[Numpy-discussion] Simplifying array()

Ralf Juengling juenglin at cs.pdx.edu
Thu Jan 13 10:31:14 CST 2005


On Thu, 2005-01-13 at 09:00, Tim Hochberg wrote:
> > It would be good to clarify the acceptable content of a sequence.
> > A list, perhaps with sublists, of numbers is clear enough but what 
> > about a sequence of NumArray instances or even a sequence of 
> > numbers, mixed with NumArray instances?
> 
> Isn't any sequence that is composed of numbers or subsequences 
> acceptable, as long as it has a consistent shape (no ragged edges)?

Why not make it a little more general and accept iterable objects?

>From http://docs.python.org/lib/module-array.html :


array(
typecode[, initializer])
        Return a new array whose items are restricted by typecode, and
        initialized from the optional initializer value, which must be a
        list, string, or iterable over elements of the appropriate type.
        Changed in version 2.4: Formerly, only lists or strings were
        accepted. If given a list or string, the initializer is passed
        to the new array's fromlist(), fromstring(), or fromunicode()
        method (see below) to add initial items to the array. Otherwise,
        the iterable initializer is passed to the extend() method.



Ralf






More information about the Numpy-discussion mailing list