On 18 June 2013 19:41, Steven D'Aprano <st...@pearwood.info> wrote: > As an alternative, if you give up the requirement that the string be > human-readable, you can *serialise* the object. Not all objects can be > serialised, but most can. You can use: > > - marshal > - pickle
I had a feeling it would be nearly impossible unless it involved unpickling instead of unstringing ;') I solved the problem another way. I type dicts on the fly to use as a learning tool, but find it annoying, so I wrote a small snippet/module combo to split a single string of space-separated tokens, then print them as a dictionary, so I could just copy that into my program, and not type all those nasty quotes and colons (I'm the ultimate lazy typist). Only splitting makes all strings, so I wanted the original types back. But then I found the alternate way of defining a dict: D = dict(name='bob', age=50) That doesn't bother me so much - fewer quotes and no colons - so I threw my module to the winds. Still, I'm learning a lot of Python trying to use Python to find lazy ways to do things ;') -- Jim Scorn that fancy food - put bread in your head! _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor