Inspired by Haskell this library provides a NonEmpty
class.
NonEmpty
mimics the API for normal Python list
s:
from nonempty import NonEmpty
n = NonEmpty(1)
n.append(2)
n.extend([3])
n.pop()
However, it is not allowed to remove the last element of a non-empty list.