[Bf-python] Object types as string

Stephen Swaney sswaney at centurytel.net
Wed Apr 4 07:34:11 CEST 2007


On Wed, Apr 04, 2007 at 03:13:42PM +1000, Campbell Barton wrote:
> Hi, just wondering if were ok about ob.type's being a string..
> 
> bpy.ipos.new('name', 'Material') # new material ipo
> ob.type == 'Mesh'

Funny you should mention this.  I was just thinking about it the 
other day.

As a general rule, we would like to get away from passing strings
as arguments and use constants instead.  

We talked about constants a little bit at the last meeting.

>From a user perspective, constants have the advantage of being checked
at 'compile' time rather than when the script is running.  The can
also be handled programmatically rather then being hard coded as
'magic numbers'.

>From a C programming standpoint, constants can be used in case
statements rather than the long if/else blocks you need with strings
names.

-- 
Stephen Swaney			
sswaney at centurytel.net




More information about the Bf-python mailing list