Table of Contents

Class: enum ./src/peak/model/enumerations.py

Define an enumeration literal

Place enum instances in an Enumeration class to define the values of the enumeration's instances. Example:

        class RGB(model.Enumeration):
            red = model.enum("R")
            green = model.enum("G")
            blue = model.enum("B")

In the example above, RGB.red will become an enumeration instance whose value hashes and compares the same as the string "R".

You may use any object as an enumeration literal, but typically you will use an integer, string, boolean, or similar primitive type. Note that you can also omit the value when creating a literal, in which case the value will be the same string as the name of the literal, e.g.:

        class FooBar(model.Enumeration)
            foo = model.enum()
            bar = model.enum()

In the example above, FooBar.foo will be an enumeration instance whose value hashes and compares the same as the string "foo".

Note, by the way, that a model.enum() literal is not the same object as the enumeration instance whose value it defines! model.enum(1) does not hash or compare the same as 1, and it is not an instance of model.Enumeration or any subclass thereof. model.enum() is only used to define literals in the body of an enumeration class.

Base Classes   
object
Methods   
__call__
__init__
  __call__ 
__call__ ( self,  name )

Return dict of enumeration literals in context of name

This method is used by Enumeration classes to set up their instances; you do not need to call this yourself.

  __init__ 
__init__ ( self,  *value )

Exceptions   
TypeError( "enum() takes at most one argument", value )

Table of Contents

This document was automatically generated on Mon Aug 10 01:11:12 2020 by HappyDoc version 2.1