"Carlos" <[EMAIL PROTECTED]> wrote
> I am wondering if it is possible to create lists on the fly.

In general you can use a list comprehension to do that.

> This is only so you can have an idea:
>
> for i in range(5):
>    'list_%i' % (i) = []

>>> mylists = [ [] for n in range(5)]

creats a list of 5 empty lists. You can then poulate the sublists
using normal indexing:

>>> mylists[0].append(5)
>>> print mylists[0][0]
5

You can find more on List Comprehensions in the Functional Programming
topic of my web tutor.

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to