[issue39800] Inconsistent/incomplete disassembly of methods vs method source code
Steven D'Aprano
report at bugs.python.org
Sat Feb 29 22:48:39 EST 2020
Steven D'Aprano <steve+python at pearwood.info> added the comment:
> BTW how else are methods/functions are created in Python except via def?
Functions are objects like everything else in Python, so they have a
type, which has a constructor:
from types import FunctionType
The documentation for FunctionType is a bit thin, so you may need to
experiment a bit to get the details right, but it can be done.
Unfortunately copy.copy doesn't actually copy functions, which is in my
opinion a bug (see #39805) but if you search the internet, you will find
code that makes independent copies of function objects.
Methods are different from functions, and like functions, they
too have a type with a constructor:
from types import MethodType
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39800>
_______________________________________
More information about the Python-bugs-list
mailing list