Re: about dictionary

2005-11-20 Thread Bengt Richter
On Sun, 20 Nov 2005 07:12:08 -0800, Shi Mu <[EMAIL PROTECTED]> wrote: >d is a dictionary. d >{0: [[0, 1], [0, 2]], 1: [[0, 1], [1, 2], [1, 3]], 2: [[0, 2], [1, 2], >[2, 3]], 3: [[1, 3], [2, 3]]} > >for the value under each key, if the possible connection is in the >dictionary, for example, un

Re: about dictionary

2005-11-20 Thread przemek drochomirecki
Uzytkownik "Shi Mu" <[EMAIL PROTECTED]> napisal w wiadomosci news:[EMAIL PROTECTED] On 11/20/05, przemek drochomirecki <[EMAIL PROTECTED]> wrote: > > Uzytkownik "Peter Otten" <[EMAIL PROTECTED]> napisal w wiadomosci > news:[EMAIL PROTECTED] > > Shi Mu wrote: > > > > > how to do with it? > > > > Us

Re: about dictionary

2005-11-20 Thread Shi Mu
On 11/20/05, przemek drochomirecki <[EMAIL PROTECTED]> wrote: > > Uzytkownik "Peter Otten" <[EMAIL PROTECTED]> napisal w wiadomosci > news:[EMAIL PROTECTED] > > Shi Mu wrote: > > > > > how to do with it? > > > > Use Ben Finney's, not Przemek's approach if the values are mutables that > you > > plan

Re: about dictionary

2005-11-20 Thread przemek drochomirecki
Uzytkownik "Peter Otten" <[EMAIL PROTECTED]> napisal w wiadomosci news:[EMAIL PROTECTED] > Shi Mu wrote: > > > how to do with it? > > Use Ben Finney's, not Przemek's approach if the values are mutables that you > plan to modify. If that's what you are asking. > > Peter Maybe he just want to use d

Re: about dictionary

2005-11-20 Thread Peter Otten
Shi Mu wrote: > how to do with it? Use Ben Finney's, not Przemek's approach if the values are mutables that you plan to modify. If that's what you are asking. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: about dictionary

2005-11-20 Thread Shi Mu
On 11/20/05, Peter Otten <[EMAIL PROTECTED]> wrote: > przemek drochomirecki wrote: > > > Uzytkownik "Shi Mu" <[EMAIL PROTECTED]> napisal w wiadomosci > > news:[EMAIL PROTECTED] > > I have have the following code: > a=[3,5,8,0] > b={} > > > How I can i assign each item in a as the key

Re: about dictionary

2005-11-20 Thread Peter Otten
przemek drochomirecki wrote: > Uzytkownik "Shi Mu" <[EMAIL PROTECTED]> napisal w wiadomosci > news:[EMAIL PROTECTED] > I have have the following code: a=[3,5,8,0] b={} > How I can i assign each item in a as the key in the dictionary b > simultaneously? > that is, > b={3:[],5:[],8:[]

Re: about dictionary

2005-11-20 Thread przemek drochomirecki
Uzytkownik "Shi Mu" <[EMAIL PROTECTED]> napisal w wiadomosci news:[EMAIL PROTECTED] I have have the following code: >>> a=[3,5,8,0] >>> b={} >>> How I can i assign each item in a as the key in the dictionary b simultaneously? that is, b={3:[],5:[],8:[],0:[]} Thanks! Other solution: b.fromkeys(a,

Re: about dictionary

2005-11-20 Thread Ben Finney
Shi Mu <[EMAIL PROTECTED]> wrote: > I have have the following code: > >>> a=[3,5,8,0] > >>> b={} > >>> > How I can i assign each item in a as the key in the dictionary b > simultaneously? > that is, > b={3:[],5:[],8:[],0:[]} Explicit: a = [3, 5, 8, 0] b = {} for key in a: b[ke

Re: about dictionary

2005-11-20 Thread Shi Mu
On 20 Nov 2005 02:59:30 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > b = dict([(x,dict()) for x in a]) > Shi Mu wrote: > > I have have the following code: > > >>> a=[3,5,8,0] > > >>> b={} > > >>> > > How I can i assign each item in a as the key in the dictionary b > > simultaneously? > > t

Re: about dictionary

2005-11-20 Thread [EMAIL PROTECTED]
b = dict([(x,dict()) for x in a]) Shi Mu wrote: > I have have the following code: > >>> a=[3,5,8,0] > >>> b={} > >>> > How I can i assign each item in a as the key in the dictionary b > simultaneously? > that is, > b={3:[],5:[],8:[],0:[]} > Thanks! -- http://mail.python.org/mailman/listinfo/pytho