Previous topic

propy.repr_method

Next topic

propy.bool_property

This Page

propy.enum_property

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.

Parameters:
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.

Examples

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