[Tutor] Writing Classes in python
kent37 at tds.net
Wed Nov 1 22:28:43 CET 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 :
> class Sample:
> 'A simple class'
> def method1():
> print 'Inside Method1'
> When i create an instance of the class and when i try to call the method
> method1, i get an error message.
> What i do is on the promt, i import the class, create an instance say
> obj=Sample and i call the method obj.method1
> Am i doing something wrong or i might have not understood the class coding
> in Python.
You need parentheses for calls in Python. Try obj=Sample() and
More information about the Tutor