[Bf-python] Object types as string

Martin Poirier theeth at yahoo.com
Wed Apr 4 19:35:30 CEST 2007


--- Willian Padovani Germano <wgermano at superig.com.br>
wrote:

> - Ken pointed months ago that he disliked how a user
> could write correct 
> scripts using totally wrong constants, because
> internally their (int) 
> values were the same. Something like lamp.type =
> Mesh.Modes.Twosided, 
> for example. If we use strings instead of ints this
> can be prevented easily.

This can also be fixed with non-string constants in
two different ways:

1- If constants are numeric, use an artificial number
instead of the internal constant and do the conversion
in BPy (then, parameters that accept constants can
check against specific constants vs specific values).

2- If constants are instances of an opaque Py types
(could even be an empty type), check against the
Python ID internally (the instance could have a
non-python accessible param that corresponds to its
numeric value). These instances could implement
__str__ and __repr__ for ease of use/debugging.

Of those two, I prefer solution 2 because it opens the
door to abstracting the constant type (float, int,
...) and doesn't have all the clunkiness of string
constants

Martin


 
____________________________________________________________________________________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains.
http://farechase.yahoo.com/promo-generic-14795097



More information about the Bf-python mailing list