Sending Dictionary via Network

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Tue Oct 24 19:21:50 EDT 2006


mumebuhi a écrit :
> Hi,
> 
> Is it possible to send a non-string object from a Python program to
> another? I particularly need to send a dictionary over to the other
> program. However, this is not possible using the socket object's send()
> function.
> 
> Help?


>>> d = dict(one=1, two="three", question="life, universe, and everything")
 >>> import simplejson
 >>> s = simplejson.dumps(d)
 >>> s
'{"question": "life, universe, and everything", "two": "three", "one": 1}'
 >>> simplejson.loads(s) == d
True

http://cheeseshop.python.org/pypi/simplejson

If you *really* want to "share" objects between programs, there are way 
to do so (pyro comes to mind). But this gets more complicated...



More information about the Python-list mailing list