Hi,

I need to define some common variables in one file and use that file in my python script , Like in php we define some variable in (eg :definevble.config) file, later we will use that file using include method in php script.

Plz let me know how to do this in pyhon.


Thanks
-Shyami

You put your variable definitions in a .py file you could name it definevble.py if you wanted to.

Then from the other python file (.py) that wanted the variables you add a line:

from definevble import *

That imports everything in that file into this file.

I think that will do what you want.

For example if vardefs.py contains:

pie="Apple"

and vartest.py contains:

from vardefs import *
print pie

The output of vartest.py will be "Apple"

Thanks Murtan !
It is working

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.