changeset 29:3a9710b7a785

Element - Use standard get behaviour emeraldtree/ElementTree.py: Make Element.get throw KeyError.
author Bastian Blank <bblank@thinkmo.de>
date Tue, 08 Jul 2008 14:46:44 +0200
parents 21cef3864c33
children 96e02876b1a2
files emeraldtree/ElementTree.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/emeraldtree/ElementTree.py	Mon Jun 23 14:53:58 2008 +0200
+++ b/emeraldtree/ElementTree.py	Tue Jul 08 14:46:44 2008 +0200
@@ -122,6 +122,8 @@
 
 import ElementPath
 
+_marker = object()
+
 class ParseError(SyntaxError):
     pass
 
@@ -339,10 +341,12 @@
     # @param default What to return if the attribute was not found.
     # @return The attribute value, or the default value, if the
     #     attribute was not found.
-    # @defreturn string or None
 
-    def get(self, key, default=None):
-        return self.attrib.get(key, default)
+    def get(self, key, default=_marker):
+        ret = self.attrib.get(key, default)
+        if ret is default and default is _marker:
+            raise KeyError(key)
+        return ret
 
     ##
     # Sets an element attribute.