Welcome, guest | Sign In | My Account | Store | Cart

The code says it all... ;o)

Put the two lines in any Python code and have universal KB input...

Enjoy finding simple solutions to often very difficult problems...

Bazza, G0LCU...

Python, 2 lines
1
2
import sys
if sys.version[0]=="3": raw_input=input

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:- lkasjlkjlakjdf
>>> print(test)
lkasjlkjlakjdf
>>>

7 comments

Christopher Neugebauer 12 years, 7 months ago  # | flag

Surely this is something that 2to3 fixes anyway?

Barry Walker (author) 12 years, 7 months ago  # | flag

Nope, 2to3 swaps "raw_input" for "input" in the code, so........

(I guess it was you who voted it down.)

"Put the two lines in any Python code and have universal KB input..."

You obviously didn't read the "universal" bit...

These two lines are for any experimental code usage inside ANY version to save the aggro of remembering to use "input" for version 3.x.x whilst not being triggered inside versions 1.4.0 and upwards to 2.7.2...

But, me, as a mere amateur, AND having a lateral thinking head thought that the simplicity of it might be useful...

Obviously not to a professional...

Bazza, G0LCU...

Barry Walker (author) 12 years, 5 months ago  # | flag

To the person who voted this back up again from 0 to 1 sometime in October 2011...

You know who you are... ;o)

Many thanks from me......

Bazza, G0LCU...

Barry Walker (author) 12 years, 3 months ago  # | flag

To the person voting this up another notch from 1 to 2 sometime between 24-11-2011 to 28-11-2011...

You know who you are... ;o)

Many thanks from me......

Bazza, G0LCU...

Barry Walker (author) 10 years, 8 months ago  # | flag

I have no idea when this was voted up yet again to 3 but to whoever it was many thanks from me...

Bazza, G0LCU...

K. Chris 8 years, 10 months ago  # | flag

Hey, cool, thanks. I didn't know there might be a problem, as I still use 2.7. I added your code to my IDE templates.

Barry Walker (author) 8 years, 10 months ago  # | flag

Hi K. Chris...

Thank you for those kind words.

I guess it was you that upvoted it to 4 too...

Many thanks for that...