Re: How to use a class property to store function variables?

2010-04-28 Thread GZ
On Apr 27, 9:20 pm, alex23 wuwe...@gmail.com wrote: GZ zyzhu2...@gmail.com wrote: I do not think it will help me. I am not trying to define a function fn() in the class, but rather I want to make it a function reference so that I can initialize it any way I like later. It always helps to

Re: How to use a class property to store function variables?

2010-04-28 Thread GZ
On Apr 27, 9:20 pm, alex23 wuwe...@gmail.com wrote: GZ zyzhu2...@gmail.com wrote: I do not think it will help me. I am not trying to define a function fn() in the class, but rather I want to make it a function reference so that I can initialize it any way I like later. It always helps to

Re: How to use a class property to store function variables?

2010-04-28 Thread Chris Rebert
On Tue, Apr 27, 2010 at 11:02 PM, GZ zyzhu2...@gmail.com wrote: On Apr 27, 9:20 pm, alex23 wuwe...@gmail.com wrote: GZ zyzhu2...@gmail.com wrote: I do not think it will help me. I am not trying to define a function fn() in the class, but rather I want to make it a function reference so

Re: How to use a class property to store function variables?

2010-04-28 Thread GZ
On Apr 28, 1:20 am, Chris Rebert c...@rebertia.com wrote: On Tue, Apr 27, 2010 at 11:02 PM, GZ zyzhu2...@gmail.com wrote: On Apr 27, 9:20 pm, alex23 wuwe...@gmail.com wrote: GZ zyzhu2...@gmail.com wrote: I do not think it will help me. I am not trying to define a function fn() in the

Re: How to use a class property to store function variables?

2010-04-28 Thread Bruno Desthuilliers
GZ a écrit : (snip) Ah, this totally works. The key is to use the staticmethod function. staticmethod is not a function, it's a class. Another question: I am not sure how staticmethod works internally. And the python doc does not seem to say. What does it do? It's easy to figure this out

Re: How to use a class property to store function variables?

2010-04-27 Thread Chris Rebert
On Tue, Apr 27, 2010 at 4:36 PM, GZ zyzhu2...@gmail.com wrote: I want to store a reference to a function into a class property. So I am expecting that: class A:     fn = lambda x: x fn = A.fn fn(1) Traceback (most recent call last):  File string, line 1, in string TypeError: unbound

Re: How to use a class property to store function variables?

2010-04-27 Thread Terry Reedy
On 4/27/2010 7:36 PM, GZ wrote: I want to store a reference to a function into a class property. So I am expecting that: class A: fn = lambda x: x fn = A.fn fn(1) Traceback (most recent call last): File string, line 1, instring TypeError: unbound methodlambda() must be called with A

Re: How to use a class property to store function variables?

2010-04-27 Thread GZ
Hi Chris, On Apr 27, 6:43 pm, Chris Rebert c...@rebertia.com wrote: On Tue, Apr 27, 2010 at 4:36 PM, GZ zyzhu2...@gmail.com wrote: I want to store a reference to a function into a class property. So I am expecting that: class A:     fn = lambda x: x fn = A.fn fn(1) Traceback

Re: How to use a class property to store function variables?

2010-04-27 Thread MRAB
Terry Reedy wrote: On 4/27/2010 7:36 PM, GZ wrote: I want to store a reference to a function into a class property. So I am expecting that: class A: fn = lambda x: x fn = A.fn fn(1) Traceback (most recent call last): File string, line 1, instring TypeError: unbound methodlambda()

Re: How to use a class property to store function variables?

2010-04-27 Thread alex23
GZ zyzhu2...@gmail.com wrote: I do not think it will help me. I am not trying to define a function fn() in the class, but rather I want to make it a function reference so that I can initialize it any way I like later. It always helps to try an idea out before dismissing it out of hand.