- 4.2.1. Binding of names
- -----------------------
- *Names* refer to objects. Names are introduced by name binding
- operations.
- The following constructs bind names:
- * formal parameters to functions,
- * class definitions,
- * function definitions,
- * assignment expressions,
- * targets that are identifiers if occurring in an assignment:
- * "for" loop header,
- * after "as" in a "with" statement, "except" clause, "except*"
- clause, or in the as-pattern in structural pattern matching,
- * in a capture pattern in structural pattern matching
- * "import" statements.
- The "import" statement of the form "from ... import *" binds all names
- defined in the imported module, except those beginning with an
- underscore. This form may only be used at the module level.
- A target occurring in a "del" statement is also considered bound for
- this purpose (though the actual semantics are to unbind the name).
- Each assignment or import statement occurs within a block defined by a
- class or function definition or at the module level (the top-level
- code block).
- If a name is bound in a block, it is a local variable of that block,
- unless declared as "nonlocal" or "global". If a name is bound at the
- module level, it is a global variable. (The variables of the module
- code block are local and global.) If a variable is used in a code
- block but not defined there, it is a *free variable*.
- Each occurrence of a name in the program text refers to the *binding*
- of that name established by the following name resolution rules.
- See also:
- Python Classes and Objects >> Python Binding a Name to an Object
Python software and documentation are licensed under the PSF License Agreement.
Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.
Some software incorporated into Python is under different licenses. The licenses are listed with code falling under that license. See Licenses and Acknowledgements for Incorporated Software for an incomplete list of these licenses.
Python and it's documentation is:
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives. All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.
See History and License for complete license and permissions information:
https://docs.python.org/3/license.html#psf-license