Skip to content

Instantly share code, notes, and snippets.

@takluyver
Created January 11, 2018 13:13
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 takluyver/6b9348f69ee88ee5d8439bc8ff816819 to your computer and use it in GitHub Desktop.
Save takluyver/6b9348f69ee88ee5d8439bc8ff816819 to your computer and use it in GitHub Desktop.
class CompleteAttrs(object):
def __getattr__(self, name):
if name == 'foo':
return 1
if name == 'bar':
return 2
raise AttributeError(name)
def __dir__(self):
return ['foo', 'bar'] + object.__dir__(self)
ca = CompleteAttrs()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment