I keep seeing functions and documentation like this and this (to name a few) which operate on or refer to list-like objects.
I'm quite aware of what exactly an actual list is (dir(list)
), and can deduce what (often varying) methods from a list are necessary in most references to a "list-like object", however the number of times I see it referenced has left me with the following question:
Is there an official or common knowledge standard minimal interface for a "list-like" object? Is it as simple as actualizing__getitem__
, or is it agreed that additional things like __len__
and __setitem__
are required as well?
This may seem like semantics, but I can't help but think that if there does not exist a standard minimal interface requirement, various ideas of "list-likeness" could cause some issues/improper handling. Perhaps this is just a slight downside to Python's duck typing?