Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Erik
On 18/10/15 21:38, Denis McMahon wrote: I'm not sure I understand why after m = deepcopy(l); m.remove(i); m is a different value to that which it as after m = deepcopy(l).remove(i). It's because list.remove() returns None, not 'self'. E. -- https://mail.python.org/mailman/listinfo/python-list

Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Denis McMahon
On Sun, 18 Oct 2015 20:38:26 +, Denis McMahon wrote: > On Sun, 18 Oct 2015 03:17:18 -0700, Beppe wrote: > >> hi to everybody, I must turn a tuple of lists into a dictionary. > > I went down a different path to Peter, and discovered something > perplexing: I just realised staring at it again

Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Denis McMahon
On Sun, 18 Oct 2015 03:17:18 -0700, Beppe wrote: > hi to everybody, I must turn a tuple of lists into a dictionary. I went down a different path to Peter, and discovered something perplexing: This failed: d = { i: deepcopy(l).remove(i) for l in t for i in l } So I tried to expand it out to se

Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Beppe
Il giorno domenica 18 ottobre 2015 14:47:34 UTC+2, Peter Otten ha scritto: > Beppe wrote: > > > Il giorno domenica 18 ottobre 2015 13:00:44 UTC+2, Peter Otten ha scritto: > >> Beppe wrote: > >> > >> > hi to everybody, I must turn a tuple of lists into a dictionary. > >> > > >> > something like >

Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Peter Otten
Beppe wrote: > Il giorno domenica 18 ottobre 2015 13:00:44 UTC+2, Peter Otten ha scritto: >> Beppe wrote: >> >> > hi to everybody, I must turn a tuple of lists into a dictionary. >> > >> > something like >> > >> > (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', 'n', 'o']) >> > >>

Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Beppe
Il giorno domenica 18 ottobre 2015 14:35:53 UTC+2, Chris Angelico ha scritto: > On Sun, Oct 18, 2015 at 11:23 PM, Beppe wrote: > > hi Peter, you are right, no duplicates are admitted between lists, > > anyway your solution,works on python 3 but not on 2. > > however beautiful list comprehension so

Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Chris Angelico
On Sun, Oct 18, 2015 at 11:23 PM, Beppe wrote: > hi Peter, you are right, no duplicates are admitted between lists, > anyway your solution,works on python 3 but not on 2. > however beautiful list comprehension solution. > I will try to suit it for the python version i need Should work fine on 2.7

Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Beppe
Il giorno domenica 18 ottobre 2015 13:00:44 UTC+2, Peter Otten ha scritto: > Beppe wrote: > > > hi to everybody, I must turn a tuple of lists into a dictionary. > > > > something like > > > > (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', 'n', 'o']) > > > > note that the length af

Re: Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Peter Otten
Beppe wrote: > hi to everybody, I must turn a tuple of lists into a dictionary. > > something like > > (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', 'n', 'o']) > > note that the length af each list is variable > > must return > > a ['b', 'c', 'd', 'e', 'f'] > b ['a', 'c', 'd',

Converting tuple of lists of variable length into dictionary

2015-10-18 Thread Beppe
hi to everybody, I must turn a tuple of lists into a dictionary. something like (['a', 'b', 'c', 'd', 'e', 'f'], ['g', 'h', 'i'], ['l', 'm', 'n', 'o']) note that the length af each list is variable must return a ['b', 'c', 'd', 'e', 'f'] b ['a', 'c', 'd', 'e', 'f'] c ['a', 'b', 'd', 'e', 'f']