On 11/07/13 13:18, Sivaram Neelakantan wrote:
>>> How do I get to do
>>>
>>> x1..xn = lines.split()
third choice? Put them in a list.
This seems the easiest but I already foresee hardcoded subscripts all
over the code which I will promptly forget the very next day of what
it stands for.
So you would remember what x1, x7 and x23 were for, but wouldn't
remember x[1], x[7] and x[23]?
The whole premise here was that you wanted Python to create the numeric
suffixes for you. The reason that's a bad idea is exactly as you said:
you don't have a clue what the numbers mean. But if you must use
numbers, list indices are no worse than suffixed names.
Next choice? Put them in a dict. This works just like a list, except
the subscript doesn't have to be continguous ints.
I don't know how you would do this because you still need to
create n unique keys...
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor