Input problem

Bearophile bearophileHUGS at lycos.com
Tue Jun 16 06:16:15 EDT 2009


Prasoon:
> I am new to python....and using python 2.6
> I want to know when to use raw_input( ) and when to use input( )???

I think it's better to always use raw_input(), and then convert the
string to the data to work on.

Once in a while you may want to use input() to input expressions (like
formulas) in your program in a quick, simple and unsafe way...

In Python3+ they have removed input() and they have renamed raw_input
() as input(). You can have the functionality of 2.x input() with eval
(input()). (I think Python3 developers have taken the right choices
here).

Bye,
bearophile



More information about the Python-list mailing list