12 Mar
2020
12 Mar
'20
5:27 p.m.
On Thu, 12 Mar 2020 at 17:09, Christopher Barker <pythonchb@gmail.com> wrote:
I was so used to have False for an empty iterable I hate to be pedantic, but it doesn't work for iterables anyway:
Yes, I know that it does not work for iterators. This is another problem :-)
but If I really want to know if a sequence is empty, maybe if len(sequence) == 0: is really a more clear test.
But it's against PEP 8.
And by the way, numpy arrays are not Sequences as far as collections.abc is concerned
But it quacks like a sequence. IMHO numpy arrays should result as they implements collections.abc.Sequence, even if it's really not true. Like dict:
help(dict) Help on class dict in module builtins:
class dict(object) [...]
issubclass(dict, MutableMapping) True