On Sun, Jun 7, 2009 at 20:44, Fernando Perez<[email protected]> wrote: > On Sun, Jun 7, 2009 at 4:31 PM, David Warde-Farley<[email protected]> wrote: >> A question was raised on the #scipy IRC earlier today, about the >> behaviour of array() with structured dtypes. After some educated >> guessing I figured out that for record arrays, tuples (rather than >> lists) must be used to indicate atomic elements. What I wondered is >> whether this behaviour is documented anywhere, and does it belong in >> the array() docstring, for example? The docstring currently reads "... >> or any (nested) sequence." > > +1 for a clear indication of this fact, as it's rather unusual that a > tuple is OK where a list is not (for typical pythyon APIs) and the > error is *very* obscure. I've been bitten enough times by this that > by now I'm used to it, but I distinctly remember much head scratching > and looking in the wrong places the first time I was hit by this > behavior. > > I don't know if there's a good reason why lists aren't accepted > though, so that instead of documenting an oddity it could just be > cleaned up. Is it not possible for the constructor to duck-type here > a list for a tuple?
It may be *possible*, but it's certainly easier this way, and that is the reason for it. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ Numpy-discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
