global var

S

Steven Bethard

raver2046 said:
How to have a global var in python ?

You can, but you probably don't want to. What's your use case? Example
code and what you'd like it to do would be helpful.

STeVe
 
N

Nick Coghlan

Michael said:
"global var" will give you a global variable named "var".

Whether this advice is correct or not depends greatly on what the OP means by
'global' :)

Module global, it's right, application global it's wrong. Given the nature of
the question, I suspect the latter.

Cheers,
Nick.
 
J

Jeff Shannon

Nick said:
Whether this advice is correct or not depends greatly on what the OP
means by 'global' :)

Module global, it's right, application global it's wrong. Given the
nature of the question, I suspect the latter.

And even there, one must be careful. "global var" won't really give you
a global variable; it will cause the name "var", when used locally, to
refer to a pre-existing module-level reference "var". No variables are
actually created in the execution of "global var".

Jeff Shannon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,219
Messages
2,571,127
Members
47,744
Latest member
FrederickM

Latest Threads

Top