Skip to content

Instantly share code, notes, and snippets.

@mushfiq
Last active October 13, 2015 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mushfiq/4231509 to your computer and use it in GitHub Desktop.
Save mushfiq/4231509 to your computer and use it in GitHub Desktop.
Python Class Properties using decorators
class Book(object):
@property
def title(self):
return self._title
@title.setter
def title(self, value):
if value is None or "" == value.strip():
raise ValueError("Title should have proper value!")
self._title = value
return self._title
if __name__=='__main__':
b = Book()
b.title = "Intro Of Python"
print b.title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment