"Fuzzyman" <[EMAIL PROTECTED]> wrote: > >Alex Martelli wrote: >> 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]) >> > >Cool, thanks. That's what I did, it's just not an error I'd seen >before. Everywhere else Python evaluates the function call and then >does it's stuff with the result.
One thing that can be helpful in situations like this is to remember that += in Python isn't quite as "special" as it is in C. So, f() += [4] is the same as f() = f() + [4] and I think you can see why that is a problem. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list