Checking if elements are empty
horpner at yahoo.com
Mon Sep 10 19:44:02 CEST 2007
On 2007-09-10, Chris Mellon <arkanes at gmail.com> wrote:
> On 9/10/07, Neil Cerutti <horpner at yahoo.com> wrote:
>> Agreed; but I prefer 'if y == ""', absent more context and
>> better names.
> Probably should use u"" if you're going to take that route, as
> this will fail spuriously if y contains a unicode string
> that can't be implicitly converted to ascii. Personally, I
> prefer the boolean check and I'll let operations fail elsewhere
> if there's a type mismatch.
I have a quibble not with the functionality of the boolean check,
but with its expressiveness. if y == "" expresses more, i.e.,
that I expect y to contain a Python byte string.
More information about the Python-list