[Bf-python] module consts / dictionary consts
Joseph Gilbert
models at paposo.com
Sat Aug 13 19:40:09 CEST 2005
Ken Hughes wrote:
> Asking for a clarification in my mind, so I know exactly what I should
> be watching for while I'm reviewing the BPython code for API
> inconsistencies:
>
> We've been discussing inplementing dictionary constants to replace
> strings in the API refactoring. There is also discussion of module
> constants, which are implemented in some BPython modules
> (http://wiki.blender.org/bin/view.pl/Blenderdev/UseOfConstantsInTheAPI).
>
> So are dictionary constants and module constants the same thing? Are
> dictionary constants more like Blender.Lamp.Type? Or a combination of
> both (i.e., making dictionaries of module constants)?
A module contant is a PyObject that resides in the namespace of the
module of which it was added. There are 3 types of module constants:
1. a named object
2. a named integer
3. a named string
By dictionary constant i assume you mean the PyContantObject in
constant.c. This is basically a psuedo-dictionary that was originally
meant to be loaded with key:value pairs. Then you would be able to call
x = myconst['key'].
The way the wiki page out lines things you can load a single key:value
pair into the dictionary and use the object as it'f the whole object as
a constant. e.g. myconst == Module.Constant does a instance comparison)
However it might be just as feasible to load a constant object with a
series of key:value pairs. Such as:
{'constA': TEX_somedefine, 'constB':TEX_somethingelse, 'constC':
TEX_doodoodo}
This isn't really useful though unless you load this as an object bound
to the modules namespace imo. What might be useful is something like this:
const = pyConstant({key:value,key:value, key:value})
module_addobject("constants", const)
Blender.Module.constants['constant1']
This would be a better implementation if the PyConstant implements the
keys/items/values iterface. That way you could call.
print Blender.Module.constants.keys()
to get a list of constants for that module. However either way is nice.
>
>
>
> Ken
> _______________________________________________
> Bf-python mailing list
> Bf-python at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-python
>
>
>
More information about the Bf-python
mailing list