This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients smurthy, steven.daprano
Date 2020-03-01.03:48:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20200301034728.GC4624@ando.pearwood.info>
In-reply-to <1582996890.73.0.351359856665.issue39800@roundup.psfhosted.org>
Content
> 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
History
Date User Action Args
2020-03-01 03:48:39steven.dapranosetrecipients: + steven.daprano, smurthy
2020-03-01 03:48:39steven.dapranolinkissue39800 messages
2020-03-01 03:48:39steven.dapranocreate