Skip to content

Commit cbb7494

Browse files
committed
For "constructor similar to that of enum.Enum" point to https://docs.python.org/3/howto/enum.html#functional-api, as suggested by gh-timohl (#5555 (comment)).
1 parent f885205 commit cbb7494

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

docs/classes.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ supplied to the ``py::native_enum`` and ``py::class_`` constructors. The
516516
into the parent scope, if desired.
517517

518518
``py::native_enum`` was introduced with pybind11v3. It binds C++ enum types
519-
to native Python enum types, typically types in Python's `stdlib enum`_ module,
519+
to native Python enum types, typically types in Python's
520+
`stdlib enum <https://docs.python.org/3/library/enum.html>`_ module,
520521
which are `PEP 435 compatible <https://peps.python.org/pep-0435/>`_.
521522
This is the recommended way to bind C++ enums.
522523
The older ``py::enum_`` is not PEP 435 compatible
@@ -543,9 +544,12 @@ Other types can be specified like this:
543544
py::native_enum<Pet::Kind>(pet, "Kind", "enum.IntEnum")
544545
545546
Any fully-qualified Python name can be specified. The only requirement is
546-
that the named type is similar to enum.Enum_ in these ways:
547+
that the named type is similar to
548+
`enum.Enum <https://docs.python.org/3/library/enum.html#enum.Enum>`_
549+
in these ways:
547550

548-
* Has a constructor similar to that of enum.Enum_::
551+
* Has a `constructor similar to that of enum.Enum
552+
<https://docs.python.org/3/howto/enum.html#functional-api>`_::
549553

550554
Colors = enum.Enum("Colors", (("Red", 0), ("Green", 1)))
551555

@@ -559,9 +563,6 @@ that the named type is similar to enum.Enum_ in these ways:
559563

560564
underlying = red.value
561565

562-
.. _`stdlib enum`: https://docs.python.org/3/library/enum.html
563-
.. _enum.Enum: https://docs.python.org/3/library/enum.html#enum.Enum
564-
565566
.. note::
566567

567568
In rare cases, a C++ enum may be bound to Python via a

0 commit comments

Comments
 (0)