[New-bugs-announce] [issue39964] adding a string to a list works differently with x+='' compared to x=x+''

Richard King report at bugs.python.org
Sat Mar 14 23:19:20 EDT 2020


New submission from Richard King <rickbking at comcast.net>:

x = ['a']

x += ' ' results in ['a',' ']

x = x + ' ' results in an exception:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: can only concatenate list (not "str") to list

It behaves the same in 2.7.15 and 3.7.2.

----------
components: Windows
messages: 364213
nosy: paul.moore, rickbking, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: adding a string to a list works differently with x+='' compared to x=x+''
type: behavior
versions: Python 2.7, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39964>
_______________________________________


More information about the New-bugs-announce mailing list