Class PyEnumAttribute
Marks a C# enum that stands for Python values (DR-84): either the members of a Python Enum class
(AutoresetMode is Gymnasium's AutoresetMode, printed
<AutoresetMode.NEXT_STEP: 'NextStep'>), or plain Python strings that a closed set of values takes
(RenderMode, whose members are Gymnasium's render-mode strings). Each member carries its
Python value in a PyValueAttribute and, for an Enum class, its Python name in a
PyNameAttribute.
[AttributeUsage(AttributeTargets.Enum, AllowMultiple = false, Inherited = false)]
public sealed class PyEnumAttribute : Attribute
- Inheritance
-
PyEnumAttribute
- Inherited Members
- Extension Methods
Remarks
PyEnums reads the attributes once per type. PyBuiltins prints such a member as Python
prints its counterpart, PyEquality compares it as Python compares its counterpart (an Enum
member only with itself, a string member with the equal string), and From(object?) passes a string
member on as its string, so specs and kwargs keep Gymnasium's values.
A C# enum without this attribute is an integer to Python (an IntEnum, a Discrete value), as before.
Constructors
PyEnumAttribute(string?)
Marks the enum.
public PyEnumAttribute(string? className = null)
Parameters
classNamestringThe Python
Enumclass the members belong to ("AutoresetMode"), printed in theirstrandrepr; null (the default) when each member stands for a plain Pythonstr, its PyValueAttribute text.
Properties
ClassName
The Python Enum class's name, or null for members that are plain strings in Python.
public string? ClassName { get; }