Reputation: 4051
I have tried a lot to run raw_input("")
on the python console but that gives an error. Moreover I watch some videos that might have been made on old python. so input("")
is the only method and why raw_input("")
is discarded in the new version is there any reason ?
Upvotes: 24
Views: 68548
Reputation: 1
The reason for this is that the old input() function tries to convert things you type as if it's python code. It generates lot of security issues, that's mainly why it was discarded for the raw_input instead but renamed input() because, well, you know, we programmers are a little bit lazy and typing input() instead of raw_input takes 4 less characters so...
Upvotes: 0
Reputation: 143017
raw_input()
was renamed to input()
in Python v3.x
The old input()
is gone, but you can emulate it with eval(input())
What's new in Python 3 will mention this (and more):
PEP 3111: raw_input() was renamed to input(). That is, the new input() function reads a line from sys.stdin and returns it with the trailing newline stripped. It raises EOFError if the input is terminated prematurely. To get the old behavior of input(), use eval(input()).
Upvotes: 50
Reputation: 287745
Python 3.x's input
is python 2.x's raw_input
. The function has just been renamed since the old 2.x input
was broken by design and therefore eliminated in 3.x.
Upvotes: 5