"raw_input" For ALL Versions Of Python...

Code junkies hangout here

Moderators: ChriThor, LXF moderators

"raw_input" For ALL Versions Of Python...

Postby Bazza » Wed Aug 10, 2011 7:23 pm

Hi all...

A simple quicky...

Add these two lines to ANY python code from Python 1.4.0 to 3.2.x, and
have universal KB entry for ALL versions...

(C)2011, B.Walker, G0LCU...

Issued under the MIT licence.


import sys
if sys.version[0]=="3": raw_input=input


Test procedure below for Python 3.x.x...

Code: Select all
Python 3.1.3 (r313:86834, Nov 28 2010, 10:01:07)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> if sys.version[0]=="3":
...     raw_input=input
>>> test=raw_input("Some Prompt:- ")
Some Prompt:- qwertyuiop
>>> print(test)

Bazza, G0LCU...

Team AMIGA...

The less that I speak, the smarter I sound.
User avatar
LXF regular
Posts: 1596
Joined: Sat Mar 21, 2009 11:16 am
Location: Loughborough

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest