Re: Lists in classes

2007-07-15 Thread Alex Popescu
On Jul 13, 6:02 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Alex Popescu a écrit : > (snip) > > > > > You are defining the list in the class context and so it becomes a > > class field/member. > > 'attribute' is the pythonic term. Thanks! I'm just a couple of weeks Python old, so I am st

Re: [Fwd: RE: Lists in classes]

2007-07-12 Thread Wildemar Wildenburger
Adam Pletcher wrote: > I'm curious (and somewhat new to Python)... What's the benefit of > inheriting from 'object'? > > The docs aren't clear on that, nor is that used in the class examples > I've seen. > Thanks in advance. > Well, they are, but they are just not well integrated. Which they, t

[Fwd: RE: Lists in classes]

2007-07-12 Thread Wildemar Wildenburger
Another one bitten by the 'missing' reply-to munging ;) You might want to ensure that you always reply to python-list@python.org intsead of the message author. Original Message Subject: RE: Lists in classes Date: Thu, 12 Jul 2007 16:58:50 -0500 From: Ada

Re: Lists in classes

2007-07-12 Thread Bruno Desthuilliers
Alex Popescu a écrit : (snip) > > You are defining the list in the class context and so it becomes a > class field/member. 'attribute' is the pythonic term. -- http://mail.python.org/mailman/listinfo/python-list

Re: Lists in classes

2007-07-12 Thread Jason Drew
Thanks for clearing up the other incorrect answers! In true Python fashion, I would also remind everyone of the *documentation* - in particular the Python tutorial. These are very elementary mistakes to be making - even worse as part of attempted answers. The Python tutorial is at http://docs.pyth

Re: Lists in classes

2007-07-12 Thread Jeremy Lynch
Thanks for all the replies, very impressive. Got it now. Jeremy. On Jul 12, 4:23 pm, Jeremy Lynch <[EMAIL PROTECTED]> wrote: > Hello, > > Learning python from a c++ background. Very confused about this: > > > class jeremy: > list=[] > def additem(self): >

Re: Lists in classes

2007-07-12 Thread Wildemar Wildenburger
Bart Ogryczak wrote: > On 12 jul, 17:23, Jeremy Lynch <[EMAIL PROTECTED]> wrote: > >> Hello, >> >> Learning python from a c++ background. Very confused about this: >> >> >> class jeremy: >> list=[] >> > > You've defined list (very bad choice of a name, BTW), as a class

Re: Lists in classes

2007-07-12 Thread Jennifer Thacher
Jeremy Lynch wrote: > Hello, > > Learning python from a c++ background. Very confused about this: > > > class jeremy: > list=[] > def additem(self): > self.list.append("hi") > return > > temp = jeremy() > temp.additem() > temp.additem(

Re: Lists in classes

2007-07-12 Thread Alex Popescu
On Jul 12, 6:23 pm, Jeremy Lynch <[EMAIL PROTECTED]> wrote: > Hello, > > Learning python from a c++ background. Very confused about this: > > > class jeremy: > list=[] > def additem(self): > self.list.append("hi") > return > > te

Re: Lists in classes

2007-07-12 Thread Bart Ogryczak
On 12 jul, 17:23, Jeremy Lynch <[EMAIL PROTECTED]> wrote: > Hello, > > Learning python from a c++ background. Very confused about this: > > > class jeremy: > list=[] You've defined list (very bad choice of a name, BTW), as a class variable. To declare is as instance variable

Re: Lists in classes

2007-07-12 Thread kyosohma
On Jul 12, 10:23 am, Jeremy Lynch <[EMAIL PROTECTED]> wrote: > Hello, > > Learning python from a c++ background. Very confused about this: > > > class jeremy: > list=[] > def additem(self): > self.list.append("hi") > return > > t

Re: Lists in classes

2007-07-12 Thread Bart Ogryczak
On 12 jul, 17:23, Jeremy Lynch <[EMAIL PROTECTED]> wrote: > Hello, > > Learning python from a c++ background. Very confused about this: > > > class jeremy: > list=[] > def additem(self): > self.list.append("hi") > return > > temp

Lists in classes

2007-07-12 Thread Jeremy Lynch
Hello, Learning python from a c++ background. Very confused about this: class jeremy: list=[] def additem(self): self.list.append("hi") return temp = jeremy() temp.additem() temp.additem() print temp.list temp2 = jeremy() prin