Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

"raw_input" For ALL Versions Of Python...

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
Bazza
LXF regular


Joined: Sat Mar 21, 2009 11:16 am
Posts: 1462
Location: Loughborough

PostPosted: Wed Aug 10, 2011 8:23 pm    Post subject: "raw_input" For ALL Versions Of Python... Reply with quote

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.

<CODE>

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

</CODE>

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


Code:

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)
qwertyuiop
>>>

_________________
73...

Bazza, G0LCU...

Team AMIGA...
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast