Re: [Tutor] multiple assignments when reading a file

2013-07-11 Thread Alan Gauld
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 y

Re: [Tutor] multiple assignments when reading a file

2013-07-11 Thread Dave Angel
On 07/11/2013 08:18 AM, Sivaram Neelakantan wrote: Thanks for the detailed explanation below. I've replied below. On Thu, Jul 11 2013,Dave Angel wrote: third choice? Put them in a list. Whaddya know, they already are. So just assign a name to that list. Referencing them is now by subscri

Re: [Tutor] multiple assignments when reading a file

2013-07-11 Thread Alan Gauld
On 11/07/13 04:24, Sivaram Neelakantan wrote: I'm aware of var1, var2 = lines.split() kind of assignments How do I get to do x1..xn = lines.split() x = lines.split() then you access the fields with x[0], x[1]...x[n] It's the default behaviour. -- Alan G Author of the Learn to Program

Re: [Tutor] multiple assignments when reading a file

2013-07-10 Thread Dave Angel
On 07/10/2013 11:24 PM, Sivaram Neelakantan wrote: I'm aware of var1, var2 = lines.split() kind of assignments How do I get to do x1..xn = lines.split() instead of typing out n var names? Is there some pythonic way to map all the data fields automagically given a starter var? I have data