Python Type Objects#
- A
type
object = an instance of type
class = a normal classtype
and class
are interchangable since Python 2.4print(type(type)) # result: <class 'type'>
print(type(str)) # result: <class 'type'>
- So
type
class is also an instance of type
class.- This is basica building block of Python, and cannot be expressed in Python language.
- In python everything is an object, so a class is an object (instance) of
type
. - For details, see this StackOverflow Post
Python Decimal Package#
quantize()
: The quantize()
method rounds a number to a fixed exponent.- Basically forces precision level for the current variable..
a.quantize(Decimal('0.01'))
works, because of the string conversion to exact level of precisiona.quantize(Decimal(0.01))
does not work (overflows precision), because 0.01 float is not precisely ‘0.01’..
Pytest Tips#
- Pytest fixtures:
- To see all fixtures including 3rd-party fixtures and local-code fixtures:
pytest -q --fixtures