Skip to content

Commit

Permalink
implementing CLAMData.get() (akin to dict.get())
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Nov 15, 2018
1 parent 68ed1a3 commit d97cb40
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clam/common/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,12 @@ def __getitem__(self, parameter_id):
except KeyError:
raise

def get(self, parameter_id, default=None):
try:
return self[parameter_id]
except KeyError:
return default

def __setitem__(self, parameter_id, value):
"""Set the value of the specified global parameter"""
for parametergroup, parameters in self.parameters: #pylint: disable=unused-variable
Expand Down

0 comments on commit d97cb40

Please sign in to comment.