News for hackers. Stuff that matters.
Re:Python built-ins worth learning (2019) by saila on Wednesday March 30, 2022 @12:43AM (#30851555)
Perhaps true but misses the point. If you’re using len() for type checking, it’s essentially no different than doing isinstance(items, Sized). The latter explicitly calls out what you’re doing and makes it clear, to me, that’s it’s not really correct, in that it doesn’t show your intent, which is to enforce a sequence of items in a container not that the object has a size.

There are no comments on this comment yet.