Hi, I can't figure out how I can extend the 'function' built-in
class. I tried: class test(function):
def test(self):
print("test")
but I get an error. Is it possible ?
While I don't have an answer, I did find this interesting. First,
"function" doesn't seem to be in the default __buitin__ namespace:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'function' is not defined
I presume you're doing it with the following:
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Error when calling the metaclass bases
type 'function' is not an acceptable base type
but, as you mention, the inability to subclass it is somewhat
peculiar. It appears to be metaclass-related.
I'm not quite sure *why* one might want to subclass FunctionType, but
I'm also not sure why you should be *prevented* from subclassing it.
-tkc