[Python-Dev] bug or a feature?

Phillip J. Eby pje at telecommunity.com
Thu Jun 12 12:06:32 CEST 2008


At 02:59 AM 6/12/2008 +0200, Maciej Fijalkowski wrote:
>It's about abusing locals, which are not even given that they'll
>modify this dict.

Note that class bodies are a special case: as of PEP 3115, it's 
possible for a class body's locals to be a non-dictionary object, so 
it makes no sense to make a class body's locals() or f_locals return 
some *other* object.

Meanwhile, as a practicality-beats-purity matter, you're going to run 
into compatibility problems with a fair number of libraries in the 
field (including Zope and Twisted, and anything using them) if you 
*don't* support locals() modification in class bodies.  (Those other 
libraries don't use non-string keys like AddOns does, but they *do* 
depend on modifying a class body's frame locals.)



More information about the Python-Dev mailing list