Null number input
Carl Banks
imbosol at vt.edu
Sun Jan 26 23:46:45 EST 2003
Tyson Tate wrote:
> When I use raw_input, I'm able to not enter anything and just hit
> return, yet with input, I get "unexpected EOF while parsing" if I don't
> enter anything.
Stay away from input, unless your intention is to ask the user to
input Python Code. Sure, it can be nice to let a user enter 1+1 at
the prompt, but it could really suck when a user enters
__import__("os").system("rm -rf /").
Stick to something like this:
line = raw_input()
if line == '\n':
age = None
else:
age = int(line)
--
CARL BANKS
More information about the Python-list
mailing list