[docs] Bug in description of namespaces and scopes

Dmitry Mugtasimov dmugtasimov at gmail.com
Tue Mar 27 10:42:52 CEST 2012


Hello,

I found it hard for me to understand the relation between namespaces and
scopes, so I tried find out why it is hard do it. I found that description
of namespaces and scopes it contradictive and brakes plain logic. I would
like to ask to refactor description somehow, so it would be logically
structured. Here is my analysis:

*http://docs.python.org/tutorial/classes.html:*
*

"A namespace is a mapping from names to objects."

> namespace is a mapping from names to objects
*

*

A scope is a textual region of a Python program where a namespace is
directly accessible. "Directly accessible" here means that an unqualified
reference to a name attempts to find the name in the namespace.

> scope is textual region

Although scopes are determined statically, they are used dynamically. At
any time during execution, there are at least three nested scopes whose
namespaces are directly accessible:

> scope owns namespaces

   -

   the innermost scope, which is searched first, contains the local names

> scope contains names

   -

   the scopes of any enclosing functions, which are searched starting with
   the nearest enclosing scope, contains non-local, but also non-global
   names

> scope contains names

   -

   the next-to-last scope contains the current module's global names

> scope contains names

   -

   the outermost scope (searched last) is the namespace containing built-in
   names

> scope is the namespace
--------------------
> namespace is a mapping from names to objects
> scope is textual region
> scope owns namespaces
> scope contains names
> scope is the namespace
--------------------
scope is textual region which owns namespaces and scope contains names
scope is a mapping from names to objects
textual region == a mapping from names to objects ?*

Please, take it seriously. Absence of strict description does not allow
full understanding of the language and its advanced usage.

-- 
Regards,
Dmitry Mugtasimov
dmugtasimov at gmail.com
+7 903 756 37 26

С уважением,
Дмитрий Мугтасимов
dmugtasimov at gmail.com
+7 903 756 37 26

--
Мобильный голосовой микроблог: govoritter.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20120327/b2ca7952/attachment.html>


More information about the docs mailing list