Assignments and globals
Peter Schneider-Kamp
nowonder at nowonder.de
Fri Aug 18 01:25:51 EDT 2000
echuck3 at my-deja.com wrote:
>
> settings = { 'x': {}, 'y': {} }
> class K:
> def foo(self):
global settings
> settings = settings['x']
> K().foo()
If you insert a "global settings" before accessing the global
variable, everythin will work fine.
> Is there a good reason for this? Is it even a design point, or an
> accident of implementation? I wonder if JPython has this problem.
Well, as far as I can see this could be either an error or
what you meant. Python refuses to guess.
For a more detailed view have a look at
http://www.faqts.com/knowledge-base/view.phtml/aid/2902/fid/241
and
http://www.faqts.com/knowledge-base/view.phtml/aid/4722/fid/241
Peter
--
Peter Schneider-Kamp ++47-7388-7331
Herman Krags veg 51-11 mailto:peter at schneider-kamp.de
N-7050 Trondheim http://schneider-kamp.de
More information about the Python-list
mailing list