...and Seek Questions _input and raw_input


#1



My input went well, but i am curious how "raw_input" works and checked online.
according to this web
it says:

Python 2:

raw_input() takes exactly what the user typed and passes it back as a string.
input() first takes the raw_input() and then performs an eval() on it as well.
The main difference is that input() expects a syntactically correct python statement where raw_input() does not.

Python 3:

raw_input() was renamed to input() so now input() returns the exact string.
Old input() was removed.



what "eval()" does in python 2 ?
and we are excepted to utilize the newest version which is Python 3.0
so it's better just use "input()" instead of "raw_input()" ? am i right?


#2

okay, python2:

raw_input() prompts the user for input, and stores the result as string
input() will prompt the user for input, then run the built in eval() function, which will cause the input to be run as python code.

python3:

raw_input() is removed, and is now input(). If we want the equivalent of python2 input(), we can call eval manually: eval(input())


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.