Skip to content

Instantly share code, notes, and snippets.

@vladyio
Last active January 4, 2016 08:33
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 vladyio/ec59ef6c407c25a13c7a to your computer and use it in GitHub Desktop.
Save vladyio/ec59ef6c407c25a13c7a to your computer and use it in GitHub Desktop.
class Hij:
attr = 1
hij_var = Hij()
hij_var.attr = 2
hij_var.__dict__ # => {'attr': 2}
###############################################################################
class Abc:
__slots__ = ["some_attr"]
alpha = Abc()
alpha.some_attr = 1
alpha.some_attr # => 1
alpha.other_attr # => AttributeError: 'Abc' object has no attribute 'other'
alpha.__dict__ # => AttributeError: 'Abc' object has no attribute '__dict__'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment