changeset 225:f48d3e419bcc

created
author 127.0.0.1
date Sun, 30 Jun 2013 10:05:40 +0200
parents b1445e602b59
children 8705b86b6a27
files ___%2Aitem__
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/___%2Aitem__	Sun Jun 30 10:01:43 2013 +0200
+++ b/___%2Aitem__	Sun Jun 30 10:05:40 2013 +0200
@@ -9,8 +9,16 @@
 thing.__delitem__(key)
 
 thing[start:end:step]
-def get_slice(thing, start, end, step):
-    if hasattr(thing, '__getslice__'):
-        return thing.__getslice__(start, end, step)
+def get_slice(thing, start=None, end=None, step=None):
+    if step is None and hasattr(thing, '__getslice__'):
+        if start is None:
+            start = 0
+        elif start < 0:
+            start += len(thing)
+        if end is None:
+            end = sys.maxint
+        elif end < 0:
+            end += len(thing)
+        return thing.__getslice__(start, end)
     return thing[slice(start, end, step)]
 }}}
\ No newline at end of file