Previous topic

Binary Types

Next topic

Complex

This Page

Enum

spyne.model.enum.Enum(*values, **kwargs)[source]

The enum type that can only return True when compared to types of own type.

Here’s how it’s supposed to work:

>>> from spyne.model.enum import Enum
>>> SomeEnum = Enum("SomeValue", "SomeOtherValue", type_name="SomeEnum")
>>> SomeEnum.SomeValue == SomeEnum.SomeOtherValue
False
>>> SomeEnum.SomeValue == SomeEnum.SomeValue
True
>>> SomeEnum.SomeValue is SomeEnum.SomeValue
True
>>> SomeEnum.SomeValue == 0
False
>>> SomeEnum2 = Enum("SomeValue", "SomeOtherValue", type_name="SomeEnum")
>>> SomeEnum2.SomeValue == SomeEnum.SomeValue
False

In the above example, SomeEnum can be used as a regular Spyne model.