Checking if elements are empty

Piet van Oostrum piet at cs.uu.nl
Tue Sep 11 04:22:58 EDT 2007


>>>>> "Chris Mellon" <arkanes at gmail.com> (CM) wrote:

>CM> On 9/10/07, Neil Cerutti <horpner at yahoo.com> wrote:

>>> Agreed; but I prefer 'if y[0] == ""', absent more context and
>>> better names.

>CM> Probably should use u"" if you're going to take that route, as this
>CM> will fail spuriously if y[0] contains a unicode string that can't be
>CM> implicitly converted to ascii. Personally, I prefer the boolean check
>CM> and I'll let operations fail elsewhere if there's a type mismatch.

>>> x=u"€"
>>> x == ""
False
>>> 

-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list