Created
July 25, 2011 14:22
-
-
Save romuald/1104222 to your computer and use it in GitHub Desktop.
Python 2.5 compatibility hack for property.setter, property.deleter
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
# Python 2.5 compatibility hack for property.setter, property.deleter | |
import __builtin__ | |
if not hasattr(__builtin__.property, "setter"): | |
class property(__builtin__.property): | |
__metaclass__ = type | |
def setter(self, method): | |
return property(self.fget, method, self.fdel) | |
def deleter(self, method): | |
return property(self.fget, self.fset, method) | |
@__builtin__.property | |
def __doc__(self): | |
"""Doc seems not to be set correctly when subclassing""" | |
return self.fget.__doc__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment