Merged revisions 73190,73213,73257-73258,73260,73275,73294 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73190 | georg.brandl | 2009-06-04 01:23:45 +0200 (Do, 04 Jun 2009) | 2 lines

  Avoid PendingDeprecationWarnings emitted by deprecated unittest methods.
........
  r73213 | georg.brandl | 2009-06-04 12:15:57 +0200 (Do, 04 Jun 2009) | 1 line

  #5967: note that the C slicing APIs do not support negative indices.
........
  r73257 | georg.brandl | 2009-06-06 19:50:05 +0200 (Sa, 06 Jun 2009) | 1 line

  #6211: elaborate a bit on ways to call the function.
........
  r73258 | georg.brandl | 2009-06-06 19:51:31 +0200 (Sa, 06 Jun 2009) | 1 line

  #6204: use a real reference instead of "see later".
........
  r73260 | georg.brandl | 2009-06-06 20:21:58 +0200 (Sa, 06 Jun 2009) | 1 line

  #6224: s/JPython/Jython/, and remove one link to a module nine years old.
........
  r73275 | georg.brandl | 2009-06-07 22:37:52 +0200 (So, 07 Jun 2009) | 1 line

  Add Ezio.
........
  r73294 | georg.brandl | 2009-06-08 15:34:52 +0200 (Mo, 08 Jun 2009) | 1 line

  #6194: O_SHLOCK/O_EXLOCK are not really more platform independent than lockf().
........
This commit is contained in:
Georg Brandl 2009-06-08 13:41:29 +00:00
parent 8d8f197c9c
commit c6c3178942
8 changed files with 28 additions and 19 deletions

View file

@ -317,7 +317,7 @@ This example, as usual, demonstrates some new Python features:
and ``methodname`` is the name of a method that is defined by the object's type.
Different types define different methods. Methods of different types may have
the same name without causing ambiguity. (It is possible to define your own
object types and methods, using *classes*, as discussed later in this tutorial.)
object types and methods, using *classes*, see :ref:`tut-classes`)
The method :meth:`append` shown in the example is defined for list objects; it
adds a new element at the end of the list. In this example it is equivalent to
``result = result + [b]``, but more efficient.
@ -344,15 +344,23 @@ defined to allow. For example::
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
while True:
ok = input(prompt)
if ok in ('y', 'ye', 'yes'): return True
if ok in ('n', 'no', 'nop', 'nope'): return False
if ok in ('y', 'ye', 'yes'):
return True
if ok in ('n', 'no', 'nop', 'nope'):
return False
retries = retries - 1
if retries < 0:
raise IOError('refusenik user')
print(complaint)
This function can be called either like this: ``ask_ok('Do you really want to
quit?')`` or like this: ``ask_ok('OK to overwrite the file?', 2)``.
This function can be called in several ways:
* giving only the mandatory argument:
``ask_ok('Do you really want to quit?')``
* giving one of the optional arguments:
``ask_ok('OK to overwrite the file?', 2)``
* or even giving all arguments:
``ask_ok('OK to overwrite the file?', 2, 'Come on, only yes or no!')``
This example also introduces the :keyword:`in` keyword. This tests whether or
not a sequence contains a certain value.