1

I want to have an uniform way of using input over python <3 and >=3. Is there any cleaner way to do it apart of of version detection:

if sys.version_info[0] < 3:
    raw_input("Press Enter to continue...");
else:
    input("Press Enter to continue...");
2
  • 2
    Slightly cleaner using the same idea is to have at the top of the file: if sys.version_info[0] < 3: input = raw_input Commented Feb 9, 2014 at 7:49
  • Yes, sure in production; I wanted clearly to express my doubts :) Commented Feb 14, 2014 at 0:44

1 Answer 1

3

The six or future libraries will more or less take care of this (and many other cross-version concerns) for you.

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

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.