Skip to content

Instantly share code, notes, and snippets.

@funkaoshi
Created August 10, 2015 18:28
Show Gist options
  • Save funkaoshi/4675b9b2babaf1ee8d9e to your computer and use it in GitHub Desktop.
Save funkaoshi/4675b9b2babaf1ee8d9e to your computer and use it in GitHub Desktop.
classproperty
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