Commit ba9b05f2 authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Romain Courteaud

Use adequate iteration methods.

Also, reduce the scope of one more try..except block.
parent 3650d673
...@@ -141,20 +141,19 @@ def _getDict(instance): ...@@ -141,20 +141,19 @@ def _getDict(instance):
elif isinstance(instance, dict): elif isinstance(instance, dict):
result = {} result = {}
for key in instance.keys(): for key in instance:
result[key] = _getDict(instance[key]) result[key] = _getDict(instance[key])
return result return result
else: else:
try: try:
dikt = instance.__dict__
result = {}
for key in instance.__dict__.keys():
result[key] = _getDict(instance.__dict__[key])
return result
except AttributeError: except AttributeError:
return instance return instance
result = {}
for key, value in dikt.iteritems():
result[key] = _getDict(value)
return result
class Computer: class Computer:
"Object representing the computer" "Object representing the computer"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment