[Bf-python] boolean check bug in Armature_setDrawAxes

Stephen Swaney sswaney at centurytel.net
Fri Dec 23 19:07:48 CET 2005


On Fri, Dec 23, 2005 at 12:34:13PM -0500, Gilbert, Joseph T. wrote:
> That is correct anything not None, 0 or False evaluates to True using
> PyObject_IsTrue. I understand that and I intentionally implemented all
> Boolean members in Armature to take True/False. 
> In a sense yes, Armature.member = 'wasssup' can technically be
> considered a valid Boolean but I thought restricting this to True/False
> would make more sense. 

I can understand and appreciate your thinking here, but I believe that
we should take the position that if Python thinks it is True, then BPy
should also.

A useful principle for system integration is "Be liberal in what you
accecpt as input and be strict in what you output".  Python
exemplifies this by accepting pretty much anything that is vaguely not
false or nullish as true.

>From the user's point of view, this makes life simpler.  IIRC, this
issue came up originally, when someone had trouble spelling 'True' in
their script and switched to integers instead.  Note to self: must
remember to add this incident to forthcoming paper "Users Considered
Harmful".

So don't think of this as a criticism, but as an enhancement for
real-world conditions.  Note to self #2: remember to compliment Joseph
on new armature work.

I would suggest that in our API we use  PyObject_IsTrue() to check
our boolean inputs and return actual PyBools as boolean output.  As
you mentioned, this is good wiki material.
 
-- 
Stephen Swaney			
sswaney at centurytel.net




More information about the Bf-python mailing list