strings in the global section

Tim Chase python.list at tim.thechases.com
Thu Oct 12 21:49:58 CEST 2006


>> Works, but something different ?
> 
> Excuse me, what do you mean?

Sounded like the OP wanted a behavior similar to "auto-globals" 
that has been a long-cursed aspect of PHP.  That, without 
specifying it, local-variables should be global if their name 
exists in the global namespace.  Python seems to behave this way 
when reading, but when writing, writes to the local namespace. 
Moderately confusing when first encountered, but it makes sense 
in short order.

If auto-writing to globals were permitted, all sorts of weird 
behaviors could ensue and accompanying breakage of existing code. 
  I'm quite happy with not using "global" at all (okay, there's 
been once or twice I've wanted to modify a module-level settings 
structure, but otherwise...).

For the most part, using "global" is cause to be smacked in the 
head as it makes for a nightmare maint.-wise.	

-tkc






More information about the Python-list mailing list