In java I can transfer objects between server and client by using Object Output Stream and Object Input Stream. Is there anything equivalent in python?
Related:
In java I can transfer objects between server and client by using Object Output Stream and Object Input Stream. Is there anything equivalent in python?
Related:
The pickle module in Python provides object serialization and deserialization functionality. http://docs.python.org/library/pickle.html
It's not particularly secure, so you should always validate the incoming data, but it should support your needs.
The multiprocessing module has the Pipe() function that handles serializing and passing objects between processes. http://docs.python.org/library/multiprocessing.html#multiprocessing.Pipe
example (pipes work within the same process too)
import multiprocessing
class ObjectToSend:
def __init__(self,data):
self.data = data
obj = ObjectToSend(['some data'])
#create 2 read/write ends to a pipe
a, b = multiprocessing.Pipe()
#serialize and send obj across the pipe using send method
a.send(obj)
#deserialize object at other end of the pipe using recv method
print(b.recv().data)