Advertisement
atm-irbis

Pickle test

Mar 24th, 2013
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. class Example:
  2.     def __init__(self, x, y):
  3.         self.x = x
  4.         self.y = y
  5.     def plus(self, x):
  6.         self.x+=x
  7.     @property
  8.     def x(self):
  9.         return self.x
  10.     @property
  11.     def y(self):
  12.         return self.y
  13.     def minus(self, x):
  14.         self.x -= x
  15.     @property
  16.     def distance(self):
  17.         return ((self.x**2)+(self.y**2)) ** 0.5
  18.  
  19. import pickle
  20. f = open('путь_к_файлу_obj.txt', 'r')
  21. zz = pickle.load(f)
  22. print zz.distance, zz.x
  23. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement