On Thu, Mar 31, 2016 at 9:24 AM, Peter Otten <__pete...@web.de> wrote: > But note: > >>>> def get(seq, index, default=None): > ... return (seq[index:index+1] or [default])[0] > ... >>>> get("abc", -1, "default") > 'default'
The discontinuity between -1 and 0 in indexing is a pain in the rear. Negative indexes are one of those things that may seem like a good idea at first, but I think in the end it causes more trouble than it's worth. There's nothing you can do with L[-x] that you can't do more explicitly with L[len(L) - x]. -- https://mail.python.org/mailman/listinfo/python-list