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

Barry Warsaw barry at list.org
Mon Mar 16 18:18:25 CET 2009

Hash: SHA1

On Mar 14, 2009, at 04:40 PM, Mark Sapiro wrote:

>Barry Warsaw wrote:
>>On Mar 14, 2009, at 6:22 PM, noreply at launchpad.net wrote:
>>> @@ -510,6 +507,12 @@
>>>         try:
>>>             msgfp = open(pckfile)
>>>             msg = cPickle.load(msgfp)
>>> +            if data == {}:
>>This looks a little Pythonically weird; maybe if len(data) == 0 instead?
>Actually, I was concerned about the possibility that data could be
>None, but upon closer inspection, that can't happen, and even if it
>did, it wouldn't matter, so just if data: should be good.

Hi Mark,

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:

What do you think?  MM2 is pretty inconsistent here so I'm not sure whether
it's worth adopting or (in 2.2) converting to this style.

Version: GnuPG v1.4.9 (GNU/Linux)


More information about the Mailman-Developers mailing list