FAQ

sean at activeprime.com (Sean) writes:

Is there any way to access global variables defined from within an
imported module? For example, lets say have a file called test2.py
that defines a simple class: [...]
Now I have another file that imports test2, sets a global variable
called globalVar, and calles printGlobal() like so:
[...]

You could explicitly pass MyClass constructor the globals dict
(globals()), and have it use that. Not very nice.

What's your end goal with this, though?

Why not have a class to represent this 'global' state (since it seems
it isn't really global)?


John

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 6 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedAug 4, '03 at 2:27p
activeAug 5, '03 at 7:58p
posts6
users5
websitepython.org

People

Translate

site design / logo © 2022 Grokbase