Re: [Tutor] list of dict question

2010-10-12 Thread Francesco Loffredo
On 11/10/2010 19.23, Alan Gauld wrote: ... HTH, Sure it did! Very enlightening, Alan. THANK YOU! Nessun virus nel messaggio in uscita. Controllato da AVG - www.avg.com Versione: 9.0.862 / Database dei virus: 271.1.1/3190 - Data di rilascio: 10/11/10 08:34:00 ___

Re: [Tutor] list of dict question

2010-10-11 Thread Alan Gauld
"Francesco Loffredo" wrote lst = [] for n in range(3): obj = {} I didn't know that this creates a new obj if obj already exists, I thought it would just update it. That's my mistake. Yes you have to remember that in Python, unlike C etc, names are not aliases for memory locations. They are

Re: [Tutor] list of dict question

2010-10-11 Thread Francesco Loffredo
Thank you, Alan and Dave, for your spotting this weak point in my understanding of Python! On 11/10/2010 2.11, Dave Angel wrote: On 2:59 PM, Alan Gauld wrote: "Francesco Loffredo" wrote did, Roelof's code would work perfectly, and you could store in a list all the subsequent changes of a d

Re: [Tutor] list of dict question

2010-10-10 Thread Dave Angel
On 2:59 PM, Alan Gauld wrote: "Francesco Loffredo" wrote did, Roelof's code would work perfectly, and you could store in a list all the subsequent changes of a dictionary without calling them with different names. You don;'t need dfifferent names. Provided the name creates a new object ins

Re: [Tutor] list of dict question

2010-10-10 Thread Alan Gauld
"Francesco Loffredo" wrote did, Roelof's code would work perfectly, and you could store in a list all the subsequent changes of a dictionary without calling them with different names. You don;'t need dfifferent names. Provided the name creates a new object inside the loop you can reuse the

Re: [Tutor] list of dict question

2010-10-10 Thread Francesco Loffredo
On 09/10/2010 10.25, Alan Gauld wrote: "Francesco Loffredo" wrote > On the next iteration you overwrite those two dictionaries > with new values then append them to the list again. > So you wind up with 2 copies of the updated dictionaries. > ... This is difficult for me too: why does this hap

Re: [Tutor] list of dict question

2010-10-09 Thread Alan Gauld
"Francesco Loffredo" wrote > On the next iteration you overwrite those two dictionaries > with new values then append them to the list again. > So you wind up with 2 copies of the updated dictionaries. > ... This is difficult for me too: why does this happen? Or, more correctly, why should th

Re: [Tutor] list of dict question

2010-10-09 Thread Francesco Loffredo
On 09/10/2010 9.37, Steven D'Aprano wrote: On Sat, 9 Oct 2010 06:05:57 pm Francesco Loffredo wrote: Alan's answer to Roelof made me think... I'm sorry, I don't know what your question is. You seem to have quoted various bits and pieces of text from earlier emails (text beginning with> signs).

Re: [Tutor] list of dict question

2010-10-09 Thread Steven D'Aprano
On Sat, 9 Oct 2010 06:05:57 pm Francesco Loffredo wrote: > Alan's answer to Roelof made me think... I'm sorry, I don't know what your question is. You seem to have quoted various bits and pieces of text from earlier emails (text beginning with > signs). Apart from the sentence beginning with "Al

[Tutor] list of dict question

2010-10-09 Thread Francesco Loffredo
Alan's answer to Roelof made me think... On 08/10/2010 13.40, Francesco Loffredo wrote: Il 08/10/2010 10.02, Alan Gauld ha scritto: "Roelof Wobben" wrote I have this programm : tournooi = [{'thuis': 'A','uit': "B",'thuisscore': 20, 'uitscore': ... This was your answer to Roelof: On the

Re: [Tutor] list of dict question

2010-10-08 Thread Francesco Loffredo
Il 08/10/2010 10.02, Alan Gauld ha scritto: "Roelof Wobben" wrote I have this programm : tournooi = [{'thuis': 'A','uit': "B",'thuisscore': 20, 'uitscore': ... for wedstrijd in tournooi : if wedstrijd['thuis'] in stand : print "True" stand is a list of dictionaries so this will never be

Re: [Tutor] list of dict question

2010-10-08 Thread Roelof Wobben
> To: tutor@python.org > From: alan.ga...@btinternet.com > Date: Fri, 8 Oct 2010 09:02:05 +0100 > Subject: Re: [Tutor] list of dict question > > > "Roelof Wobben" wrote > >> I have this programm : >> >&

Re: [Tutor] list of dict question

2010-10-08 Thread Alan Gauld
"Roelof Wobben" wrote I have this programm : tournooi = [{'thuis': 'A','uit': "B",'thuisscore': 20, 'uitscore': 15},{'thuis': 'C','uit': "D",'thuisscore': 80, 'uitscore': 40}] stand = [] tussen_thuis = {} tussen_uit = {} Here you create your dictionary objects. You never create any more d

[Tutor] list of dict question

2010-10-08 Thread Roelof Wobben
Hello, I have this programm : tournooi = [{'thuis': 'A','uit': "B",'thuisscore': 20, 'uitscore': 15},{'thuis': 'C','uit': "D",'thuisscore': 80, 'uitscore': 40}] stand = [] tussen_thuis = {} tussen_uit = {} for wedstrijd in tournooi : if wedstrijd['thuis'] in stand : print "True"