How to turn a list of tuples into a dictionary?

castironpi at gmail.com castironpi at gmail.com
Tue Feb 26 13:49:11 EST 2008


On Feb 26, 11:15 am, mrstephengross <mrstevegr... at gmail.com> wrote:
> > How about this?
> >   d = dict(tuples)
>
> Aha! I hadn't realized it could be so simple.
>
> --Steve

In terms of a metric for code, 'And runs in a single line!' may be a
bit deceptive.  [Counterexample snipped.]  Absent repeating the line
d= dict( tuples ) verbatim, how does:

identifiers: 3
- func. calls: 1
-- builtins: 1
-- call depth: 1
- assign't: 1
- variable: 1
nesting depth: 1
- parenthesis: 1
- control flow: 0
if statements: 0
- elifs: 0
- elses: 0
call tree: 0
- max. breadth: 1
-- per scope: 1
- max. depth: 1
-- per scope: 1

sound?



More information about the Python-list mailing list