[Tutor] What's in a name?

Keith Winston keithwins at gmail.com
Fri Jan 3 19:53:42 CET 2014


On Fri, Jan 3, 2014 at 4:50 AM, Danny Yoo <dyoo at hashcollision.org> wrote:

> Quick thing.  Please look at the following small program:
>
> #################
> d1 = {1 : 'one'}
> d2 = d1
> d2[2] = 'two'
> print(d1)
> print(d2)
> #################
>
> Predict what this prints out.  Write your prediction on a piece of paper.
>
> Then run the program.  Does it match what you wrote?
>
> If not, start asking questions.  If so, then I'm puzzled.  :P
>
>
> Thanks Danny: I understand this issue when I'm looking right at it, but it
can still slip past me with a moments inattention... as soon as you pointed
it out, I bruised my forehead by slapping it so hard. Thanks.

Actually, it's funnier than that: I now notice that the code I swiped from
you passes the original arrays, not even the "copies" which aren't copies.
That's what I meant to do: make a copy when I wrote chute_nums = chutes. So
I should have passed chute_nums to summarize_game, but it still wouldn't
work (because it's not a copy). More below.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140103/580dc927/attachment.html>


More information about the Tutor mailing list