Is there some way I could make decimal.Decimal the default type for all numerical values in Python? I would like to be able to use Python in a manner similar to the bc and dc programs without having to call decimal.Decimal(…) for every number.
EDIT: For the uninitiated: bc.
EDIT 2: Thank you tokenize module..
At the bottom of the tokenize module’s documentation, there is a function that does exactly what I need:
- Python 3: “Example of a script rewriter that transforms float literals into Decimal objects“
- Python 2: “Example of a script re-writer that transforms float literals into Decimal objects“