Commit 01f28f67 authored by Vincent Pelletier's avatar Vincent Pelletier

Use adequate iteration methods.

Also, reduce the scope of one more try..except block.
parent 023c0a9f
...@@ -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