[Bf-python] Attribute casing

Ken Hughes khughes at pacific.edu
Fri Aug 26 22:48:12 CEST 2005


Since the True and False booleans are just subclasses of int, I think 
maybe relaxing the argument checks will work.  I just tested with two 
new attributes ("camera.ortho" and "camera.persp") with this:

if camera.ortho == 0:
     camera.ortho = 1
elif camera.persp == False:
     camera.persp = True

PyArg_ParseTyple(args, "i", &value) and PyInt_Check() will accept either 
int or bool.  Whether we want the setters to return 0/1 or True/False is 
a separate matter.  I think it's mainly a matter of semantics.

Ken

Gilbert, Joseph wrote:
> Hmm.. well I'd personally prefer we stick with True and False but that
> may screw with a lot of scripts.
> 
> -----Original Message-----
> [mailto:bf-python-bounces at projects.blender.org] On Behalf Of Ken Hughes
> Stephen Swaney wrote:
> 
>>On Fri, Aug 26, 2005 at 09:12:53AM -0400, Joseph Gilbert wrote:
>>
>>>Yehoshua Sapir wrote:
>>>
>>>>>Obj.attriubte = TRUE  (or)
>>>>
>>>>I'd like to note that Python already has a 'True' built-in.
>>>
>>>Hehe good point Yehoshua. It was just a way for testing and returning 1 
>>>or 0 (which is what a lot of our functions were throwing and taking). 
>>>It's probably better to be using 'True' and 'False' for booleans! :)
>>
>>Actually, I believe it is more correct to say "Python *now* has a
>>'True' built-in".  And yeah, we should use it.
> 
> I was just thinking about while work on the tp_getset stuff.  For the 
> attributes which and getStuff()/setStuff() methods which takes 1 or  0, 
> should we also have them use booleans (setters would accept both bools 
> and ints)?



More information about the Bf-python mailing list