data.replace('=', ':').replace(';', ',') then eval in a namespace object whose __getitem__ method returns its argument unchanged.
class not_str(str): # take care of that IPF.Contact def __getattr__(self, attr):return self + '.' + attr class not_dict(dict): def __getitem__(self, name):return not_str(name) eval(data.replace('=',':').replace(';', ','), not_dict()) Tom Grove wrote: > I have a server program that I am writing an interface to and it returns > data in a perl dictionary. Is there a nice way to convert this to > something useful in Python? > > Here is some sample data: > > 200 data follow > { > Calendar = { > Access = { anyone = lr;}; > Class = IPF.Appointment; > Messages = 0; > Size = 0; > UIDNext = 1; > UIDValidity = 287898056; > Unseen = 0; > }; > Contacts = { > Class = IPF.Contact; > Messages = 0; > Size = 0; > UIDNext = 1; > UIDValidity = 287898056; > Unseen = 0; > }; > } > > -Tom -- http://mail.python.org/mailman/listinfo/python-list