0

I'm not sure what I'm trying to do is even possible:

Basically I got a config.py file, it contains some variables, let's say var1 is one of them.

I want that by doing config.var1 = 'some value' what will actually happen is config.some_method('some value')

Is that possible?

3
  • 2
    Check this out. stackoverflow.com/questions/25456448/… Commented Dec 12, 2016 at 9:16
  • well that sucks Commented Dec 12, 2016 at 9:21
  • 1
    Read the linked answer more carefully: You can do it, as long as config is not a module but an object of a class you define. You could even name both config, and import it with from config import config to keep the rest of your code the same. Commented Dec 12, 2016 at 11:47

1 Answer 1

0

You can't do this with a module.

Use a class, with a @property.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.