pythondecimalinterpreter

Making decimal.Decimal the default numerical type in Python


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.


Solution

  • At the bottom of the tokenize module's documentation, there is a function that does exactly what I need: