[Bf-python] Thought about IRC meeting and beyond

Joseph Gilbert jgilbert at tigr.ORG
Tue Jan 10 18:47:02 CET 2006


Fine we'll use PyObject_IsTrue() to check booleans. When we have someone 
that asks "Y is it that when I do Object.booleanAttribute = pythonObject 
I get strange behavior?" I'll refer them to stivs :0

Stephen Swaney wrote:

>On Mon, Jan 09, 2006 at 01:45:28PM -0500, Joseph Gilbert wrote:
>  
>
>>Toni Alatalo wrote:
>>
>>    
>>
>>>On Monday 09 January 2006 16:31, Willian Padovani Germano wrote:
>>>
>>>
>>>      
>>>
>>>>>1) The use of True/False over 1/0:
>>>>>    
>>>>>
>>>>>          
>>>>>
>>>>Hi Joseph. Python itself accepts many things as true or false, as
>>>>discussed previously, but of course we won't go there (we won't accept
>>>>"" as false for functions that don't even expect a string, etc).
>>>>  
>>>>
>>>>        
>>>>
>>>err, anything that can be evaluated as true/false should accepted where a 
>>>boolean is expected. those arguments should not be typechecked, just use 
>>>that eval func that python provides. why not just do what python does?
>>>
>>>
>>>      
>>>
>>Again I feel that PyObject_IsTrue is too liberal for use with tp_getset. 
>>However I may be (other than theeth) the only person to feel that 
>>'wassup' != True.
>>    
>>
>
>Allow me to disagree based on two principles:
>1) Python itself is very flexible when evaluating true/false.
>2) Be flexible in what you accept, be strict in what you output.
>
>At the very least we need to accept 1/0 and True/False for our boolean
>vars.  Since we need to test for either case and Python provides the
>lovely convenience func PyObject_IsTrue, I recommend we go all the way
>ad use it.
>
>The rationale for this is similar in what the C++ compiler does when trying
>to match method signatures where it will run appropriate (and often surprising)
>converters to make things work out nicely
>
>If we are going to be strict about bools, we are essentially requiring
>the scripter to write
>  A.bool_var = bool( some_data )
>rather than simply accepting
>  A.bool_var = some_data
>
>I think we should be nice and run the converter for them.  Expecially
>since we don't have to write it!  (there is another systems integration
>principle for you: write as little code as possible)
>
>For return values, booleans should return bools and not 1/0.
>
>  
>



More information about the Bf-python mailing list