Open ariebovenberg opened 3 years ago
Good idea! But, we are blocked right now because of #392 I don't know which methods it will require.
Interesting!
Note though that once you abuse one of the container interfaces (iter, getitem, contains, etc.), the others are pretty much off the table as well (otherwise you get a really wonky API)
I'm eager to see what the outcome is π
related: #874, #592
Python has a rich set of container interfaces, like
__iter__
,__len__
,__contains__
, and others.could we treat
Maybe
as a collection (i.e. one containing 0 or 1 items)? It may seem weird, but it has precedent. In Rust,Option
implements iteration and other collection-like traits as well....but why?
returns
compatible with the Python builtin containers. You get expected behavior (empty containers are falsey), and it fits in the universe of iterables anditertools
.I'm sure you have some opinion on this, but couldn't find it in the issues so far... π