Created
August 10, 2015 18:28
-
-
Save funkaoshi/4675b9b2babaf1ee8d9e to your computer and use it in GitHub Desktop.
classproperty
This file contains 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 classproperty(property): | |
""" | |
Marries @property and @classmethod | |
Why doesn't python have this? Grr.. | |
""" | |
def __new__(cls, fget, *args): | |
return super(classproperty, cls).__new__(cls, classmethod(fget), *args) | |
def __get__(self, obj, type=None): | |
return self.fget(type) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment