while 1 vs while True

Nick Coghlan ncoghlan at iinet.net.au
Wed Dec 15 10:41:53 CET 2004


Paul Rubin wrote:
> Nick Coghlan <ncoghlan at iinet.net.au> writes:
> 
>>Until this code:
>>
>>.>>> import pdb
>>.>>> pdb.True = 0
>>.>>> pdb.x = "Darn writeable module dictionaries"
>>.>>> from pdb import True
>>.>>> True
>>0
>>.>>> from pdb import x
>>.>>> x
>>'Darn writeable module dictionaries'
> 
> 
> If Python really does behave that way, that bug should be fixed immediately.

I tried it out in the 2.4 interpreter before posting it - it certainly does 
behave that way.

And some test frameworks do make use of the capability to inject behaviour into 
the module under test (e.g. the one mentioned here: 
http://mail.python.org/pipermail/python-list/2003-April/156301.html).

This is behaviour which has been around for a while - and breaking such expected 
behaviour gratuitously isn't acceptable.

PEP 267 discusses a way of speeding access to globals/builtins without giving up 
the external binding of names.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list