Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class IdCounter:
- __counter = 0
- def __getattr__(self, attr):
- if attr == 'id':
- IdCounter.__counter += 1
- self.id = IdCounter.__counter
- return self.id
- else:
- raise AttributeError("no attribute '" + attr + "'")
- class Account(IdCounter):
- pass
- class Vehicle(IdCounter):
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement