Fuzzyman <[EMAIL PROTECTED]> wrote:

> What gives ?
   ...
> >>> a = []
> >>> def f():
>       return a
   ...
> >>> f() += [4]
> SyntaxError: can't assign to function call

Exactly what the error message says: it's syntactically forbidden to
perform any assignment on a function-call.

If you're keen on these semantics, use for example

f().extend([4])

which IS quite legal (or, if you know the RHS list has only one item,
f().append(4) is clearer and more effective).


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to