Last active
December 30, 2015 09:42
-
-
Save fernandojunior/f6ea068a2145a662705b to your computer and use it in GitHub Desktop.
Class name using descriptor in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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