sub typing built in type with common attributes. Am I right?

King animator333 at gmail.com
Fri Jul 18 06:56:11 EDT 2008


Thanks Michaud,

You have actually solved an another problem by
'make_subtype_with_attr' function.

What actually I am trying to do here is to create custom types using
built in types to use in my application.
For example , float2, float3, color, vector, point, normal, matrix
etc. The reason being creating as individual subtypes is because each
subtypes has it's own set of functions as well as common functions and
attributes defined in 'Attribute' class.

Although I won't be doing any math using subtypes like multiply a
color by another color or add a float and a color. One of the
important function that every subtype has is to print itself in a
special format. For 'color' it would be :

'type' + 'name' + ' = color('+color[0]+', '+color[2]+',
'+color[2]+');'
Result: color myColor = color(0.5, 0.1, 1.0);

I hope this will make things more clearer. If you do have any
suggestions then please send it across.

Prashant



More information about the Python-list mailing list