diff options
author | Raymond Hettinger <python@rcn.com> | 2010-12-08 10:18:21 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2010-12-08 10:18:21 (GMT) |
commit | 2ffa671de77d9b3ca8f43669ae62a1913174b8e0 (patch) | |
tree | 4a8e2af85f5d00d7210495abc7a89782980433d4 | |
parent | f34445f7bd30d3fe1fb9c5a5a87f10225a6372a3 (diff) | |
download | cpython-2ffa671de77d9b3ca8f43669ae62a1913174b8e0.zip cpython-2ffa671de77d9b3ca8f43669ae62a1913174b8e0.tar.gz cpython-2ffa671de77d9b3ca8f43669ae62a1913174b8e0.tar.bz2 |
range() example
-rw-r--r-- | Doc/whatsnew/3.2.rst | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst index f51adc8..38d2feb 100644 --- a/Doc/whatsnew/3.2.rst +++ b/Doc/whatsnew/3.2.rst @@ -508,7 +508,16 @@ Some smaller changes made to the core Python language are: :class:`collections.Sequence` :term:`abstract base class`. As a result, the language will have a more uniform API. In addition, :class:`range` objects now support slicing and negative indices. This makes *range* more - interoperable with lists. + interoperable with lists:: + + >>> range(0, 100, 2).count(10) + 1 + >>> range(0, 100, 2).index(10) + 5 + >>> range(0, 100, 2)[5] + 10 + >>> range(0, 100, 2)[0:5] + range(0, 10, 2) (Contributed by Daniel Stuzback in :issue:`9213` and by Alexander Belopolsky in :issue:`2690`.) |