Unification of Methods and Functions

Greg Ewing greg at cosc.canterbury.ac.nz
Thu May 6 23:59:20 EDT 2004


David MacQuigg wrote:
> Static methods
> are necessary because it is a very natural thing to write a method in
> a class that needs to work without being bound to any particular
> instance.

I beg to differ. It might seem natural to someone who's
been exposed to C++ or Java, but I don't think it's
a priori a natural thing at all.

In Python, a function defined inside a class is a method.
If you want a function to be a method, you put it inside
a class. If you don't want it to be a method, you don't
put it inside a class. It's as simple as that.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list