Raymond Hettinger wrote:
On Mar 25, 7:38 am, 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:

PEP 8 recommends the latter.


Raymond
I can't seem to find where this recommendation is mentioned or implied.

Personally I would go for the len version for the sole reason that its immediate clear what it is what I am trying to do here. So that when I reread my code a couple of weeks later I don't have to think, eh was A a bool, oh no I was checking if that list had content in it.

But that could be just me though :-)

YMMV
--
mph
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to