Re: [Tutor] New guy question...
First, let me say thanks for all the responses! This definitely looks like a useful mailing list for complete noobs like me. Second, I think my machine is probably set up a little weird. I have Python 2.6.2 installed alongside 3.1.1 so maybe that makes a difference. I'm writing programs in TextMate and running them from there. Which seemed to be working fine until I ran into this input issue. At any rate, I've installed 2.6.2 over again from a fresh download and I think I can move ahead. The example works now as long as I change input to raw_input. This should allow me to get through some more of this tutorial book anyway. Thanks again, all! I appreciate the help. - Warren (war...@wantonhubris.com) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
On Tue, Sep 15, 2009 at 9:07 AM, Warren war...@wantonhubris.com wrote: Second, I think my machine is probably set up a little weird. I have Python 2.6.2 installed alongside 3.1.1 so maybe that makes a difference. That should be fine. I'm writing programs in TextMate and running them from there. Which seemed to be working fine until I ran into this input issue. Does TextMate support input into a running Python program? I'm not sure if it supports standard input. You might have to run the program from Terminal to get this to work. Kent ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
Does TextMate support input into a running Python program? I'm not sure if it supports standard input. You might have to run the program from Terminal to get this to work. Good question, Kent. That might be the root of all of this pain. I'll experiment when I get a chance... - Warren (war...@wantonhubris.com) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
2009/9/15 Warren war...@wantonhubris.com: Does TextMate support input into a running Python program? I'm not sure if it supports standard input. You might have to run the program from Terminal to get this to work. Good question, Kent. That might be the root of all of this pain. I'll experiment when I get a chance... - Warren (war...@wantonhubris.com) ___ Tutor maillist - tu...@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor As I mentioned in my earlier response, the only way I could replicate the error was to pipe the file into python, disconnecting (I'm guessing) the stdin stream from the terminal: $ cat test.py input() $ cat test.py | python3 Traceback (most recent call last): File stdin, line 1, in module EOFError: EOF when reading a line (I also tested the script in the OP, and got identical output to that mentioned). This supports Kent's suggestion in a way, although maybe for a slightly different reason. -- Rich Roadie Rich Lovely There are 10 types of people in the world: those who know binary, those who do not, and those who are off by one. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] New guy question...
Hey all, I'm just getting started with Python and I'm working my way through my first Learn Python book on my Mac. I ran into a weird issue though. Here's the example code I'm using: #!/usr/bin/env python3 print( Type integers, each followed by ENTER; or just ENTER to finish ) total = 0 count = 0 while True: line = input() if line: try: number = int(line) except ValueErr as err: print( BLARGH : , err ) continue total += number count += 1 else: break if count: print( count =, count, total =, total, mean =, total / count ) Now, what happens is that this starts up and immediately dies, giving me this error: Type integers, each followed by ENTER; or just ENTER to finish Traceback (most recent call last): method module in test.py at line 9 line = input() EOFError: EOF when reading a line Why is the input statement not waiting for input like it should be and instead killing the app? My google-fu is failing me on this one. - Warren (war...@wantonhubris.com) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
Hi, I noticed this: #!/usr/bin/env python3 which I think indicates you are using python version 3. I strongly suspect you are reading a text based on one of the version 2 issues of python. You might consider dropping back a version(such as 2.6.) since most learning texts are not updated to work with Version 3. Robert Berman On Mon, 2009-09-14 at 15:30 -0400, Warren wrote: Hey all, I'm just getting started with Python and I'm working my way through my first Learn Python book on my Mac. I ran into a weird issue though. Here's the example code I'm using: #!/usr/bin/env python3 print( Type integers, each followed by ENTER; or just ENTER to finish ) total = 0 count = 0 while True: line = input() if line: try: number = int(line) except ValueErr as err: print( BLARGH : , err ) continue total += number count += 1 else: break if count: print( count =, count, total =, total, mean =, total / count ) Now, what happens is that this starts up and immediately dies, giving me this error: Type integers, each followed by ENTER; or just ENTER to finish Traceback (most recent call last): method module in test.py at line 9 line = input() EOFError: EOF when reading a line Why is the input statement not waiting for input like it should be and instead killing the app? My google-fu is failing me on this one. - Warren (war...@wantonhubris.com) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
Warren wrote: Hey all, I'm just getting started with Python and I'm working my way through my first Learn Python book on my Mac. I ran into a weird issue though. Here's the example code I'm using: #!/usr/bin/env python3 print( Type integers, each followed by ENTER; or just ENTER to finish ) total = 0 count = 0 while True: line = input() if line: try: number = int(line) except ValueErr as err: print( BLARGH : , err ) continue total += number count += 1 else: break if count: print( count =, count, total =, total, mean =, total / count ) Now, what happens is that this starts up and immediately dies, giving me this error: Type integers, each followed by ENTER; or just ENTER to finish Traceback (most recent call last): method module in test.py at line 9 line = input() EOFError: EOF when reading a line Why is the input statement not waiting for input like it should be and instead killing the app? My google-fu is failing me on this one. Sorry - I can't explain that. But consider a simplified program: total = 0 count = 0 line = input() while line: if line.isdigit(): number = int(line) total += number count += 1 else: print( BLARGH : , err ) line = input() if count: print( count =, count, total =, total, mean =, total / count ) -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
Well, I thought that as well but I took it out which makes it run under 2.6.1 and I get similar, but not exactly the same, output: Type integers, each followed by ENTER; or just ENTER to finish EOFError: EOF when reading a line - Warren (war...@wantonhubris.com) On Sep 14, 2009, at 3:57 PM, Robert Berman wrote: Hi, I noticed this: #!/usr/bin/env python3 which I think indicates you are using python version 3. I strongly suspect you are reading a text based on one of the version 2 issues of python. You might consider dropping back a version(such as 2.6.) since most learning texts are not updated to work with Version 3. Robert Berman On Mon, 2009-09-14 at 15:30 -0400, Warren wrote: Hey all, I'm just getting started with Python and I'm working my way through my first Learn Python book on my Mac. I ran into a weird issue though. Here's the example code I'm using: #!/usr/bin/env python3 print( Type integers, each followed by ENTER; or just ENTER to finish ) total = 0 count = 0 while True: line = input() if line: try: number = int(line) except ValueErr as err: print( BLARGH : , err ) continue total += number count += 1 else: break if count: print( count =, count, total =, total, mean =, total / count ) Now, what happens is that this starts up and immediately dies, giving me this error: Type integers, each followed by ENTER; or just ENTER to finish Traceback (most recent call last): method module in test.py at line 9 line = input() EOFError: EOF when reading a line Why is the input statement not waiting for input like it should be and instead killing the app? My google-fu is failing me on this one. - Warren ( war...@wantonhubris.com ) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
On Mon, Sep 14, 2009 at 12:30 PM, Warren war...@wantonhubris.com wrote: Type integers, each followed by ENTER; or just ENTER to finish Traceback (most recent call last): method module in test.py at line 9 line = input() EOFError: EOF when reading a line Why is the input statement not waiting for input like it should be and instead killing the app? My google-fu is failing me on this one. Try changing it to raw_input() instead... From the docs: input([prompt]) Equivalent to eval(raw_input(prompt)). In other words, Python is trying to evaluate your input as a valid Python statement at the moment you enter it. I don't quite see why eval(blank line) == EOF, but apparently it does... When I tried your code, if I pressed Enter it blew up with the same error you reported; if I entered integers instead, it accepted them happily until my first blank line, at which point it again complained of an EOF. (I'm running 2.62 on Windows, by the way.) Changing to raw_input() made things work, so I think it's the implicit eval(). -- www.fsrtechnologies.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
Have you tried running this line by line through the interactive shell? Given, I'm not doing this on a mac, but your input() call doesn't fail for me. I'm using Python 2.6. mark ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
(You're top-posting, which makes the message flow very confusing) Warren wrote: div class=moz-text-flowed style=font-family: -moz-fixed Well, I thought that as well but I took it out which makes it run under 2.6.1 and I get similar, but not exactly the same, output: Type integers, each followed by ENTER; or just ENTER to finish EOFError: EOF when reading a line - Warren (war...@wantonhubris.com) On Sep 14, 2009, at 3:57 PM, Robert Berman wrote: Hi, I noticed this: #!/usr/bin/env python3 which I think indicates you are using python version 3. I strongly suspect you are reading a text based on one of the version 2 issues of python. You might consider dropping back a version(such as 2.6.) since most learning texts are not updated to work with Version 3. Robert Berman On Mon, 2009-09-14 at 15:30 -0400, Warren wrote: Hey all, I'm just getting started with Python and I'm working my way through my first Learn Python book on my Mac. I ran into a weird issue though. Here's the example code I'm using: #!/usr/bin/env python3 print( Type integers, each followed by ENTER; or just ENTER to finish ) total = 0 count = 0 while True: line = input() if line: try: number = int(line) except ValueErr as err: print( BLARGH : , err ) continue total += number count += 1 else: break if count: print( count =, count, total =, total, mean =, total / count ) Now, what happens is that this starts up and immediately dies, giving me this error: Type integers, each followed by ENTER; or just ENTER to finish Traceback (most recent call last): method module in test.py at line 9 line = input() EOFError: EOF when reading a line Why is the input statement not waiting for input like it should be and instead killing the app? My google-fu is failing me on this one. - Warren ( war...@wantonhubris.com ) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor /div Seems to me you're running Python 2.x. The input() function is dangerous. In Python 2.x you should use raw_input(), and your program will behave as you expect. In Python 3, raw_input() has been dropped, and that functionality is called input(). The old input() function evaluates the input, and if there isn't anything to evaluate, it raises an exception, as you see. But to get a uninterpreted string, use raw_input(). DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
2009/9/14 Warren war...@wantonhubris.com: Hey all, I'm just getting started with Python and I'm working my way through my first Learn Python book on my Mac. I ran into a weird issue though. Here's the example code I'm using: #!/usr/bin/env python3 print( Type integers, each followed by ENTER; or just ENTER to finish ) total = 0 count = 0 while True: line = input() if line: try: number = int(line) except ValueErr as err: print( BLARGH : , err ) continue total += number count += 1 else: break if count: print( count =, count, total =, total, mean =, total / count ) Now, what happens is that this starts up and immediately dies, giving me this error: Type integers, each followed by ENTER; or just ENTER to finish Traceback (most recent call last): method module in test.py at line 9 line = input() EOFError: EOF when reading a line Why is the input statement not waiting for input like it should be and instead killing the app? My google-fu is failing me on this one. - Warren (war...@wantonhubris.com) ___ Tutor maillist - tu...@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor I'm just a little irritated at all the Don;t use input()-alikes... #!/usr/bin/env python3 The OP is in python3, so it isn't an issue. I agree with the don't use python 3 emails, but that's another matter. The way I read the OP, the problem appears to be that input() isn't blocking... so none of the other responses have actually replicated the problem described. (I can't even get the eof error by hitting enter on a newline) - I am on a mac, running from terminal. I can only replicate the error one way: $ cat test.py | python3 Traceback (most recent call last): File stdin, line 1, in module EOFError: EOF when reading a line How exactly you running your script? -- Rich Roadie Rich Lovely There are 10 types of people in the world: those who know binary, those who do not, and those who are off by one. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
Warren war...@wantonhubris.com wrote while True: line = input() Beats me, it works OK on my XP box. try: number = int(line) except ValueErr as err: Are you sure this shouldn't be ValueError rather than ValueErr? It won't be causing your current problem but it might cause your next one! :-) Now, what happens is that this starts up and immediately dies, giving me this error: Type integers, each followed by ENTER; or just ENTER to finish Traceback (most recent call last): method module in test.py at line 9 line = input() EOFError: EOF when reading a line Why is the input statement not waiting for input like it should be and instead killing the app? My google-fu is failing me on this one. How are you running the code? Are you typing it into a file and then running the file? If so are you typing python foo.py or double clicking the file in Finder? Are you using an IDE? If so which? Finally which version of Python are you using? v3.0 or 3.1 or something else? Clutching at straws... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/l2p/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New guy question...
Rich Lovely wrote: 2009/9/14 Warren war...@wantonhubris.com: Hey all, I'm just getting started with Python and I'm working my way through my first Learn Python book on my Mac. I ran into a weird issue though. Here's the example code I'm using: #!/usr/bin/env python3 print( Type integers, each followed by ENTER; or just ENTER to finish ) total = 0 count = 0 while True: line = input() if line: try: number = int(line) except ValueErr as err: print( BLARGH : , err ) continue total += number count += 1 else: break if count: print( count =, count, total =, total, mean =, total / count ) Now, what happens is that this starts up and immediately dies, giving me this error: Type integers, each followed by ENTER; or just ENTER to finish Traceback (most recent call last): method module in test.py at line 9 line = input() EOFError: EOF when reading a line Why is the input statement not waiting for input like it should be and instead killing the app? My google-fu is failing me on this one. - Warren (war...@wantonhubris.com) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor I'm just a little irritated at all the Don;t use input()-alikes... #!/usr/bin/env python3 The OP is in python3, so it isn't an issue. I agree with the don't use python 3 emails, but that's another matter. The way I read the OP, the problem appears to be that input() isn't blocking... so none of the other responses have actually replicated the problem described. (I can't even get the eof error by hitting enter on a newline) - I am on a mac, running from terminal. I can only replicate the error one way: $ cat test.py | python3 Traceback (most recent call last): File stdin, line 1, in module EOFError: EOF when reading a line How exactly you running your script? This works with 2.6 #!/usr/bin/python print Type integers, each followed by ENTER; or just ENTER to finish total = 0 count = 0 while True: line = raw_input() if line: try: number = int(line) except ValueErr as err: print( BLARGH : , err ) continue total += number count += 1 else: break if count: print count =, count, total =, total, mean =, total / count david [07:43 PM] opteron ~ $ ./tutor_input.py Type integers, each followed by ENTER; or just ENTER to finish 1 2 3 4 5 6 count = 6 total = 21 mean = 3 -- Powered by Gentoo GNU/Linux http://linuxcrazy.com ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor