[Tutor] static methods & class methods
Alan Gauld
alan.gauld at btinternet.com
Fri Apr 20 21:11:25 CEST 2012
On 20/04/12 16:32, Surya K wrote:
> I java it really works well.
Java:
this.foo()
Python:
self.foo()
Works almost identically in both.
Of course in Java the 'this' is optional but many style guides
recommend its use to make it clear where the function lives...
If you really like 'this' over 'self' you can even do that too:
class C:
def foo(this): pass
def bar(this):
this.foo()
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list