1. Python Snippets

    Tue 01 January 2013
    By Felipe Reyes

    Property

    def Property(f):
        fget, fset, fdel = f()
        fdoc = f.__doc__
        return property(fget, fset, fdel, fdoc)
    

    Usage Example

    class TtyExample (object):
    
        def __init__ (self):
            self._name = None
    
        @Property
        def name(f):
            "The name"
            def fget (self):
                return self._name
    
            def fset (self, value):
                assert isinstance (value, basestring)
                assert value …