Object help
John Machin
sjmachin at lexicon.net
Sun Jan 11 20:07:30 EST 2009
On Jan 12, 10:49 am, killsto <kilian... at gmail.com> wrote:
> On Jan 11, 2:20 pm, Steven D'Aprano <st... at REMOVE-THIS-cybersource.com.au> wrote:
> > On Sun, 11 Jan 2009 14:06:22 -0800, killsto wrote:
> > > I have a class called ball. The members are things like position, size,
> > > active. So each ball is an object.
>
> > > How do I make the object without specifically saying ball1 = ball()?
> > > Because I don't know how many balls I want; each time it is different.
>
> > Instead of having named balls, have a list of balls.
Or some other collection or container of objects (e.g. a dict or a
queue), depending on what you are trying to simulate.
> > for b in balls:
> > print b.colour # print the colour of each ball
>
> Thanks. That makes sense. It helps a lot. Although, you spelled color
> wrong :P.
At this time of day you are likely to find yourself communicating with
Australians. Get used to it :-)
Cheers,
John
More information about the Python-list
mailing list