[Python-ideas] [Python-Dev] hello, new dict addition for new eve ? (original) (raw)

Robert Kern robert.kern at gmail.com
Tue Jan 3 19:58:46 CET 2012


On 1/3/12 6:55 PM, Joshua Landau wrote:

On 3 January 2012 18:45, Robert Kern <robert.kern at gmail.com_ _<mailto:robert.kern at gmail.com>> wrote:

[~] |7> a = {'one': 1} [~] |8> b = {'one': '1'} [~] |9> set(a.items()) | set(b.items()) set([('one', '1'), ('one', 1)]) [~] |10> dict(set(a.items()) | set(b.items())) {'one': 1}

I don't know what you've done here: >>> a = {'one': 1} >>> b = {'one': 1} >>> set(a.items()) | set(b.items()) {('one', 1)} >>> dict(set(a.items()) | set(b.items())) {'one': 1} >>>

Sorry, I was a little too clever for my own good:

a = {'one': 1} b = {'one': '1'}

The first has the integer 1; the second has the string '1'.

-- Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco



More information about the Python-ideas mailing list