Package csb :: Package core :: Class validatedproperty
[frames] | no frames]

Class validatedproperty

source code

object --+    
         |    
  property --+
             |
            validatedproperty

Property decorator with predefined getter/setter and value checking or casting in the setter. The provided function will be the validator and must take and return a value.

If the property is named foo, a private field named _foo will be used to store the value.

Example:

>>> @validatedproperty
>>> def a(v):
>>>     v = int(v)
>>>     if v < 0:
>>>         raise ValueError(v)
>>>     return v
Instance Methods
value
__get__(self, instance, cls) source code
property attribute

__init__(self, validator)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__set__(self, instance, value) source code

Inherited from property: __delete__, __getattribute__, __new__, deleter, getter, setter

Inherited from object: __delattr__, __format__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from property: fdel, fget, fset

Inherited from object: __class__

Method Details

__get__(self, instance, cls)

source code 
Returns: value
Overrides: property.__get__
(inherited documentation)

__init__(self, validator)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Returns:
property attribute

Overrides: object.__init__
(inherited documentation)

__set__(self, instance, value)

source code 
Overrides: property.__set__
(inherited documentation)