Should I use x.__len__() or len(x)?

Date Tags #python
In the context of providing type hints, someone had a function like this.
def f(x: Sized) -> Whatever: ...

And, since sized objects have a __len__() method it seemed sensible to use x.__len__(). It was a good question about the use of special methods.
My advice is to avoid using …
more ...


Python Interviews

The #Python Interviews book is out. Mike Driscoll interviewed a bunch of Python experts. And me, too. get 30% off the Amazon paperback version of the book using the code 30PYTHON: https://goo.gl/5A3uhq
Here's a flavor of how this went:

Driscoll: So how did you end up becoming …
more ...