How to make a custom type "true" or not, in Python 1.5.2
Michael Hudson
mwh21 at cam.ac.uk
Mon Feb 19 16:29:42 EST 2001
"Warren Postma" <embed at geocities.com> writes:
> I am writing a little event object, here is the PyTypeObject declaration:
[bobbit]
> Now, how do I make it true or false, it appears that all C Type object
> instances are True, because They Are A Thing, not Nothing, but what if you
> want to make something that can be a Logically False Entity? Do I have to
> implement the sequence protocol, and implement len(x)? It doesn't seem that
> it calls my getattr function to check anything. It's just plain true.
You want nb_nonzero in the number methods struct, from memory... and
the nb_nonzero field from the tp_as_number field from checking the
source (! where does my brain keep all these bits of information?).
Cheers,
M.
--
On the other hand, the following areas are subject to boycott
in reaction to the rampant impurity of design or execution, as
determined after a period of study, in no particular order:
... http://www.naggum.no/profile.html
More information about the Python-list
mailing list