I currently have a module, my_module
, which contains classes.py
:
from . import config
class Class1:
@staticmethod
def method_one(x)
return x + config.constant
@staticmethod
def method_two(y)
return x - config.constant
My problem is that I want to be able to have multiple instances of the module with different values for config.constant
. Ideally, I'd have a new class called MyClass
where the constant would be an instance variable, so that this would work:
instance1 = MyClass(5)
instance1.Class1.method_one(5) # 10
instance2 = MyClass(0)
instance2.Class1.method_one(5) # 5
Is there a way to do this without modifying the classes which are in my_module
?