Self function
BJörn Lindqvist
bjourne at gmail.com
Mon May 4 08:39:08 EDT 2009
2009/5/4 <bearophileHUGS at lycos.com>:
> An idea-syntax:
>
> def fact(n):
> return 1 if n <= 1 else n * inspect.self(n - 1)
>
> Or even a lambda, because you don't need the name anymore to call the
> function:
>
> fact = lambda n: 1 if n <= 1 else n * self(n - 1)
How would it work with methods?
class Foo:
def fac(self, n):
return 1 if n <= 1 else n * self.self(n-1)
??
--
mvh Björn
More information about the Python-list
mailing list