Name
PyErr_NewException
Synopsis
PyObject* PyErr_NewException(char*name
,PyObject*base
,PyObject*dict
)
Subclasses exception class base
, with
extra class attributes and methods from dictionary
dict
(normally NULL
,
meaning no extra class attributes or methods), creating a new
exception class named name
(string
name
must be of the form
"modulename
.classname
“)
and returning a new reference to the new class object. When
base
is NULL
, uses
PyExc_Exception
as the base class. You normally
call this function during initialization of a module object
module
. For example:
PyModule_AddObject(module, "error", PyErr_NewException("mymod.error", NULL, NULL));
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.