Checking if elements are empty

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Sat Sep 8 02:36:44 CEST 2007


In message <46e115e5$0$7691$9b4e6d93 at newsspool2.arcor-online.net>, Wildemar
Wildenburger wrote:

> Lawrence D'Oliveiro wrote:
>
>> In message <mailman.93.1189003016.2658.python-list at python.org>, Chris
>> Mellon 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
>>>>
>>> Better spelled as
>>>
>>> if y[0]:
>> 
>> Not a good idea.
> 
> Why not?

Because there is a situation where your version of the test will fail even
if the first element of y is non-null.



More information about the Python-list mailing list