<div class="gmail_quote">On 21 December 2011 22:25, Eric <span dir="ltr"><<a href="mailto:einazaki668@yahoo.com">einazaki668@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is it true that if I want to create an array or arbitrary size such<br>
as:<br>
for a in range(n):<br>
x.append(<some function...>)<br>
<br>
I must do this instead?<br>
x=[]<br>
for a in range(n):<br>
x.append(<some function...>)<br>
<br>
Now to my actual question. I need to do the above for multiple arrays<br>
(all the same, arbitrary size). So I do this:<br>
x=y=z=[]<br>
for a in range(n):<br>
x.append(<some function...>)<br>
y.append(<some other function...>)<br>
z.append(<yet another function...>)<br>
<br>
Except it seems that I didn't create three different arrays, I created<br>
one array that goes by three different names (i.e. x[], y[] and z[]<br>
all reference the same pile of numbers, no idea which pile).<br>
<br>
This surprises me, can someone tell me why it shouldn't? I figure if<br>
I want to create and initialize three scalars the just do "a=b=c=7",<br></blockquote><div><br></div><div>7 is 7 => True</div><div>They're the same "7". You won't notice it though, as numbers are immutable. </div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
for example, so why not extend it to arrays. Also, is there a more<br>
pythonic way to do "x=[], y=[], z=[]"?<br></blockquote><div><br></div><div> a, b, c = [], [], []</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It's a slick language but I still have trouble wrapping my brain<br>
around some of the concepts.<br>
<br>
TIA,<br>
<span class="HOEnZb"><font color="#888888">eric<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br>