def object_to_items(data_structure):
items = []<EOL>try:<EOL><INDENT>items = list(data_structure.__dict__.items())<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>hierarchy = [data_structure]<EOL>try:<EOL><INDENT>hierarchy += inspect.getmro(data_structure)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>slots = []<EOL>try:<EOL><INDENT>for b in hierarchy:<EOL><INDENT>try:<EOL><INDENT>slots += b.__slots__<EOL><DEDENT>except:  <EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>except:  <EOL><INDENT>pass<EOL><DEDENT>for x in slots:<EOL><INDENT>items.append((x, getattr(data_structure, x)))<EOL><DEDENT>return items<EOL>
Converts a object to a items list respecting also slots.

    Use dict(object_to_items(obj)) to get a dictionary.