[Numpy-discussion] RecArray.tolist() suggestion

Francesc Alted falted at pytables.org
Tue Jul 13 01:30:55 EDT 2004


A Dilluns 12 Juliol 2004 23:14, Perry Greenfield va escriure:
> What I'm wondering about is what a single element of a record array
> should be. Returning a tuple has an undeniable simplicity to it.

Yeah, this why I'm strongly biased toward this possibility.

> On the other hand, we've been using recarrays that allow naming the
> various columns (which we refer to as "fields").  If one can refer
> to fields of a recarray, shouldn't one be able to refer to a field
> (by name) of one of it's elements? Or are you proposing that basic
> recarrays not have that sort of capability (something added by a
> subclass)?

Well, I'm not sure about that. But just in case most of people would like to
access records by field as well as by index, I would advocate for the
possibility that the Record instances would behave as similar as possible as
a tuple (or dictionary?). That include creating appropriate __str__() *and*
__repr__() methods as well as __getitem__() that supports both name fields
and indices. I'm not sure about whether providing an __getattr__() method
would ok, but for the sake of simplicity and in order to have (preferably)
only one way to do things, I would say no.

Regards,

-- 
Francesc Alted





More information about the NumPy-Discussion mailing list