list to dict

Matteo Dell'Amico della at toglimi.linux.it
Thu Jun 17 13:31:19 EDT 2004


Denis S. Otkidach wrote:
> On Wed, 16 Jun 2004, Yermat wrote:
> Y>  >>> dict([(1,'a'),(2,'b')])
> Y> {1: 'a', 2: 'b'}
> Y>
> Y> list of tuples -> dict !
> 
> But unfortunately list({1: 'a', 2: 'b'}) -> [1, 2].

That's because it's coherent with what happens with iter(lst), I think.

Anyway, {1: 'a', 2: 'b'}.items() -> [(1, 'a'), (2, 'b')].

-- 
Ciao,
Matteo



More information about the Python-list mailing list