[Numpy-discussion] alternative mechanism for initializing an array

Keith Goodman kwgoodman@gmail....
Thu Jul 16 15:57:18 CDT 2009


On Thu, Jul 16, 2009 at 1:49 PM, David Warde-Farley<dwf@cs.toronto.edu> wrote:
> On 16-Jul-09, at 3:09 PM, Keith Goodman wrote:
>
>> def myarray(*args, **kwargs):
>>    return np.array([z for z in args], **kwargs)
>
>
> This version is better IMHO, because then you can still specify the
> dtype by keyword. although (just to be a pedant)
>
>> return np.array(args, **kwargs)
>
> works as well. :)

Oh, of course. Nice.


More information about the NumPy-Discussion mailing list