diff options
author | Heiko Noordhof <hkoof@xs4all.nl> | 2014-10-15 15:23:53 +0200 |
---|---|---|
committer | Heiko Noordhof <hkoof@xs4all.nl> | 2014-10-17 09:50:08 +0200 |
commit | 8eac1bac3f163448083b9a77e3a03f79f8f06da0 (patch) | |
tree | 098dbf0e6f51c449f783ba1519cd09230ada8209 | |
parent | ba1c39341504922d4a7af8453d929de71ad86c13 (diff) | |
download | urwid-8eac1bac3f163448083b9a77e3a03f79f8f06da0.tar.gz |
add doctest examples of negative indices
-rwxr-xr-x | urwid/monitored_list.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/urwid/monitored_list.py b/urwid/monitored_list.py index 028e082..e7de5f9 100755 --- a/urwid/monitored_list.py +++ b/urwid/monitored_list.py @@ -265,8 +265,10 @@ class MonitoredFocusList(MonitoredList): def __delitem__(self, y): """ - >>> ml = MonitoredFocusList([0,1,2,3], focus=2) + >>> ml = MonitoredFocusList([0,1,2,3,4], focus=2) >>> del ml[3]; ml + MonitoredFocusList([0, 1, 2, 4], focus=2) + >>> del ml[-1]; ml MonitoredFocusList([0, 1, 2], focus=2) >>> del ml[0]; ml MonitoredFocusList([1, 2], focus=1) @@ -279,6 +281,13 @@ class MonitoredFocusList(MonitoredList): MonitoredFocusList([5, 6, 5, 6, 5], focus=2) >>> del ml[::2]; ml MonitoredFocusList([6, 6], focus=1) + >>> ml = MonitoredFocusList([0,1,2,3,4,6,7], focus=2) + >>> del ml[-2:]; ml + MonitoredFocusList([0, 1, 2, 3, 4], focus=2) + >>> del ml[-4:-2]; ml + MonitoredFocusList([0, 3, 4], focus=1) + >>> del ml[:]; ml + MonitoredFocusList([], focus=None) """ if isinstance(y, slice): focus = self._adjust_focus_on_contents_modified(y) @@ -308,6 +317,14 @@ class MonitoredFocusList(MonitoredList): range(1, 4, 2) <- [12, 13] >>> ml[::2] = [10, 11] range(0, 4, 2) <- [10, 11] + >>> ml[-3:-1] = [21, 22, 23] + range(1, 3, 1) <- [21, 22, 23] + >>> ml + MonitoredFocusList([10, 21, 22, 23, 13], focus=2) + >>> ml[:] = [] + range(0, 5, 1) <- [] + >>> ml + MonitoredFocusList([], focus=None) """ if isinstance(i, slice): focus = self._adjust_focus_on_contents_modified(i, y) |