From 6fb10829e0381fc1c78e1e915399e9d4c2d863fa Mon Sep 17 00:00:00 2001 From: wirawan Date: Mon, 12 Sep 2011 21:58:43 +0000 Subject: [PATCH] * Added Parameters._get_() method. --- params/params_flat.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/params/params_flat.py b/params/params_flat.py index 4f36fe7..d0cb62f 100644 --- a/params/params_flat.py +++ b/params/params_flat.py @@ -1,4 +1,4 @@ -# $Id: params_flat.py,v 1.4 2011-09-09 18:58:48 wirawan Exp $ +# $Id: params_flat.py,v 1.5 2011-09-12 21:58:43 wirawan Exp $ # # wpylib.params.params_flat module # Created: 20100930 @@ -245,6 +245,12 @@ class Parameters(dict): # return self._prm_.__iter__() #def _iteritems_(self): # return self._prm_.iteritems() + def _get_(self, key, default=None): + """Nested version of dict.get for this Parameters object.""" + try: + return self[key] + except KeyError: + return default def _update_(self, srcdict): """Updates the most overriding parameters with key-value pairs from srcdict.