Carl Banks wrote:
On Aug 26, 8:13 am, Dave Angel <da...@ieee.org> wrote:
You can probably work around this by replacing the staticmethod
decorator with an equivalent function call:.

class Demo9(object):
    def fact(n):
        if n < 2:
            return 1
        else:
            return n * Demo.fact(n - 1)

    _classvar =act(5)
    fact =taticmethod(fact)

print Demo9._classvar
xx =emo9()
print xx.fact(6)
print Demo9.fact(8)

This won't work normally.  It only worked for you because you made a
typo.


Carl Banks

Sorry about the typo. I was trying out several different versions of the class in the same module, and forgot to include to change Demo to Demo9 in the recursive call.

I didn't like that approach anyway, as it smacked of taking advantage of some implementation accident. The other approaches are more straightforward.


DaveA
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to