Previous topic


Next topic


This Page


propy.enum_property(name, iterable)[source]

Creates a class property that has an iterable qualifier. If the value assigned to the property is not contained in the qualifying iterable, an exception is raised. To use, place the method within a class’s scope.

name : str

The name of the property to be created.

iterable : iterable

An iterable, such as a tuple, list, set, dictionary, or generator. If a dictionary, the value will be checked against the dictionary keys. For faster validation times on large iterables, the use of a set is recommended over a tuple or list.


>>> class Class():
...     property1 = bool_property('property1', {'apples', 'oranges'})