Le Jeudi 01 Juin 2006 13:12, Eric Brunel a écrit :
> class C1(C):
>    f = int

int is not a function but a type, but it's callable so int(0) return 0.

> class C2(C):
>    f = lambda x: x != 0

lambda is a function, applied as a class attribute it becomes a method so it's 
called with a first parameter representing the instance, self.f(0) in the 
__init__  becomes C2.f(self, 0), so the lambda should be :

    f = lambda s, x: x != 0 # s for self, some poeple use _

this exactly the same as :

   def f(self, val) :
       return x != 0

(that lambda will return True or False i expect this is not what you want)

-- 
_____________

Maric Michaud
_____________

Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to