[Bf-python] Memory leak - BPY

Campbell Barton cbarton at metavr.com
Fri Apr 6 10:20:05 CEST 2007


Ken Hughes wrote:
> Campbell Barton wrote:
>> Hey Ken,
>>
>> I dont see how PyObject_IsTrue relates to PyNumber_Float or PyNumber_Int?
> 
> The relation is this: PyObject_IsTrue() will let you say
> 
>    ob.selected = True
> or
>    ob.selected = 1
> or anything else which Python would evaluate as True using bool().  The 
> gist of the discussion I referred to (as I interpreted it) was to be as 
> forgiving of user input as possible (can't remember the expression 
> Stephen quoted).  Since the consensus at that time was to go with 
> PyObject_IsTrue(), my assumption was we should follow that elsewhere in 
> the API.

I think PyObject_IsTrue is good, since python works this way.

if 1:
if True:

AFAIK no python builtin modules accept  '1.2' as a float.

We should discuss next Py Meeting

> 
>> With my additions to the python API Iv been using PyFloat_AsDouble and 
>> PyNumber_Check seem to work with floats and ints.
>>
>> see - boxPack_FromPyObject
>>
>> I should do some testing to see exactly what it will and wont accept, 
>> (the py docs dont help - http://www.python.org/doc/api/floatObjects.html)
> 
> I tried passing strings like '1.2' to PyFloat_AsDouble() and as I 
> expected, it doesn't return a float value of 1.2.  Same type of thing 
> for PyInt_AsLong().
> 
> Ken
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
> 


-- 
See MetaVR Visuals Used at the Combat Studies Institute
http://www.metavr.com/casestudies/baghdadviews.html

Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-python mailing list