Skip to content

Instantly share code, notes, and snippets.

@eriky
Created June 23, 2020 08:00
Show Gist options
  • Save eriky/6495b034865efc9aca8a290319e4631e to your computer and use it in GitHub Desktop.
Save eriky/6495b034865efc9aca8a290319e4631e to your computer and use it in GitHub Desktop.
@attrs
class Person(object):
name = attrib(default='John')
surname = attrib(default='Doe')
age = attrib(init=False)
p = Person()
print(p)
p = Person('Bill', 'Gates')
p.age = 60
print(p)
# Output:
# Person(name='John', surname='Doe', age=NOTHING)
# Person(name='Bill', surname='Gates', age=60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment