Can I use __init__.py to define global variables?

I want to define a constant that should be available in all of the submodules of a package. I’ve thought that the best place would be in in the __init__.py file of the root package. But I don’t know how to do this. Suppose I have a few subpackages and each with several modules. How can I access that variable from these modules?

class variables is shared across all instances in python?

I started coding in python a week ago, it is my mistake i started coding using oops,classes and objects that soon. I assumed my C++ proficiency will help…. I got bit by the following code class A: var=0 list=[] def __init__(self): pass Here to my surprise, var and list are kinda global variable, it is … Read more