Re: [Tutor] renaming input works intermittently

2013-07-11 Thread Steven D'Aprano
On 12/07/13 11:07, eryksun wrote: On Thu, Jul 11, 2013 at 9:01 PM, Steven D'Aprano wrote: try: if int(sys.version[0]) < 3: input = raw_input numbers_str = original = input('Enter a positive' 'integer, space separated if desired.') # error

Re: [Tutor] renaming input works intermittently

2013-07-11 Thread Steven D'Aprano
On 12/07/13 10:44, Jim Mooney wrote: When I tried a simple rename of input, it worked - in python 2.7 and python 3.3 import sys if int(sys.version[0]) < 3: input = raw_input x = input('type something ') print(x) # this works in both Py versions But when I tried that in my numbers program

Re: [Tutor] importing into a function

2013-07-11 Thread Alan Gauld
On 11/07/13 19:47, Jim Mooney wrote: in the DOS box, but there's not much sense in using an IDE at all if it doesn't have everything to make life easy, very sensibly arranged, when you Do need something like a debugger or some snippets (an essential since I have a truly rotten memory ;') You c

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