Thoughts on object representation in a dictionary

Peter Hansen peter at engcorp.com
Fri Dec 9 21:21:18 CET 2005


py wrote:
...
> Well the other thing is that I am allowed to store strings in this
> dictionary...so I can't just store the Engine and Body object and later
> use them.  ....this is just a requirement (which i dont understand
> either)...but its what I have to do.

Homework?

> So my question is there a good way of storing this information in a
> nested dictionary such that if I receive this dictionary I could easily
> pull it apart and create Engine and Body objects with the information?
> Any suggestions at all?  keep in mind I am limited to using a
> dictionary of strings...thats it.

You're describing a task that is named "serialization".  Google for 
"python serialization" and you'll get lots of useful and interesting 
background to help you out.

-Peter




More information about the Python-list mailing list