Newbie Variable Definition Question
Emile van Sebille
emile at fenx.com
Tue Dec 14 22:04:02 EST 1999
I seem to recall from the docs that locals and globals could
not always be relied on. Something ... ah... here it is:
.. undefined.4.2
The current implementations return the dictionary
actually used to implement the namespace, except
for functions, where the optimizer may
cause the local namespace to be implemented differently,
and locals() returns a read-only dictionary.
>From the python reference manual.
You're probably ok, but watch out.
Emile van Sebille
emile at fenx.com
-------------------
----- Original Message -----
From: Gerrit Holl <gerrit.holl at pobox.com>
To: <python-list at python.org>
Sent: Tuesday, December 14, 1999 8:51 AM
Subject: Re: Newbie Variable Definition Question
<snip>
> I prefer:
> if not locals.has_key('x') or globals.has_key('x'):
> x='default value'
>
> --
> "Nature abhors a Vacuum"
>
> -- Brian Behlendorf on OSS (Open Sources, 1999 O'Reilly and
Associates)
> 5:49pm up 4 min, 3 users, load average: 0.28, 0.37, 0.17
>
> --
> http://www.python.org/mailman/listinfo/python-list
>
>
More information about the Python-list
mailing list