Skip to content

Instantly share code, notes, and snippets.

@Tinche
Created August 19, 2016 09:14
Show Gist options
  • Save Tinche/a50f38192325c6103673c6dbecb4c39f to your computer and use it in GitHub Desktop.
Save Tinche/a50f38192325c6103673c6dbecb4c39f to your computer and use it in GitHub Desktop.
_setattr_cached = object.__setattr__
class A:
__slots__ = ('x', 'y', 'z', 'a', 'b', 'c')
def __init__(self, x, y, z, a, b, c):
_setattr = _setattr_cached.__get__(self, A)
_setattr('x', x)
_setattr('y', y)
_setattr('z', z)
_setattr('a', a)
_setattr('b', b)
_setattr('c', c)
def __setattr__(self, name, value):
raise AttributeError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment