This can be used to facilitate car
, cdr
:
head, *tail = lst
Too bad this is Python 3 only...
Simplified version of pattern matching that's in Erlang or Scala, yet the most useful one.
and thing
can be anything! Good for implementing magic.
class A(object):
def __getitem__(self, idx):
print idx
A()[1:0, 2:0]
# (slice(1, 0, None), slice(2, 0, None))
A tuple of two slice objects.
- thread-safe double-ended queue for fast inserting and removing from both ends.
maxlen
to implement a list of 'last seen' elements