[Numpy-discussion] subclassing RecordArrays

Francesc Altet faltet at carabos.com
Tue Jul 5 09:58:23 EDT 2005


A Sunday 03 July 2005 04:39, Les Schaffer va escriure:
> suppose i want to have a class RecArrayD(RecArray) that returns a list
> of its fields, much like a Dict does: recarrayD.keys()
>
> the problem is that the fromXXX functions in records.py know only about
> the one RecArray. and RecArrayD._copyFrom() seems to be of little help,
> since the new style RecArray has to be framed out first, so to speak.

I don't know exactly what do you mean here. If RecArrayD inherits from
RecArray, then RecArrayD should be a RecArray object (and also a
RecArrayD, of course!). So I would say that the fromXXX fucntions
should work just fine for these objects. May you put some example on
what are you trying to do?.

> yes, i can get the keys like so: recarray._names, but i assume that the
> '_' in front of '_names' is there for a reason, like maybe don't count
> on it???

Maybe. However I guess that "_names" would not change for some time so
it might be safe using it for a while :-P. Nevertheless I agree that
"_names" attribute should be promoted to "names" because it's a
first-class attribute for RecArray object IMO.

Cheers,

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"





More information about the NumPy-Discussion mailing list