Return true if the object is a code object. Code objects provide these attributes: co_argcount number of arguments (not including * or ** args) co_code string of raw compiled bytecode co_consts tuple of constants used in the bytecode co_filename
(object)
| 39 | return isinstance(object, types.FunctionType) |
| 40 | |
| 41 | def iscode(object): |
| 42 | """Return true if the object is a code object. |
| 43 | |
| 44 | Code objects provide these attributes: |
| 45 | co_argcount number of arguments (not including * or ** args) |
| 46 | co_code string of raw compiled bytecode |
| 47 | co_consts tuple of constants used in the bytecode |
| 48 | co_filename name of file in which this code object was created |
| 49 | co_firstlineno number of first line in Python source code |
| 50 | co_flags bitmap: 1=optimized | 2=newlocals | 4=*arg | 8=**arg |
| 51 | co_lnotab encoded mapping of line numbers to bytecode indices |
| 52 | co_name name with which this code object was defined |
| 53 | co_names tuple of names of local variables |
| 54 | co_nlocals number of local variables |
| 55 | co_stacksize virtual machine stack space required |
| 56 | co_varnames tuple of names of arguments and local variables |
| 57 | |
| 58 | """ |
| 59 | return isinstance(object, types.CodeType) |
| 60 | |
| 61 | # ------------------------------------------------ argument list extraction |
| 62 | # These constants are from Python's compile.h. |