[Tutor] Further into classes
Alan Gauld
alan.gauld at btinternet.com
Sun Sep 2 01:46:54 CEST 2007
"Ara Kooser" <ghashsnaga at gmail.com> wrote
> So I have a class set up and running. My question is how you append
> a
> list (such as self.contents = [ ]) using a method like def
> AddObject?
> class Area:
> #Methods. What you can do.
> def AddObject(self,thing):
> #pass
> self.contents.append()
>
You are almost there but you need to pass 'thing' to the append:
self.contents.append(thing)
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list