I have a file num.py in which I have defined a variable as

import decimal

fivedecimal = Decimal(10) ** -5

This particular variable is being used in other python files as:

import decimal

from num import fivedecimal

b= decimal.Decimal(100.05).quantize(fivedecimal)

Now the problem I am facing is that I have to add a parameter for rounding=ROUND_CEILING but I have to do that in the first file only as the variable fivedecimal is being used in multiple files in different contexts for quantizing values to five decimal places, but I want to make a change in only the first file so that I don't have to make changes in the multiple files where I am importing fivedecimal.

Basically my question is if there is a way in which I can specify the two parameters as a variable in the first file (num.py) that is fivedecimal = (Decimal(10)** -5, rounding=ROUND_CEILING) and then automatically wherever I am using the fivedecimal variable the decimals are being rounded off as this will save me a lot of time as there are more than 250 places where I am using the fivedecimal variable and if this is not possible then I will have to make the changes in all the 250 places by adding an extra parameter rounding=ROUND_CEILING i.e. quantize(fivedecimal, rounding=ROUND_CEILING).

0

There are 0 answers