On 15/11/2007, Timothy Hochberg <[EMAIL PROTECTED]> wrote:
>
>
> On Nov 15, 2007 9:11 AM, Hans Meine <[EMAIL PROTECTED]> wrote:
> > Am Donnerstag, 15. November 2007 16:29:12 schrieb Warren Focke:
> >
> > > On Thu, 15 Nov 2007, George Nurser wrote:
> > > > It looks to me like
> > > > a,b = (zeros((2
I tried the (as I thought) nice compact form
In [60]: a,b = (zeros((2,)),)*2
But...
In [61]: b[0] = 2
In [62]: a
Out[62]: array([ 2., 0.])
a and b are the _same_ array
But
In [68]: a,b = (zeros((2,)),zeros((2,)))
In [69]: b[0] = 2
In [70]: a
Out[70]: array([ 0., 0.])
is OK. a & b are
On Nov 15, 2007 9:11 AM, Hans Meine <[EMAIL PROTECTED]> wrote:
> Am Donnerstag, 15. November 2007 16:29:12 schrieb Warren Focke:
> > On Thu, 15 Nov 2007, George Nurser wrote:
> > > It looks to me like
> > > a,b = (zeros((2,)),)*2
> > > is equivalent to
> > > x= zeros((2,))
> > > a,b=(x,)*2
> >
> >
Am Donnerstag, 15. November 2007 16:29:12 schrieb Warren Focke:
> On Thu, 15 Nov 2007, George Nurser wrote:
> > It looks to me like
> > a,b = (zeros((2,)),)*2
> > is equivalent to
> > x= zeros((2,))
> > a,b=(x,)*2
>
> Correct.
>
> > If this is indeed a feature rather than a bug, is there an alterna
On Thu, 15 Nov 2007, George Nurser wrote:
> It looks to me like
> a,b = (zeros((2,)),)*2
> is equivalent to
> x= zeros((2,))
> a,b=(x,)*2
Correct.
> If this is indeed a feature rather than a bug, is there an alternative
> compact way to allocate many arrays?
a, b = [zeros((2,)) for x in range
It's not a question of tuple, you made a tuple, but in each element, you put
the same array, so this behaviour is to be expected.
Matthieu
2007/11/15, George Nurser <[EMAIL PROTECTED]>:
>
> I tried the (as I thought) nice compact form
> In [60]: a,b = (zeros((2,)),)*2
>
> But...
>
> In [61]: b[0]