[Tutor] Writing Classes in python
Rajesh R
rkrajeshin at hotmail.com
Wed Nov 1 23:04:42 CET 2006
Thanks All, It worked.
Rajesh
>From: Andreas Kostyrka <andreas at kostyrka.org>
>To: Rajesh R <rkrajeshin at hotmail.com>
>CC: Tutor at python.org
>Subject: Re: [Tutor] Writing Classes in python
>Date: Wed, 01 Nov 2006 22:39:57 +0100
>
>class Sample:
> def method1(self):
> print "method1"
>
>s = Sample()
>s.method1()
>
>Please notice, you need () to invoke a method in Python, and you need an
>explicit self argument on the method definition.
>
>Andreas
>
>Am Mittwoch, den 01.11.2006, 21:21 +0000 schrieb Rajesh R:
> > 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.
> >
> > Thanks
> > Rajesh
> >
> > _________________________________________________________________
> > Spice up your IM conversations. New, colorful and animated emoticons.
>Get
> > chatting! http://server1.msn.co.in/SP05/emoticons/
> >
> > _______________________________________________
> > Tutor maillist - Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
><< signature.asc >>
_________________________________________________________________
Live the life in style with MSN Lifestyle. Check out!
http://content.msn.co.in/Lifestyle/Default
More information about the Tutor
mailing list