Skip to content

Commit

Permalink
cleanup/quieter print_vals method
Browse files Browse the repository at this point in the history
  • Loading branch information
chosak committed Nov 7, 2016
1 parent 7c546ad commit 1b22428
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions paying_for_college/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,15 +745,19 @@ def print_vals(obj, val_list=False, val_dict=False, noprint=False):
keylist = sorted([key for key in obj._meta.get_all_field_names()],
key=lambda s: s.lower())
if val_list:
newlist = []
values = []
for key in keylist:
try:
print "%s: %s" % (key, obj.__getattribute__(key))
except:
pass
else:
newlist.append(key)
return [obj.__getattribute__(key) for key in newlist]
value = obj.__getattribute__(key)
except AttributeError:
continue

values.append(value)

if not noprint:
print "%s: %s" % (key, value)

return values
elif val_dict:
return obj.__dict__
else:
Expand Down

0 comments on commit 1b22428

Please sign in to comment.