Barry Warsaw writes:

 > A style I've adopted for MM3 is that if the object is definitely supposed to
 > be a sequence, emptiness is checked with len().  E.g. for a string, list,
 > tuple, dictionary, you'd use:
 > 
 >     if len(data) == 0:
 > 
 > If the object could be a sequence or None, then bare if would be used, but I
 > generally add a comment to explain things, e.g.:
 > 
 >     # data could be an empty dictionary or None
 >     if not data:

If you document the style in a developer's guide or something like
that, I'd rather not have the comment every time.  "None" would seem
to indicate "Yo!  Initialize me!", and you'd check for that with "if
data is None".  "if not data" would be the case where either there
never was anything to do, or nothing is left to do, so stop doing it.
And if len(data) == 0 is a terminal condition for initialized data.
So I don't think you need the comment.

Or are there other usages you have in mind that I've missed?


_______________________________________________
Mailman-Developers mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-developers
Mailman FAQ: http://wiki.list.org/x/AgA3
Searchable Archives: 
http://www.mail-archive.com/mailman-developers%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-developers/archive%40jab.org

Security Policy: http://wiki.list.org/x/QIA9

Reply via email to