Checking the boolean value of a collection

Marco Bizzarri marco.bizzarri at gmail.com
Sat Sep 13 04:03:02 EDT 2008


On Fri, Sep 12, 2008 at 6:07 PM, Bruno Desthuilliers
<bruno.42.desthuilliers at websiteburo.invalid> wrote:
> Marco Bizzarri a écrit :
> (snip)
>>
>> I'm afraid this have another problem for me...
>>
>>
>> emmebi at janitor:/var/local/zope28/porting/Products/PAFlow$ python2.3
>> Python 2.3.5 (#2, Oct 18 2006, 23:04:45)
>> [GCC 4.1.2 20061015 (prerelease) (Debian 4.1.1-16.1)] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>
>>>>> def any(iterable): pass
>>
>> ...
>>>>>
>>>>> any(x for x in [1, 2, 3])
>>
>>  File "<stdin>", line 1
>>    any(x for x in [1, 2, 3])
>>            ^
>> SyntaxError: invalid syntax
>>
>>>>> any([x for x in [1, 2, 3]])
>>>>>
>>
>> I mean, I'm afraid I can't use an expression like that without
>> building a list... not at least in python2.3
>
> Err... a list being an iterable, you just need any([1, 2, 3]).

Ehm, yes, of course... I was trying just to show from a command line
what were my results.

>
> But this wont be enough to solve your real use case, indeed.


Yes, that's the point.



-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/



More information about the Python-list mailing list