On Mon, Jan 12, 2009 at 9:06 AM, killsto <kilian...@gmail.com> wrote:

>
> I would think something like:
>
> def newball():
>     x = last_named_ball + 1
>    ball_x = ball(size, etc) # this initializes a new ball
>    return ball_x
>
> But then that would just name a ball ball_x, not ball_1 or ball_2.
>
> Is it possible?
>
>
How about placing the balls in a python list:balls = [Ball() for i in
range(number_of_balls)]
where number_of_balls is the number of balls you want to create.

additional balls can be added to the list:
balls.append(Ball())

now you can access the balls like so:
>>> balls[0]
< __main__.Ball instance at ...>
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to