Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # encoding: utf-8
- from __future__ import division, with_statement
- import sys, os
- class StrictPerson(object):
- __slots__ = ["first", "last", "age"]
- def __str__(self):
- return "%s %s (%s)" % (self.first, self.last, self.age)
- def main():
- me = StrictPerson()
- try:
- print me
- except AttributeError:
- "Because I haven't set any of the required attributes, obviously."
- me.first = "Jeremy"
- me.last = "Banks"
- me.age = 19
- print me
- try
- me.likesPotatoes = True
- except AttributeError:
- "Because I haven't made a slot for that attribute!"
- if __name__ == "__main__": sys.exit(main())
Add Comment
Please, Sign In to add comment