In article <529b8ba2$0$2270$426a7...@news.free.fr>, "G." <gru...@grumsk.tz> wrote:
> 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 ? > > Regards, G. It really helps to give us some basic information when asking questions. To start, what version of Python are you using, and what error message do you get? At least in Python 2 (but, I'm guessing, maybe, you're using Python 3, since you put parens in your print() statement?), there is no built-in class called "function". There are built-in functions, and they are of type builtin_function_or_method. When I try to subclass that by doing: class foo(type(open)): pass I get: Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Error when calling the metaclass bases type 'builtin_function_or_method' is not an acceptable base type So, we're back to asking what version you're using and what error message you got. -- https://mail.python.org/mailman/listinfo/python-list