.. cfunction:: PyObject* PyList_GetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high)
- Return a list of the objects in *list* containing the objects *between*
- *low* and *high*. Return *NULL* and set an exception if unsuccessful.
- Analogous to ``list[low:high]``.
+ Return a list of the objects in *list* containing the objects *between* *low*
+ and *high*. Return *NULL* and set an exception if unsuccessful. Analogous
+ to ``list[low:high]``. Negative indices, as when slicing from Python, are not
+ supported.
.. cfunction:: int PyList_SetSlice(PyObject *list, Py_ssize_t low, Py_ssize_t high, PyObject *itemlist)
Set the slice of *list* between *low* and *high* to the contents of
*itemlist*. Analogous to ``list[low:high] = itemlist``. The *itemlist* may
be *NULL*, indicating the assignment of an empty list (slice deletion).
- Return ``0`` on success, ``-1`` on failure.
+ Return ``0`` on success, ``-1`` on failure. Negative indices, as when
+ slicing from Python, are not supported.
.. cfunction:: int PyList_Sort(PyObject *list)
Module :mod:`os`
If the locking flags :const:`O_SHLOCK` and :const:`O_EXLOCK` are present
- in the :mod:`os` module, the :func:`os.open` function provides a more
- platform-independent alternative to the :func:`lockf` and :func:`flock`
- functions.
+ in the :mod:`os` module (on BSD only), the :func:`os.open` function
+ provides an alternative to the :func:`lockf` and :func:`flock` functions.
.. function:: java_ver(release='', vendor='', vminfo=('','',''), osinfo=('','',''))
- Version interface for JPython.
+ Version interface for Jython.
Returns a tuple ``(release, vendor, vminfo, osinfo)`` with *vminfo* being a
tuple ``(vm_name, vm_release, vm_vendor)`` and *osinfo* being a tuple
`Tkinter reference: a GUI for Python <http://infohost.nmt.edu/tcc/help/pubs/lang.html>`_
On-line reference material.
- `Tkinter for JPython <http://jtkinter.sourceforge.net>`_
- The Jython interface to Tkinter.
-
`Python and Tkinter Programming <http://www.amazon.com/exec/obidos/ASIN/1884777813>`_
The book by John Grayson (ISBN 1-884777-81-3).
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.
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.
def verify_instance_interface(self, ins):
for attr in ("args", "__str__", "__repr__"):
- self.failUnless(hasattr(ins, attr),
+ self.assertTrue(hasattr(ins, attr),
"%s missing %s attribute" %
(ins.__class__.__name__, attr))
def interface_test_driver(self, results):
for test_name, (given, expected) in zip(self.interface_tests, results):
- self.failUnlessEqual(given, expected, "%s: %s != %s" % (test_name,
+ self.assertEqual(given, expected, "%s: %s != %s" % (test_name,
given, expected))
def test_interface_single_arg(self):
Permissions History
-------------------
+- Ezio Melotti was given SVN access on June 7 2009 by GFB, for work on and
+ fixes to the documentation.
+
- Paul Kippes was given commit privileges at PyCon 2009 by BAC to work on 3to2.
- Ron DuPlain was given commit privileges at PyCon 2009 by BAC to work on 3to2.
/* This code should go into some future Unicode collation support
module. The basic comparison should compare ordinals on a naive
- basis (this is what Java does and thus JPython too). */
+ basis (this is what Java does and thus Jython too). */
/* speedy UTF-16 code point order comparison */
/* gleaned from: */