A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2002-April/022062.html below:

[Python-Dev] Namespaces

[Python-Dev] NamespacesMartin v. Loewis martin@v.loewis.de
01 Apr 2002 10:00:04 +0200
Aahz <aahz@pythoncraft.com> writes:

> Well, no.  First-level names, yes, but each object itself is a
> namespace, so every name will be bound to an object that can contain
> names.  To use my favorite example:
> 
>     def f():
>         pass
>     
>     f.permissions = 'author'

Except that those are not names, they are attributes. Namespaces nest,
in Python; permissions does not live in namespace, which becomes
obvious if you try to nest it

def f():
    return permissions

f.permissions = 'author'
print f()

Traceback (most recent call last):
  File "a.py", line 5, in ?
    print f()
  File "a.py", line 2, in f
    return permissions
NameError: global name 'permissions' is not defined

Regards,
Martin



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4