Checking if elements are empty

Daniel Larsson daniel.j.larsson at gmail.com
Wed Sep 5 10:43:11 EDT 2007


On 9/5/07, Chris Mellon <arkanes at gmail.com> wrote:
>
> On 9/5/07, Steve Holden <steve at holdenweb.com> wrote:
> > Doran, Harold wrote:
>
> > >
> > > Is there a way to check if the first element of y is null?
> > >
> >
> > len(y[0]) == 0
> >
> > would be the obvious way, assuming "null" means "the null string".
> >
>
> Better spelled as
>
> if y[0]:


Even better spelled as

if not y[0]:

;-)

--
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070905/1fa40d93/attachment.html>


More information about the Python-list mailing list