Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed222a7

Browse files
authored
Update data model docs to include missing attributes for code objects (GH-13696)
Include and document co_posonlyargcount and co_kwonlyargcount
1 parent 3a46d5c commit ed222a7

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

Doc/reference/datamodel.rst

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,8 @@ Internal types
890890

891891
.. index::
892892
single: co_argcount (code object attribute)
893+
single: co_posonlyargcount (code object attribute)
894+
single: co_kwonlyargcount (code object attribute)
893895
single: co_code (code object attribute)
894896
single: co_consts (code object attribute)
895897
single: co_filename (code object attribute)
@@ -906,18 +908,21 @@ Internal types
906908

907909
Special read-only attributes: :attr:`co_name` gives the function name;
908910
:attr:`co_argcount` is the number of positional arguments (including arguments
909-
with default values); :attr:`co_nlocals` is the number of local variables used
910-
by the function (including arguments); :attr:`co_varnames` is a tuple containing
911-
the names of the local variables (starting with the argument names);
912-
:attr:`co_cellvars` is a tuple containing the names of local variables that are
913-
referenced by nested functions; :attr:`co_freevars` is a tuple containing the
914-
names of free variables; :attr:`co_code` is a string representing the sequence
915-
of bytecode instructions; :attr:`co_consts` is a tuple containing the literals
916-
used by the bytecode; :attr:`co_names` is a tuple containing the names used by
917-
the bytecode; :attr:`co_filename` is the filename from which the code was
918-
compiled; :attr:`co_firstlineno` is the first line number of the function;
919-
:attr:`co_lnotab` is a string encoding the mapping from bytecode offsets to
920-
line numbers (for details see the source code of the interpreter);
911+
with default values); :attr:`co_posonlyargcount` is the number of
912+
positional-only arguments (including arguments with default values);
913+
:attr:`co_kwonlyargcount` is the number of keyword-only arguments (including
914+
arguments with default values); :attr:`co_nlocals` is the number of local
915+
variables used by the function (including arguments); :attr:`co_varnames` is a
916+
tuple containing the names of the local variables (starting with the argument
917+
names); :attr:`co_cellvars` is a tuple containing the names of local variables
918+
that are referenced by nested functions; :attr:`co_freevars` is a tuple
919+
containing the names of free variables; :attr:`co_code` is a string representing
920+
the sequence of bytecode instructions; :attr:`co_consts` is a tuple containing
921+
the literals used by the bytecode; :attr:`co_names` is a tuple containing the
922+
names used by the bytecode; :attr:`co_filename` is the filename from which the
923+
code was compiled; :attr:`co_firstlineno` is the first line number of the
924+
function; :attr:`co_lnotab` is a string encoding the mapping from bytecode
925+
offsets to line numbers (for details see the source code of the interpreter);
921926
:attr:`co_stacksize` is the required stack size (including local variables);
922927
:attr:`co_flags` is an integer encoding a number of flags for the interpreter.
923928

0 commit comments

Comments
 (0)