[Bf-python] API style clarification

Ken Hughes khughes at pacific.edu
Mon Dec 25 02:26:34 CET 2006


Campbell Barton wrote:
> Stephen Swaney wrote:
>> On Sun, Dec 24, 2006 at 08:22:29AM -0800, Ken Hughes wrote:
>>> Campbell Barton wrote:
>>>> campbellbarton (Campbell Barton) 2006/12/24 04:25:53 CET
>>>>
>>>>  Modified files:
>>>>    blender/source/blender/python/api2_2x/doc Camera.py  
>>>>  Log:
>>>>  added camera.dofDist to the python camera module
>>> Was looking over this commit and say Cam added a .dofDist attribute 
>>> and getDofDist()/setDofDist().  What's the "policy" on attributes vs 
>>> methods?  I've only been adding methods when they aren't simple 
>>> enough to be getseters (i.e, multiple parameters, etc).
>>>
>>> I'm not trying to critisize Cam's commit; I was thinking maybe I've 
>>> been wrong by not commiting get()/set() methods when I should be.
>>>
>>> Ken
>>
>> No, you are correct, Ken.  We want to migrate away from methods
>> for getting and assigning to attributes.  As you point out,
>> we will still need methods for doing fancey things, but tp_getset
>> tables are the general rule.
>>
> 
> Agree, went against the grain to have get/set, but I thought it better 
> to be consistent with current API.
> Also its not as simple since this has not been moved to getsetattrs yet.
> can remove get/set but in that case it would be one of the few (only?) 
> functions that is an attribute but not a method.

The reason I was asking is I believed that we planned to eventually 
deprecate the getStuff() and setStuff() methods in favor of attributes 
(where they are duplicates); we just haven't removed the existing 
get/setStuff() yet.  I just wanted to clarify whether I should go back 
and add the methods in, or if you should save yourself the extra work :-)

Ken



More information about the Bf-python mailing list