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
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
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
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
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
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
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
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
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()
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.
10 matches
Mail list logo