Accessing variables in __init__.py

Gaudha sanal.vikram at gmail.com
Tue Oct 16 04:48:17 EDT 2012


my_package/
  __init__.py
  my_module1.py
  my_module2.py
  variables.py

I want to define common variables in __init__.py and use the namespace in my_module1.py or my_module2.py. Defining it is not a problem. How can call it from my modules?

If I define them in a module (say, variables.py), I can call them by importing variables.py in other modules. How can it be done if I define it in __init__.py?

It may be a silly query as I am newbie in Python. But, I would be grateful to get help.



More information about the Python-list mailing list