On Feb 26, 11:15 am, mrstephengross <[EMAIL PROTECTED]> 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 t
> How about this?
> d = dict(tuples)
Aha! I hadn't realized it could be so simple.
--Steve
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 26 Feb 2008 09:00:54 -0800 (PST)
mrstephengross <[EMAIL PROTECTED]> wrote:
> Let's say I've got a list of tuples, like so:
>
> ( ('a', '1'), ('b', '2'), ('c', '3')
>
> And I want to turn it into a dictionary in which the first value of
> each tuple is a key and the second value is a val
mrstephengross <[EMAIL PROTECTED]> writes:
> ( ('a', '1'), ('b', '2'), ('c', '3')
I'm not trying to be snide, but have you tried looking in the manual?
See http://python.org/doc/lib and look at the section about built-in
types, if you want to know things about tuples or dictionaries.
--
http:/
On Feb 26, 11:00 am, mrstephengross <[EMAIL PROTECTED]> wrote:
> Let's say I've got a list of tuples, like so:
>
> ( ('a', '1'), ('b', '2'), ('c', '3')
>
> And I want to turn it into a dictionary in which the first value of
> each tuple is a key and the second value is a value, like so:
>
> { '
Let's say I've got a list of tuples, like so:
( ('a', '1'), ('b', '2'), ('c', '3')
And I want to turn it into a dictionary in which the first value of
each tuple is a key and the second value is a value, like so:
{ 'a' -> '1', 'b' -> '2', 'c' -> '3' }
Is there a way to do this with a single