Skip to content

Instantly share code, notes, and snippets.

@fernandojunior
Last active December 30, 2015 09:42
Show Gist options
  • Save fernandojunior/f6ea068a2145a662705b to your computer and use it in GitHub Desktop.
Save fernandojunior/f6ea068a2145a662705b to your computer and use it in GitHub Desktop.
Class name using descriptor in python
class Manager(object):
def __init__(self):
self._inst = None
self._cls = None
def __get__(self, inst, cls=None):
self._inst = inst
self._cls = cls
return self
def all(self):
print(self._cls.__name__)
class Node(object):
objects = Manager()
Node.objects.all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment