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

The single very powerful line of just the fifteen ASCII characters says it all...

Read the code for more information...

Tested on the platforms and versions inside the code...

This is entirely Public Domain and hopefully it will be of use to many a Python coder...

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

Bazza, G0LCU...

Python, 23 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# noinput.py
#
# A single line only to add after any imports to remove the contentious
# "input()" function from Python 1.4.0 to 2.7.2.
#
# This forces "input()" to become "raw_input()" and overrides the internel
# function for the current Python session. This means that if you really
# want the "input()" function you are forced to use the
# "eval(raw_input('Some Prompt:- '))" equivalent, or, to be cheeky, the
# Python 3.x.x "eval(input('Some Prompt:- '))" equivalent... ;o)
#
# I suspect this is not particularly well known so it is issued as
# Public Domain.
#
# Tested on classic AMIGAs, E-UAE, Debian 6.0.0, PCLinuxOS 2009,
# Windows and WinUAE using Python 1.4.0, 2.0.1, 2.4.2, 2.5.2, 2.6.1
# 2.6.6 and 2.7.2...

input=raw_input

# That is all there is to it! Just fifteen ASCII characters in one line...
# Enjoy finding simple solutions to often very difficult problems... ;o)
# Bazza, G0LCU...

I really don't care how you vote this but its simplicity could be its true power...

Bazza...

1 comment

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

21-08-2012.

Now tested on a MacBook Pro OSX 10.7.3, Python Version 2.7.1...