[Numpy-discussion] problem with ndarray attributes

Christopher Hanley chanley at stsci.edu
Mon Mar 27 13:48:08 CST 2006

Hi Travis,

I have run across a feature in numpy which I am not sure how to handle. 
  One of the new features of the ndarray is that named fields can be 
accessed as attributes.  So, if a user created a recarray with fields 
named "address", "phone", and "names" they would be able to access all 
of the names in the recarray objects with "recarrayObject.names".

I have found that this can cause problems when a user creates a table 
with a field name that happen to coincide with an existing class 
attribute or method.  In particular, I am having a problem in pyfits 
where a user has a table with a column named "field".  This column name 
is causing an attribute "field" to be created that overrides the 
existing class field method.

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?

Thank you for your time and help,

More information about the Numpy-discussion mailing list