Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Equivalent of extern(C/C++) in Python?

Status
Not open for further replies.

Impaled

Programmer
Apr 11, 2005
6
US
I'm new to python, and trying to find a way of accesing a variable that is in another file. I think that "global" is kind of different in python than in most languages. Anyway is there an equivalent of "extern" like in c or c++? any help is greatly appreciated :)

regards,

John
 
If you've imported the file and it's declared as global in the other file, then use "global variablename" in your file.

Or you can use "from otherfile import variablename".

Or you can say "import otherfile" and reference "otherfile.variablename".
 
uhhhh holy moly thanks. I can't believe i forgot from blah import blah2. I took a class on python like a year ago but I haven't foudn my notes on it. Thank you very much :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top