Sending Dictionary via Network

mumebuhi mumebuhi at gmail.com
Tue Oct 24 19:22:35 EDT 2006


The simplejson module is really cool and simple to use. This is great!

For others who are just starting to use Python (like myself), simply
download and decompress the source bundle then copy the simplejson
directory to your sys.path (e.g. /usr/lib/python2.4/).

Thanks so much, Bruno.


Buhi


Bruno Desthuilliers wrote:
> 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