[Bf-python] Modules vs Types (was: Modifiers syntax)

Ken Hughes khughes at pacific.edu
Sun Apr 23 17:30:58 CEST 2006


Campbell Barton wrote:
> Ken Hughes wrote:
> 
>> Campbell Barton wrote:
>>
>>> Since were using getitem/setitem anyhow.
>>>
>>> mod[mod.keys().LEVELS] = 3     # set subsurf subdivision levels to 3
>>>   ...couldent we just use
>>> mod["LEVELS"] = 3     # set subsurf subdivision levels to 3
>>>   ...and return a key error if the attribute dosent exist exist for 
>>> that modifier?
>>>
>>> Also, Id also prefer strings for append.
>>> ob.modifiers.append("SUBSURF")
>>
>>
>> I thought the goal for the API was to get rid of string in favor of 
>> constants (otherwise I would have left the Ipo stuff as it was).
>>
>> Ken
> 
> Good point, in that case what about just have a set on constants from 
> the Modifiers module.
> 
> mod[Blender.Modifier.Settings.LEVLES] = 3
> 
> This seems long winded. but in most cases people would do
> settings= Blender.Modifier.Settings
> mod[settings.LEVLES] = 3
> 
> append could be
> ob.modifiers.append(Blender.Modifier.Type.SUBSURF)
> 
> It seems odd to get constant values from an instance, especially a 
> function of an instance.
> IMHO, My suggestion is also more in keeping with Mesh/Material and other 
> modules..
> 
> This sound okay?

I'm OK with this, but brings up a separate question: what's the 
distinction between a type and a module?  I didn't make Modifiers a 
module because as far as I could see the only thing that would be 
imported were just these type of constants.  What's the "rule"?

Ken



More information about the Bf-python mailing list