~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Doc/library/symtable.rst

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
   :synopsis: Interface to the compiler's internal symbol tables.
6
6
 
7
7
.. moduleauthor:: Jeremy Hylton <jeremy@alum.mit.edu>
8
 
.. sectionauthor:: Benjamin Peterson
 
8
.. sectionauthor:: Benjamin Peterson <benjamin@python.org>
9
9
 
10
10
 
11
11
Symbol tables are generated by the compiler from AST just before bytecode is
144
144
 
145
145
      Return ``True`` if the symbol is global.
146
146
 
 
147
   .. method:: is_declared_global()
 
148
 
 
149
      Return ``True`` if the symbol is declared global with a global statement.
 
150
 
147
151
   .. method:: is_local()
148
152
 
149
153
      Return ``True`` if the symbol is local to its block.
164
168
      If the name is used as the target of a function or class statement, this
165
169
      will be true.
166
170
 
 
171
      For example::
 
172
 
 
173
         >>> table = symtable.symtable("def some_func(): pass", "string", "exec")
 
174
         >>> table.lookup("some_func").is_namespace()
 
175
         True
 
176
 
167
177
      Note that a single name can be bound to multiple objects.  If the result
168
178
      is ``True``, the name may also be bound to other objects, like an int or
169
179
      list, that does not introduce a new namespace.