Skip to content

Commit

Permalink
add __repr__ to SettingsDict (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjamesjoyce committed Aug 8, 2018
1 parent 544c662 commit 8ca42ef
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lcopt/settings.py
Expand Up @@ -7,6 +7,15 @@ def __init__(self, contents):
for k, v in contents.items():
setattr(self, k, v)

def __repr__(self):

string = "Lcopt settings section with the following entries:\n\n"

for k, v in self.as_dict().items():
string += "{}: {}\n".format(k,v)

return string

def __getattr__(self, name, value=None):
"""edit __getattr__ to allow dot notation writing of attributes to a SettingsDict object"""
try:
Expand Down

0 comments on commit 8ca42ef

Please sign in to comment.