[Numpy-discussion] problem with ndarray attributes

Perry Greenfield perry at stsci.edu
Mon Mar 27 14:11:05 CST 2006


On Mar 27, 2006, at 5:02 PM, Travis Oliphant wrote:
>
> This is a standard problem with using attribute access.   I suppose it 
> would be better to always lookup the attributes first on the object 
> and then if that fails use field access.  That way library code would 
> not break if a user happened to name their fields after a method or 
> property.   Users would have to change code if new methods or 
> properties were added (although that won't be as common).

I think some mechanism must be built in to make it easy to add new 
attributes and methods (e.g., some method to append new object 
attributes that are protected?). That way subclassing record arrays  
wouldn't have to do their own checks on this but rather register their 
new methods and attributes as things that would not get overridden (or 
is there some more magic way of doing this that doesn't require 
something this explicit?)

>>
>> It would seem to me that existing class methods and attributes should 
>> take precedence over the attributes created to correspond to column 
>> names.  Is there a way to implement this behavior in ndarray?
>
>
> I think this is the right thing to do.   Are there any objections?
>
Seems like the obvious thing. Otherwise any tool one builds that allows 
a user to use arbitrary field names can suddenly break if a user uses 
the wrong name. With the proposed change, there is always the field 
method to get around any name collisions.

Perry





More information about the Numpy-discussion mailing list