Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

Python 2 is no longer supported by the community. We recommend that you migrate Python 2 apps to Python 3.

The Enum Class

The Enum class is the base class for all enumerated types, used to initialize new Enum instances.

Enum is provided by the protorpc.messages module.


The constructor of the EnumField class is defined as follows:

class Enum(name, number=None)

Initializes an Enum instance automatically when the class is constructed. Integers and strings are cast automatically to the enum values.

The name of the Enum instance to initialize.
The number of the Enum instance to initialize.

Raises an exception if called on a class that has already been initialized.

Class Methods

The Enum class provides the following class methods:

Makes a dictionary version of enumerated class. You can use this dictionary with def_num and import_enum.
Returns a dictionary name and number for the enumerated class.