osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Recursive method in class


On 2019-09-27, ast <none at gmail.com> wrote:
> Is it feasible to define a recursive method in a class ?
> (I don't need it, it's just a trial)
>
> Here are failing codes:
>
>
> class Test:
>      def fib(self, n):
>          if n < 2: return n
>          return fib(self, n-2) + fib(self, n-1)
                  self.fib(...)

[Schnipp]

-- 
Jan v/d Broek
balglaas at dds.nl