Skip to content

Instantly share code, notes, and snippets.

Last active Mar 21, 2020
What would you like to do?
class StudentWithStaticProp:
def __init__(self):
self._name = "Default Name"
def _name(self):
return "A new name, never changes"
name = property(_name)
if __name__ == "__main__":
student = StudentWithStaticProp()
print( # An immutable attribute
del # AttributeError: can't delete attribute = "Yu" # AttributeError: can't set attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment