On May 1, 10:50 am, CTO <debat...@gmail.com> wrote:
> Make doNothing a classmethod.
>
> class SomeClass:
>
>     @classmethod
>     def doNothing(cls):
>         pass
>
>     def function1(self):
>         print "Running function 1"
>
>     def function2(self, passedFunction=SomeClass.doNothing):
>         print "Running passed function"
>         passedFunction()
>
> someObject = SomeClass()
> someObject.function2()
> someObject.function2(someObject.function1)

It's not surprising, but I've never heard of a classmethod before.
Basically, I read that it basically removes the need for the 'self'
argument.  Very cool!

And thanks for the quick response,

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

Reply via email to