def get_as_dict(x):
if isinstance(x, dict):<EOL><INDENT>return x<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>return x._asdict()<EOL><DEDENT>except AttributeError:<EOL><INDENT>return x.__dict__<EOL><DEDENT><DEDENT>
Return an object as a dictionary of its attributes.