tt = a, b = t
Philip Swartzleonard
starx at pacbell.net
Tue Feb 5 02:57:15 EST 2002
Steve Holden || Mon 14 Jan 2002 04:54:38a:
> "rihad" <rihad at mail.ru> wrote in message
> news:qfm34uch7hrkc46jqqndpqc9nb657pv49j at 4ax.com...
>> On Sun, 13 Jan 2002 18:58:25 GMT, Courageous <jkraska at san.rr.com>
>> wrote:
>>
>> >>>> None
>> >2
>> >>>>
>> Huh? This works! What are the reasons behind allowing to assign to a
>> language construct???
>>
> This is Pythonicity at its most Pythonic. In actual fact the singleton
> value None is by default associated with the name __builtins__.None --
> which is to say, any program component will be able to access this
> value, assuming that the name None does not exist in any namespace
> taking prioirity over __builtins__, which is the namespace of last
> resort.
>
> So normally, when you execute a statement equivalent to
>
> None = "Hi, Mom!"
>
> you're creating a *local* binding to the name None, which your other
> code will access in perference to the built-in as a result of the
> namespace searching rules.
>
> [ Other Bad Things... ]
I got bit by this quite accidentally as well. I wrote 'locals = globals()'
(or some such, preparing to spawn a debug shell), and it spits back 'type
module not callable' or something to that effect. About twenty minutes
later i realized it was because i have a project module named 'globals.py'
that's imported here, and that's superceeding it. At least you can always
do __builtins__.x() :).
(FWIW, i -was- careful when i named this, i went over the reserved words
and language reference and all that, but i didn't think to check builtins
and i'd never heard of this function. I should probably change the name but
I can't really think of anything else that is short enough (maybe just glo
:) )
--
Philip Sw "Starweaver" [rasx] :: www.rubydragon.com
More information about the Python-list
mailing list