Re: Basic list/dictionary question

2009-11-11 Thread Daniel Jowett
Thanks Chris, yes it's becoming clearer now. And defaultdict looks nice - unfortunately I'm stuck to python 2.4 as I'm using Plone. Thanks again, Daniel 2009/11/11 Chris Rebert > On Wed, Nov 11, 2009 at 4:16 AM, Daniel Jowett > wrote: > > Greetings, > > &

Basic list/dictionary question

2009-11-11 Thread Daniel Jowett
;, 'pear', 'orange', 'banana'], 'banana': ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']} >>> >From what I can work out, there is only ONE list that is referenced from the dictionary 4 times. Which would be because the *same empty list* is assigned to every key in the dictionary by the "fromkeys" line. But that seems *seriously *counter-intuitive to me... Would anyone beg to differ and try to rewire my thinking? (I'm from a Java background if that helps) I've already solved the problem a different way, but I am concerned about this counter-intuitiveness as I see it. rgds, Daniel Jowett -- http://mail.python.org/mailman/listinfo/python-list