I believe "if not A:" is the most pythonic, but depending on what
you're doing a list might not be the right thing to use at all. A
little while ago I got some help from this malining list in dealing
with a situation where lists really were not efficient (finding prime
numbers...for fun). In my case the ultimate conclusion was to run any
over a generator. In my case this worked wonderfully, but there are many
cases where this would not. If you only need to know if the list is
empty, and don't care what's in it, then such an approach might work
for you.

On Wed, 25 Mar 2009 20:08:53 +0530 (IST)
srinivasan srinivas <sri_anna...@yahoo.co.in> wrote:

> 
> For ex: to check list 'A' is empty or not..
> if A == []:
> if A.count == 0:
> if len(A) == 0:
> if not A:
> 
> Thanks,
> Srini
> 
> 
>       Add more friends to your messenger and enjoy! Go to
> http://messenger.yahoo.com/invite/ --
> http://mail.python.org/mailman/listinfo/python-list


-- 

Josh Dukes
MicroVu IT Department
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to