[Python-ideas] Should this be considered a bug?

Nick Coghlan ncoghlan at gmail.com
Sun Oct 30 11:55:29 CET 2011


On Sun, Oct 30, 2011 at 8:29 PM, Mike Meyer <mwm at mired.org> wrote:
>
> h = [1, 2, 3]
> d = dict(a=1, b=2)
> h += d # works
> h = h + d # exception

No, the reason the latter fails is because it's unclear what the type
of the result should be and the interpreter refuses to guess. In the
former case, there's no such ambiguity (since the type of 'h' simply
stays the same).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list