[Tutor] Not understanding a bit of code behavior

David Hutto smokefloat at gmail.com
Tue Jan 25 08:54:22 CET 2011


On Tue, Jan 25, 2011 at 2:42 AM, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
> "Bill Allen" <wallenpb at gmail.com> wrote
>
>> I am convinced that I had previously assigned part_list to out_list by
>> reference, not value as I mistaken thought when I first wrote the code,
>
> In Python variables are names which refer to objects.
> So your assignment made both names refer to the same object.
>
>> Question, is it possible to copy values from one object to another in such
>> a
>> way as they are not just references one to the other?
>
> If you want to copy a list the usual way is to create a new copy
> using slicing:
>
> newList = oldList[:]
>
> You can also use the deepcopy module if the list is multi level.
>
>> Sorry about asking questions and then answering them.  Things began to
>> become more clear with each question I asked.
>
> Thats often the way :-)
> The act of articulating the problem forces you to think about it
> differently.RTFM, before ask the list. No that they aren't helpful here, but try on your own(and don't start off topic questions)

>
> HTH
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
The lawyer in me says argue...even if you're wrong. The scientist in
me... says shut up, listen, and then argue. But the lawyer won on
appeal, so now I have to argue due to a court order.

Furthermore, if you could be a scientific celebrity, would you want
einstein sitting around with you on saturday morning, while you're
sitting in your undies, watching Underdog?...Or better yet, would
Einstein want you to violate his Underdog time?

Can you imagine Einstein sitting around in his underware? Thinking
about the relativity between his pubic nardsac, and his Fruit of the
Looms, while knocking a few Dorito's crumbs off his inner brilliant
white thighs, and hailing E = mc**2, and licking the orangy,
delicious, Doritoey crust that layered his genetically rippled
fingertips?

But then again, J. Edgar Hoover would want his pantyhose intertwined
within the equation.

However, I digress, momentarily.

But Einstein gave freely, for humanity, not for gain, other than
personal freedom.

An equation that benefited all, and yet gain is a personal product.

Also, if you can answer it, is gravity anymore than interplanetary static cling?


More information about the Tutor mailing list