[Tutor] Writing Classes in python

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Nov 1 22:36:33 CET 2006



On Wed, 1 Nov 2006, Rajesh R wrote:

> I am new to Python and i have a very basic question about writing 
> classes. Lets say i have the following code :
>
[code cut]

Hi Rajesh,

Take a look at a Python class tutorial:

http://www.diveintopython.org/object_oriented_framework/defining_classes.html

The syntax you're writing is almost right, but there are some specifics 
that you're missing.  In Python, methods need to take an explicit 'self' 
parameter.


Good luck!


More information about the Tutor mailing list