Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. class Unique:
  2.     def _init__(self):
  3.         self.__class__._counter += 1
  4.         self._id_num = self.__class__._counter # I'm trying to have a counter for each subclass
  5.         self._type_name = self.__class__.__name__
  6.  
  7.     def __str__(self):
  8.         return '{0} #{1}'.format(self._type_name, self._id_num)
  9.  
  10.     def log(self, *data):
  11.         print('[{0}]'.format(self), *data)
  12.  
  13.     @property
  14.     def id_num(self):
  15.         return self._id_num
  16.  
  17. class Job(Unique):
  18.     def __init__(self):
  19.         super().__init__()
  20.  
  21.     def run(self):
  22.         self.log('Started')
  23.  
  24.     def poll(self):
  25.         ''' Returns `None` if the job is still running
  26.            or a (return code, err/info string) pair if it has stopped '''
  27.         return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement