]> granicus.if.org Git - python/commitdiff
No need to define raw_input(), input() does the same.
authorGeorg Brandl <georg@python.org>
Fri, 17 Aug 2007 05:54:09 +0000 (05:54 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 17 Aug 2007 05:54:09 +0000 (05:54 +0000)
Doc/tutorial/controlflow.rst
Doc/tutorial/errors.rst

index f6f41b33b7aabf290cf1ec95f3e785eb8d20a04d..caea301be26842fe541e95db7a494e20474633a0 100644 (file)
@@ -16,13 +16,7 @@ control flow statements known from other languages, with some twists.
 Perhaps the most well-known statement type is the :keyword:`if` statement.  For
 example::
 
-   >>> def raw_input(prompt):
-   ...     import sys
-   ...     sys.stdout.write(prompt)
-   ...     sys.stdout.flush()
-   ...     return sys.stdin.readline()
-   ... 
-   >>> x = int(raw_input("Please enter an integer: "))
+   >>> x = int(input("Please enter an integer: "))
    >>> if x < 0:
    ...      x = 0
    ...      print 'Negative changed to zero'
@@ -298,15 +292,9 @@ The most useful form is to specify a default value for one or more arguments.
 This creates a function that can be called with fewer arguments than it is
 defined to allow.  For example::
 
-   def raw_input(prompt):
-       import sys
-       sys.stdout.write(prompt)
-       sys.stdout.flush()
-       return sys.stdin.readline()
-
    def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
        while True:
-           ok = raw_input(prompt)
+           ok = input(prompt)
            if ok in ('y', 'ye', 'yes'): return True
            if ok in ('n', 'no', 'nop', 'nope'): return False
            retries = retries - 1
index 99af9c7635d1c786af491e2731f528a511ce81f8..2f2719ad368ca6a357b7c8f04d73a383cc346aa7 100644 (file)
@@ -85,15 +85,9 @@ entered, but allows the user to interrupt the program (using :kbd:`Control-C` or
 whatever the operating system supports); note that a user-generated interruption
 is signalled by raising the :exc:`KeyboardInterrupt` exception. ::
 
-   >>> def raw_input(prompt):
-   ...     import sys
-   ...     sys.stdout.write(prompt)
-   ...     sys.stdout.flush()
-   ...     return sys.stdin.readline()
-   ... 
    >>> while True:
    ...     try:
-   ...         x = int(raw_input("Please enter a number: "))
+   ...         x = int(input("Please enter a number: "))
    ...         break
    ...     except ValueError:
    ...         print "Oops!  That was no valid number.  Try again..."