Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9af284

Browse files
committed
No need to define raw_input(), input() does the same.
1 parent ed44a1a commit e9af284

2 files changed

Lines changed: 3 additions & 21 deletions

File tree

Doc/tutorial/controlflow.rst

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ control flow statements known from other languages, with some twists.
1616
Perhaps the most well-known statement type is the :keyword:`if` statement. For
1717
example::
1818

19-
>>> def raw_input(prompt):
20-
... import sys
21-
... sys.stdout.write(prompt)
22-
... sys.stdout.flush()
23-
... return sys.stdin.readline()
24-
...
25-
>>> x = int(raw_input("Please enter an integer: "))
19+
>>> x = int(input("Please enter an integer: "))
2620
>>> if x < 0:
2721
... x = 0
2822
... print 'Negative changed to zero'
@@ -298,15 +292,9 @@ The most useful form is to specify a default value for one or more arguments.
298292
This creates a function that can be called with fewer arguments than it is
299293
defined to allow. For example::
300294

301-
def raw_input(prompt):
302-
import sys
303-
sys.stdout.write(prompt)
304-
sys.stdout.flush()
305-
return sys.stdin.readline()
306-
307295
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
308296
while True:
309-
ok = raw_input(prompt)
297+
ok = input(prompt)
310298
if ok in ('y', 'ye', 'yes'): return True
311299
if ok in ('n', 'no', 'nop', 'nope'): return False
312300
retries = retries - 1

Doc/tutorial/errors.rst

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,9 @@ entered, but allows the user to interrupt the program (using :kbd:`Control-C` or
8585
whatever the operating system supports); note that a user-generated interruption
8686
is signalled by raising the :exc:`KeyboardInterrupt` exception. ::
8787

88-
>>> def raw_input(prompt):
89-
... import sys
90-
... sys.stdout.write(prompt)
91-
... sys.stdout.flush()
92-
... return sys.stdin.readline()
93-
...
9488
>>> while True:
9589
... try:
96-
... x = int(raw_input("Please enter a number: "))
90+
... x = int(input("Please enter a number: "))
9791
... break
9892
... except ValueError:
9993
... print "Oops! That was no valid number. Try again..."

0 commit comments

Comments
 (0)