Christopher Barker wrote: > But I see no reason to add a standardized way to check for an empty > container- again “emptiness” may not be obviously defined either. > Numpy arrays, (or Pandas Dataframes) are a good example here — there are > more than one way to think of them as false - but maybe more than one way > to think of them as empty too: > Is a shape () (scalar) array empty ? > Or shape (100, 0) ? > Or shape (0, 100) > Or shape (0,0,0,0) > Or a rank 1 array that’s all zeros? Or all false? > Anyway, the point is that “emptiness” may be situation specific, just like > truthiness is.
Just like length is. It's a basic concept and like __bool__ and __len__ it should be upon the objects to specify what empty means. > So explicitly specifying that you are looking for len(container) == 0 is > more clear than isempty(container) would be, even if it did exist. As written in another post here, `len(container) == 0` is on a lower abstraction level than `isempty(container)`. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/BGFQYXXQL6Z2Y4GXCOX7OB55RAKQMVFE/ Code of Conduct: http://python.org/psf/codeofconduct/