Pelokalan
Python ID
id en
Masuk
Proyek
reference__datamodel.po Berkas proyek · python-docs-id-3.14 · Bahasa Indonesia
Modul PO Hanya lihat
Teks sumber — English
Terjemahan — Bahasa Indonesia
``None`` or a :class:`tuple` of cells that contain bindings for the names specified in the :attr:`~codeobject.co_freevars` attribute of the function's :attr:`code object <function.__code__>`.
The :ref:`code object <code-objects>` representing the compiled function body.
Additional information about a function's definition can be retrieved from its :ref:`code object <code-objects>` (accessible via the :attr:`~function.__code__` attribute).
Modules are a basic organizational unit of Python code, and are created by the :ref:`import system <importsystem>` as invoked either by the :keyword:`import` statement, or by calling functions such as :func:`importlib.import_module` and built-in :func:`__import__`. A module object has a namespace implemented by a :class:`dictionary <dict>` object (this is the dictionary referenced by the :attr:`~function.__globals__` attribute of functions defined in the module). Attribute references are translated to lookups in this dictionary, e.g., ``m.x`` is equivalent to ``m.__dict__["x"]``. A module object does not contain the code object used to initialize the module (since it isn't needed once the initialization is done).
Code objects
Code objects represent *byte-compiled* executable Python code, or :term:`bytecode`. The difference between a code object and a function object is that the function object contains an explicit reference to the function's globals (the module in which it was defined), while a code object contains no context; also the default argument values are stored in the function object, not in the code object (because they represent values calculated at run-time). Unlike function objects, code objects are immutable and contain no references (directly or indirectly) to mutable objects.
A :class:`bytes` object containing encoded source location information. The exact format is an implementation detail and may change between Python versions. Use :meth:`~codeobject.co_lines` and :meth:`~codeobject.co_positions` for supported access to line and position information. To create a modified copy of a code object, use :meth:`~codeobject.replace`.
The required stack size of the code object
Future feature declarations (for example, ``from __future__ import division``) also use bits in :attr:`~codeobject.co_flags` to indicate whether a code object was compiled with a particular feature enabled. See :attr:`~__future__._Feature.compiler_flag`.
If a code object represents a function and has a docstring, the :data:`~inspect.CO_HAS_DOCSTRING` bit is set in :attr:`~codeobject.co_flags` and the first item in :attr:`~codeobject.co_consts` is the docstring of the function.
Methods on code objects
Returns an iterable over the source code positions of each :term:`bytecode` instruction in the code object.
This feature requires storing column positions in code objects which may result in a small increase of disk usage of compiled Python files or interpreter memory usage. To avoid storing the extra information and/or deactivate printing the extra traceback information, the :option:`-X` ``no_debug_ranges`` command line flag or the :envvar:`PYTHONNODEBUGRANGES` environment variable can be used.
Return a copy of the code object with new values for the specified fields.
Code objects are also supported by the generic function :func:`copy.replace`.
The :ref:`code object <code-objects>` being executed in this frame. Accessing this attribute raises an :ref:`auditing event <auditing>` ``object.__getattr__`` with arguments ``obj`` and ``"f_code"``.
The "precise instruction" of the frame object (this is an index into the :term:`bytecode` string of the :ref:`code object <code-objects>`)
code object
objek kode
co_argcount (code object attribute)
co_posonlyargcount (code object attribute)
co_kwonlyargcount (code object attribute)
co_code (code object attribute)
co_consts (code object attribute)
co_filename (code object attribute)
co_firstlineno (code object attribute)
co_flags (code object attribute)
co_name (code object attribute)
co_names (code object attribute)
co_nlocals (code object attribute)
co_stacksize (code object attribute)
co_varnames (code object attribute)
co_cellvars (code object attribute)
co_freevars (code object attribute)
co_qualname (code object attribute)