Discussion:
Python C API: Constructing bool (True, False) values
Tim Peters
2003-03-18 18:59:51 UTC
Permalink
[Lexy Zhitenev]
I need to write a function in C that returns bool (True or False value).
What function in Python C API stands for this?
Py_True and Py_False are global constants, like Py_None. So, e.g.,

Py_INCREF(Py_True);
return Py_True;

to return True (in Python 2.3; before 2.3, Py_True resolves to the int 1).
Lexy Zhitenev
2003-03-18 17:48:03 UTC
Permalink
Can anybody help me:
I need to write a function in C that returns bool (True or False value).
What function in Python C API stands for this?

Regards, Lexy.
Gustavo Niemeyer
2003-03-19 00:04:10 UTC
Permalink
Post by Tim Peters
I need to write a function in C that returns bool (True or False value).
What function in Python C API stands for this?
Py_True and Py_False are global constants, like Py_None. So, e.g.,
Py_INCREF(Py_True);
return Py_True;
to return True (in Python 2.3; before 2.3, Py_True resolves to the int 1).
Perhaps he's looking for PyObject_IsTrue()?
--
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ]
Lexy Zhitenev
2003-03-19 08:26:28 UTC
Permalink
Post by Tim Peters
Py_True and Py_False are global constants, like Py_None. So, e.g.,
Py_INCREF(Py_True);
return Py_True;
to return True (in Python 2.3; before 2.3, Py_True resolves to the int 1).
Thank you

Loading...