Message363040
> 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 |
|
Date |
User |
Action |
Args |
2020-03-01 03:48:39 | steven.daprano | set | recipients:
+ steven.daprano, smurthy |
2020-03-01 03:48:39 | steven.daprano | link | issue39800 messages |
2020-03-01 03:48:39 | steven.daprano | create | |
|