Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Python built-ins worth learning (2019). Parent comment
It will fail for non-list inputs, which is another reason it can be handy if you want clarify that you’re enforcing a list.
len will work for strings, tuples, dicts, sets, plus all kinds of custom classes that implement the __len__ magic method.
There are no comments on this comment yet.
It will fail for non-list inputs, which is another reason it can be handy if you want clarify that you’re enforcing a list.
len will work for strings, tuples, dicts, sets, plus all kinds of custom classes that implement the __len__ magic method.