Rev 3004: HACKING: say not to use hasattr() in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Nov 16 06:25:47 GMT 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3004
revision-id: pqm at pqm.ubuntu.com-20071116062543-dl3xkea5ri27qwnz
parent: pqm at pqm.ubuntu.com-20071116053612-g6b07lkde35uvbe8
parent: mbp at sourcefrog.net-20071115041334-wfkrz0y0lzdtpkfj
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2007-11-16 06:25:43 +0000
message:
  HACKING: say not to use hasattr()
modified:
  doc/developers/HACKING.txt     HACKING-20050805200004-2a5dc975d870f78c
    ------------------------------------------------------------
    revno: 2974.1.1
    merged: mbp at sourcefrog.net-20071115041334-wfkrz0y0lzdtpkfj
    parent: pqm at pqm.ubuntu.com-20071106124804-ehlreba0lfp3kab9
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: doc
    timestamp: Wed 2007-11-14 20:13:34 -0800
    message:
      HACKING: say not to use hasattr()
=== modified file 'doc/developers/HACKING.txt'
--- a/doc/developers/HACKING.txt	2007-10-24 07:36:52 +0000
+++ b/doc/developers/HACKING.txt	2007-11-15 04:13:34 +0000
@@ -662,6 +662,15 @@
 Coding Style Guidelines
 =======================
 
+General Python rules
+--------------------
+
+``hasattr`` should not be used because it swallows exceptions including
+``KeyboardInterrupt``.  Instead, say something like ::
+
+  if getattr(thing, 'name', None) is None
+
+
 Code layout
 -----------
 




More information about the bazaar-commits mailing list