Showing posts with label object. Show all posts
Showing posts with label object. Show all posts

Saturday, January 21, 2012

Python Note 7 (the pickle module)

In python we can use serialization functionality using pickle module. it can save live instances of objects to files and retrieve object instances from pickled files.
Code:
import pickle

class Transaction : 
 def __init__(self,userName,trnsID,payment):
  self.userName=userName
  self.trnsID=trnsID
  self.payment=payment
 
 def __del__(self):
  print("Destructed!")
 
 def getPaymentValue(self):
  return self.payment
 
 def getUserName(self) :
  return self.userName
#end of the class
© kani.stack.notez 2012 | Blogger Template by Enny Law - Ngetik Dot Com - Nulis