24

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 ?

3 Answers 3

50

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()).

Sign up to request clarification or add additional context in comments.

Comments

5

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.

1 Comment

I wouldn't have said it was "broken by design", but rather that it was "ill-advised". Removing it was a good idea.
0

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...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.