Re: Extending the 'function' built-in class

2013-12-02 Thread G.
Le 02-12-2013, Steven D'Aprano st...@pearwood.info a écrit : There are plenty of ways to extend functions. Subclassing isn't one of them. Thank you very mych for your complete answer; I falled back to your last proposal by myself in my attempts; I am happyt to learn about the other ways also.

Extending the 'function' built-in class

2013-12-01 Thread G.
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. -- https://mail.python.org/mailman/listinfo/python-list

Re: Extending the 'function' built-in class

2013-12-01 Thread Roy Smith
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

Re: Extending the 'function' built-in class

2013-12-01 Thread G.
Le 01-12-2013, Roy Smith r...@panix.com a écrit : 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

Re: Extending the 'function' built-in class

2013-12-01 Thread Tim Chase
On 2013-12-01 19:18, G. 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 ? While I don't have an answer, I did find this interesting. First, function doesn't

Re: Extending the 'function' built-in class

2013-12-01 Thread Gary Herron
On 12/01/2013 11:18 AM, G. 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. What error do you get? What version of Python? What OS? And in

Re: Extending the 'function' built-in class

2013-12-01 Thread G.
Le 01-12-2013, Gary Herron gary.her...@islandtraining.com a écrit : And in particular: What 'function' built-in class? I know of no such thing, and the error message I get with your code says exactly that: NameError: name 'function' is not defined Did you not get that same error? Yes,

Re: Extending the 'function' built-in class

2013-12-01 Thread Robert Kern
On 2013-12-01 19:43, Tim Chase wrote: 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. Previously:

Re: Extending the 'function' built-in class

2013-12-01 Thread Mark Janssen
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 ? It has to do with differing models of computation, and python isn't designed for this. Perhaps you're

Re: Extending the 'function' built-in class

2013-12-01 Thread alex23
On 2/12/2013 5:18 AM, G. 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 ? Others have pointed out that you cannot subclass the function type. Could you

Re: Extending the 'function' built-in class

2013-12-01 Thread Steven D'Aprano
On Sun, 01 Dec 2013 19:18:58 +, G. 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 ? You cannot subclass the function type directly, but you can