Namespaces in functions vs classes
Rhodri James
rhodri at wildebst.demon.co.uk
Tue Apr 19 18:00:45 EDT 2011
On Tue, 19 Apr 2011 17:47:40 +0100, Gerald Britton
<gerald.britton at gmail.com> wrote:
>> Gerald Britton wrote:
>>> I now understand the Python does
>>> not consider a class definition as a separate namespace as it does for
>>> function definitions. That is a helpful understanding.
>
>> That is not correct. Classes are separate namespaces -- they just
>> aren't automatically searched. The only namespaces that are
>> automatically searched are local, non-local, global, and built-in.
>
> I see you misunderstood my observation: Python does not consider a class
> definition as a separate namespace *as it does* for function definitions.
This phrase normally parses as "Python does not consider a class
definition as a separate namespace. In contrast, Python does consider a
function definition as a separate namespace." If you meant "Python does
not consider a class definition as a separate namespace *in the same way*
that it does for function definitions," saying so would make life easier
for the fairly large number of readers of this newsgroup whose first
language isn't English.
Language abuse: it's not just Python. A donation of just $5 will keep a
programmer in prepositions for a month. $50 will supply enough articles
to keep a small company understandable for over a year. With your
generous help, we can beat this scourge!
Ahem.
Normal service will now be resumed.
--
Rhodri James *-* Wildebeest Herder to the Masses
More information about the Python-list
mailing list