Re: property using a classmethod

2009-07-10 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : (snip) You could write your own custom descriptor. Or just use an additional level of indirection, ie: myProperty = property(lambda self: self.myClassMethod()) Sorry, looks like I didn't read carefully enough. The above code won't work if you intend to looku

Re: property using a classmethod

2009-07-10 Thread Bruno Desthuilliers
Lie Ryan a écrit : Bruno Desthuilliers wrote: Lie Ryan a écrit : Emanuele D'Arrigo wrote: (snip) Ultimately all I want is a non-callable class-level attribute MyClass.myProperty that gives the result of MyClass.myClassMethod(). This works like what you seem to want (it's ugly): Ugly, indeed

Re: property using a classmethod

2009-07-09 Thread Lie Ryan
Bruno Desthuilliers wrote: > Lie Ryan a écrit : >> Emanuele D'Arrigo wrote: > (snip) >>> Ultimately all I want is a non-callable class-level attribute >>> MyClass.myProperty that gives the result of MyClass.myClassMethod(). >> >> This works like what you seem to want (it's ugly): > > Ugly, indeed.

Re: property using a classmethod

2009-07-09 Thread Scott David Daniels
Emanuele D'Arrigo wrote: class MyClass(object): @classmethod def myClassMethod(self): print "ham" myProperty = property(myClassMethod, None, None) ... doesn't work and returns a TypeError: So, how do I do this? Ultimately all I want is a non-callable class-level attrib

Re: property using a classmethod

2009-07-09 Thread Bruno Desthuilliers
Lie Ryan a écrit : Emanuele D'Arrigo wrote: (snip) Ultimately all I want is a non-callable class-level attribute MyClass.myProperty that gives the result of MyClass.myClassMethod(). This works like what you seem to want (it's ugly): Ugly, indeed. And an extreme case of arbitrary overcomplex

Re: property using a classmethod

2009-07-09 Thread Lie Ryan
Emanuele D'Arrigo wrote: > Greetings, > > today I did something like this: > > class MyClass(object): > > @classmethod > def myClassMethod(self): > print "ham" > > myProperty = property(myClassMethod, None, None) > > As many of you know this doesn't work and returns a Typ

Re: property using a classmethod

2009-07-09 Thread Bruno Desthuilliers
Emanuele D'Arrigo a écrit : Greetings, today I did something like this: class MyClass(object): @classmethod def myClassMethod(self): Usually, the first argument of classmethods is named 'cls' print "ham" myProperty = property(myClassMethod, None, None) As many of

property using a classmethod

2009-07-09 Thread Emanuele D'Arrigo
Greetings, today I did something like this: class MyClass(object): @classmethod def myClassMethod(self): print "ham" myProperty = property(myClassMethod, None, None) As many of you know this doesn't work and returns a TypeError: the object passed to the property is not a