Re: [Tutor] python dictionaries (copy by reference or copy by value?)

2015-05-02 Thread Steven D'Aprano
On Sat, May 02, 2015 at 04:25:41PM -0700, Alex McFerron wrote: > trying to understand why this is true [...] > question: if y=x from step 2 (the copy job) is just creating a pointer y > that points to the same thing as x then why when i set x = {} in step 5 > does that also not cause y to equal {}

Re: [Tutor] python dictionaries (copy by reference or copy by value?)

2015-05-02 Thread Ben Finney
Alex McFerron writes: > trying to understand why this is true > > step 1: x = {} Assignment; binds a reference (the name ‘x’) to a newly-created empty dictionary. > step 2: y = x Assignment; binds a reference (the name ‘y’) to the object currently referred to by ‘x’. That's the same object as

Re: [Tutor] python dictionaries (copy by reference or copy by value?)

2015-05-02 Thread Alan Gauld
On 03/05/15 00:25, Alex McFerron wrote: step 1: x = {} step 2: y = x step 3: x['key'] = 'value' # at this point if i print x or y i see {'key', 'value'} step 4: x['key'] = 'newValue' #and at this point printing x or y i see {'key', 'newValue'} and this is true if this was y['key'] because of t

[Tutor] python dictionaries (copy by reference or copy by value?)

2015-05-02 Thread Alex McFerron
trying to understand why this is true step 1: x = {} step 2: y = x step 3: x['key'] = 'value' # at this point if i print x or y i see {'key', 'value'} step 4: x['key'] = 'newValue' #and at this point printing x or y i see {'key', 'newValue'} and this is true if this was y['key'] because of the b

Re: [Tutor] python dictionaries

2007-01-05 Thread Carroll, Barry
> -Original Message- > Message: 7 > Date: Fri, 05 Jan 2007 15:43:56 -0800 > From: "Raven Of Night Raven Of Night" <[EMAIL PROTECTED]> > Subject: [Tutor] python dictionaries > To: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type

Re: [Tutor] python dictionaries

2007-01-05 Thread Alan Gauld
"Raven Of Night Raven Of Night" <[EMAIL PROTECTED]> wrote > I don't understand, dictionarys only allow two elements so how can > you > include several generations in the dictinoary... Grandfather -> Father -> Son can be expressed as two pairs: Grandfather -> Father Father -> Son Now you can

Re: [Tutor] python dictionaries

2007-01-05 Thread Adam Bark
On 05/01/07, Raven Of Night Raven Of Night <[EMAIL PROTECTED]> wrote: Hi, there was this two step program I was working on but i can only complete the first step. - - Write a Who's Your Daddy? program that lets the user enter the name of the male and produces the name of his father. Allow the u

[Tutor] python dictionaries

2007-01-05 Thread Raven Of Night Raven Of Night
Hi, there was this two step program I was working on but i can only complete the first step. - - Write a Who's Your Daddy? program that lets the user enter the name of the male and produces the name of his father. Allow the user to add, replace, and delete father son pairs. The program should a