[Python-3000-checkins] r57132 - python/branches/py3k/Doc/tutorial/controlflow.rst python/branches/py3k/Doc/tutorial/errors.rst

georg.brandl python-3000-checkins at python.org
Fri Aug 17 07:54:45 CEST 2007


Author: georg.brandl
Date: Fri Aug 17 07:54:09 2007
New Revision: 57132

Modified:
   python/branches/py3k/Doc/tutorial/controlflow.rst
   python/branches/py3k/Doc/tutorial/errors.rst
Log:
No need to define raw_input(), input() does the same.


Modified: python/branches/py3k/Doc/tutorial/controlflow.rst
==============================================================================
--- python/branches/py3k/Doc/tutorial/controlflow.rst	(original)
+++ python/branches/py3k/Doc/tutorial/controlflow.rst	Fri Aug 17 07:54:09 2007
@@ -16,13 +16,7 @@
 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 @@
 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

Modified: python/branches/py3k/Doc/tutorial/errors.rst
==============================================================================
--- python/branches/py3k/Doc/tutorial/errors.rst	(original)
+++ python/branches/py3k/Doc/tutorial/errors.rst	Fri Aug 17 07:54:09 2007
@@ -85,15 +85,9 @@
 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..."


More information about the Python-3000-checkins mailing list