[Bf-python] Object types as string

Campbell Barton cbarton at metavr.com
Wed Apr 4 20:12:22 CEST 2007


I like 2 also, just need to work out where we'll store types/constants.

Martin Poirier wrote:
> --- 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
> _______________________________________________
> 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