cpython/Doc/c-api/none.rst

27 lines
672 B
ReStructuredText
Raw Normal View History

.. highlight:: c
2008-01-20 05:30:57 -04:00
.. _noneobject:
The ``None`` Object
-------------------
2008-01-20 05:30:57 -04:00
.. index:: pair: object; None
2008-01-20 05:30:57 -04:00
Note that the :c:type:`PyTypeObject` for ``None`` is not directly exposed in the
2008-01-20 05:30:57 -04:00
Python/C API. Since ``None`` is a singleton, testing for object identity (using
``==`` in C) is sufficient. There is no :c:func:`!PyNone_Check` function for the
2008-01-20 05:30:57 -04:00
same reason.
.. c:var:: PyObject* Py_None
2008-01-20 05:30:57 -04:00
The Python ``None`` object, denoting lack of value. This object has no methods
and is `immortal <https://peps.python.org/pep-0683/>`_.
2008-01-20 05:30:57 -04:00
.. versionchanged:: 3.12
:c:data:`Py_None` is immortal.
2008-01-20 05:30:57 -04:00
.. c:macro:: Py_RETURN_NONE
2008-01-20 05:30:57 -04:00
Return :c:data:`Py_None` from a function.