Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Thrift Wiki" for change 
notification.

The following page has been changed by EsteveFernandez:
http://wiki.apache.org/thrift/ThriftUsagePython

New page:
'''Assuming you're using the definitions in "tutorial.thrift":'''

== Importing the Classes ==

{{{
import tutorial.Calculator
from tutorial.ttypes import *
from thrift.protocol import TBinaryProtocol
from thrift.transport import TTransport
}}}

== Creating Objects, Using Constants ==

{{{
work = Work()
work.num1 = 7
work.num2 = 9
work.op = Operation.ADD
}}}

== Serializing to/from a string ==

{{{
transportOut = TTransport.TMemoryBuffer()
protocolOut = TBinaryProtocol.TBinaryProtocol(transportOut)
work.write(protocolOut)
bytes = transportOut.getvalue()

transportIn = TTransport.TMemoryBuffer(bytes)
protocolIn = TBinaryProtocol.TBinaryProtocol(transportIn)
moreWork = Work()
moreWork.read(protocolIn)
}}}

Reply via email to