I was just running some code I had written for a learning exercise and suddenly ran into an error "SyntaxError: invalid syntax", from eval("alist += [foo]"). To try and understand I just made a simple module:
a = 5
eval("a += 1")
print(a)
and indeed it gives the same error, even when I just ran the first 2 lines directly into the Python console. Now I've only been doing Python a few days so I'm no expert but I'm 99% sure this should just work. a+=1 works. exec("a+=1") works. But eval("a+=1") does not, nor does eval("a-=1").
Am I doing something wrong? Is eval() not supposed to have this += function? Are others able to do this, and it's some issue with my own Python? Do I have some really strange setting on?