SyntaxError: can't assign to a function call

Fuzzyman fuzzyman at gmail.com
Sun Feb 26 18:37:37 EST 2006


What gives ?

>>> a = []
>>> def f():
	return a

>>> f()
[]
>>> a.append(3)
>>> f()
[3]
>>> a += [3]
>>> a
[3, 3]
>>> f()
[3, 3]
>>> f() += [4]
SyntaxError: can't assign to function call
>>> 

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml




More information about the Python-list mailing list