-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Mar 14, 2009, at 04:40 PM, Mark Sapiro wrote:
>Barry Warsaw wrote: >> >>On Mar 14, 2009, at 6:22 PM, [email protected] 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. Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkm+ieEACgkQ2YZpQepbvXG5kgCgssRqZ73I6YuWWJOCd6RRjK+v g4UAnR/qLSW52K9vVrqkWEVSw4Sp9yXd =1o90 -----END PGP SIGNATURE----- _______________________________________________ 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
