[Mailman-Developers] [Branch~mailman-coders/mailman/2.2] Rev 1046: - Changed someold messages for more current meaning.

Stephen J. Turnbull stephen at xemacs.org
Mon Mar 16 19:03:25 CET 2009


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?




More information about the Mailman-Developers mailing list