Input problem

Scott David Daniels Scott.Daniels at Acm.Org
Tue Jun 16 12:49:40 EDT 2009

Prasoon wrote:
> What is the difference between
> z=int(raw_input()) and z=eval(raw_input())????(I thought them to be
> the same in case of integers)

Note that you can (and probably should) provide a prompt as an arg to
input and raw_input.

> I mean when an integer is entered in that case are they same and when
> an integer in not entered,in that case how are they different?????
In response to an input() call in Python 2.x, you can type


Generally it gives your user enough rope to shoot himself in the foot.

And here is the code running under 3.0 and 3.1rc2 (release candidate #2)
     a, b = (int(t) for t in input('Numbers: ').split())

--Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Python-list mailing list