[Nipy-devel] attributes vs. traits

Jonathan Taylor jonathan.taylor at stanford.edu
Sat May 20 00:17:50 CDT 2006


hi again,

i'm sorry about the extra traffic -- i just don't quite get the 
attributes issue.

first question: where does the module attributes.py come from?

second question: i don't quite understand the validation mechanism.... 
for instance, in revision 413 this line appears:
-------------------------

class label (readonly): implements=(None,) # fix: can be tuple or int

-------------------

i have no idea how the "implements statement" relates to the comment "can be tuple or int": why is None automatically associated to an int? 

this may be an unfair question because maybe the comment is not meant to imply that the "implements" statement should be interpreted as a tuple or int. if this comment does not mean that, then how would one specify an attribute that can be a tuple or int?

in traits this is quite clear to me: it would look like

label = traits.Trait([traits.Tuple, traits.Int])

third question / point: not being a computer scientist, i am not impressed by arguments about messing up my metaclass structure (mainly because i have no idea what this means in practical terms). is there a concrete example where this makes a difference ("this" being to use attributes or traits)? 

one instance where i could see traits' behaviour making sense in this regard is if there were many classes that were to have the attribute "label" above (i.e. that line would appear in many class definitions). looking at the attributes examples, 
it would seem that the "label" attribute in each class having such an attribute would be an instance of a different class BUT by reusing a trait, (i.e. putting the "label" trait definition outside the class definitions and putting the line "label = label" inside each class definition), then it would seem to me like these "label" traits are really 
instances of the same class (which may be desirable). however, not being a computer scientist, i may be muddled in my class/metaclass hierarchy again.

overall question: if traits already has potential UI's for editing values (or fitting right into envisage if we ever use it), and has community support via enthought and its users, what do we gain by going to attributes instead (perhaps at the cost of adding a dependency for generating docs)?

-- jonathan




-- 
------------------------------------------------------------------------
I'm part of the Team in Training: please support our efforts for the
Leukemia and Lymphoma Society!

http://www.active.com/donate/tntsvmb/tntsvmbJTaylor

GO TEAM !!!

------------------------------------------------------------------------
Jonathan Taylor                           Tel:   650.723.9230
Dept. of Statistics                       Fax:   650.725.8977
Sequoia Hall, 137                         www-stat.stanford.edu/~jtaylo
390 Serra Mall
Stanford, CA 94305




More information about the Nipy-devel mailing list