GNU Info

Info Node: (python2.1-ref.info)Identifiers Names

(python2.1-ref.info)Identifiers Names


Next: Literals 2 Prev: Atoms Up: Atoms
Enter node , (file) or (file)node

Identifiers (Names)
-------------------

An identifier occurring as an atom is a reference to a local, global or
built-in name binding.  If a name is assigned to anywhere in a code
block (even in unreachable code), and is not mentioned in a `global'
statement in that code block, then it refers to a local name throughout
that code block.  When it is not assigned to anywhere in the block, or
when it is assigned to but also explicitly listed in a `global'
statement, it refers to a global name if one exists, else to a built-in
name (and this binding may dynamically change).(1)

When the name is bound to an object, evaluation of the atom yields that
object.  When a name is not bound, an attempt to evaluate it raises a
`NameError' exception.

*Private name mangling:* when an identifier that textually occurs in a
class definition begins with two or more underscore characters and does
not end in two or more underscores, it is considered a "private name"
of that class.  Private names are transformed to a longer form before
code is generated for them.  The transformation inserts the class name
in front of the name, with leading underscores removed, and a single
underscore inserted in front of the class name.  For example, the
identifier `__spam' occurring in a class named `Ham' will be
transformed to `_Ham__spam'.  This transformation is independent of the
syntactical context in which the identifier is used.  If the
transformed name is extremely long (longer than 255 characters),
implementation defined truncation may happen.  If the class name
consists only of underscores, no transformation is done.

---------- Footnotes ----------

(1) The Python interpreter provides a useful set of predefined built-in
functions.  It is not recommended to reuse (hide) these names with self
defined objects.  See the  for the descriptions of built-in functions
and methods.


automatically generated by info2www version 1.2.2.9