Changeset 391 for python/trunk/Doc/reference/simple_stmts.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/reference/simple_stmts.rst
r2 r391 122 122 iterable with the same number of items as there are targets in the target list, 123 123 and the items are assigned, from left to right, to the corresponding targets. 124 (This rule is relaxed as of Python 1.5; in earlier versions, the object had to125 be a tuple. Since strings are sequences, an assignment like ``a, b = "xy"`` is126 now legal as long as the string has the right length.)127 124 128 125 Assignment of an object to a single target is recursively defined as follows. … … 356 353 357 354 Deletion is recursively defined very similar to the way assignment is defined. 358 Rather tha tspelling it out in full details, here are some hints.355 Rather than spelling it out in full details, here are some hints. 359 356 360 357 Deletion of a target list recursively deletes each target, from left to right. … … 515 512 clauses to execute. 516 513 514 For full details of :keyword:`yield` semantics, refer to the :ref:`yieldexpr` 515 section. 516 517 517 .. note:: 518 518 … … 710 710 :attr:`__path__` attribute from the parent package (everything up to the last 711 711 dot in the name of the module being imported). If a finder can find the module 712 it returns a :term:`loader` (discussed later) or returns :keyword:`None`.712 it returns a :term:`loader` (discussed later) or returns ``None``. 713 713 714 714 .. index:: … … 737 737 :exc:`ImportError`. If a finder is returned then it is cached in 738 738 :data:`sys.path_importer_cache` and then used for that path entry. If no finder 739 can be found but the path exists then a value of :keyword:`None` is739 can be found but the path exists then a value of ``None`` is 740 740 stored in :data:`sys.path_importer_cache` to signify that an implicit, 741 741 file-based finder that handles modules stored as individual files should be 742 742 used for that path. If the path does not exist then a finder which always 743 returns :keyword:`None` is placed in the cache for the path.743 returns ``None`` is placed in the cache for the path. 744 744 745 745 .. index:: … … 837 837 So if you execute ``from . import mod`` from a module in the ``pkg`` package 838 838 then you will end up importing ``pkg.mod``. If you execute ``from ..subpkg2 839 imp rt mod`` from within ``pkg.subpkg1`` you will import ``pkg.subpkg2.mod``.839 import mod`` from within ``pkg.subpkg1`` you will import ``pkg.subpkg2.mod``. 840 840 The specification for relative imports is contained within :pep:`328`. 841 841 842 843 .. index:: builtin: __import__ 844 845 The built-in function :func:`__import__` is provided to support applications 846 that determine which modules need to be loaded dynamically; refer to 847 :ref:`built-in-funcs` for additional information. 842 :func:`importlib.import_module` is provided to support applications that 843 determine which modules need to be loaded dynamically. 848 844 849 845 … … 986 982 987 983 This statement supports dynamic execution of Python code. The first expression 988 should evaluate to either a string, an open file object, or a code object. If 989 it is a string, the string is parsed as a suite of Python statements which is 990 then executed (unless a syntax error occurs). [#]_ If it is an open file, the file 991 is parsed until EOF and executed. If it is a code object, it is simply 992 executed. In all cases, the code that's executed is expected to be valid as 993 file input (see section :ref:`file-input`). Be aware that the 984 should evaluate to either a Unicode string, a *Latin-1* encoded string, an open 985 file object, a code object, or a tuple. If it is a string, the string is parsed 986 as a suite of Python statements which is then executed (unless a syntax error 987 occurs). [#]_ If it is an open file, the file is parsed until EOF and executed. 988 If it is a code object, it is simply executed. For the interpretation of a 989 tuple, see below. In all cases, the code that's executed is expected to be 990 valid as file input (see section :ref:`file-input`). Be aware that the 994 991 :keyword:`return` and :keyword:`yield` statements may not be used outside of 995 992 function definitions even within the context of code passed to the … … 997 994 998 995 In all cases, if the optional parts are omitted, the code is executed in the 999 current scope. If only the first expression after :keyword:`in` is specified,996 current scope. If only the first expression after ``in`` is specified, 1000 997 it should be a dictionary, which will be used for both the global and the local 1001 998 variables. If two expressions are given, they are used for the global and local 1002 999 variables, respectively. If provided, *locals* can be any mapping object. 1000 Remember that at module level, globals and locals are the same dictionary. If 1001 two separate objects are given as *globals* and *locals*, the code will be 1002 executed as if it were embedded in a class definition. 1003 1004 The first expression may also be a tuple of length 2 or 3. In this case, the 1005 optional parts must be omitted. The form ``exec(expr, globals)`` is equivalent 1006 to ``exec expr in globals``, while the form ``exec(expr, globals, locals)`` is 1007 equivalent to ``exec expr in globals, locals``. The tuple form of ``exec`` 1008 provides compatibility with Python 3, where ``exec`` is a function rather than 1009 a statement. 1003 1010 1004 1011 .. versionchanged:: 2.4 … … 1029 1036 1030 1037 .. [#] Note that the parser only accepts the Unix-style end of line convention. 1031 If you are reading the code from a file, make sure to use universal1032 newlinemode to convert Windows or Mac-style newlines.1038 If you are reading the code from a file, make sure to use 1039 :term:`universal newlines` mode to convert Windows or Mac-style newlines.
Note:
See TracChangeset
for help on using the changeset viewer.