4 examples of 'remove decimal in python' in Python

Every line of 'remove decimal in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
16def format_decimal(value):
17 return Decimal(value.quantize(Decimal('.01'), rounding=ROUND_HALF_UP))

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

372def test__DECIMAL_to_python(self):
373 """Convert a MySQL DECIMAL to a Python decimal.Decimal type"""
374 data = b'3.14'
375 exp = Decimal('3.14')
376 res = self.cnv._DECIMAL_to_python(data)
378 self.assertEqual(exp, res)
380 self.assertEqual(self.cnv._DECIMAL_to_python,
381 self.cnv._NEWDECIMAL_to_python)
60def test_decimal_int(self):
61 a, b = mathfilters.handle_float_decimal_combinations(Decimal('2.0'), 1, '+')
62 self.assertTrue(isinstance(a, Decimal), 'Type is {0}'.format(type(a)))
63 self.assertTrue(isinstance(b, int), 'Type is {0}'.format(type(b)))
32def digits(s):
33 if not s:
34 return ''
35 if type(s) is int:
36 return s
37 return re.sub('[^0-9]', '', s)

Related snippets