why cannot assign to function call

Aaron Brady castironpi at gmail.com
Mon Dec 29 17:03:54 CET 2008

On Dec 29, 12:01 am, scsoce <scs... at gmail.com> wrote:
> I have a function return a reference, and want to assign to the
> reference, simply like this:
>  >>def f(a)
>           return a
>      b = 0
>     * f( b ) = 1*
> but the last line will be refused as "can't assign to function call".
> In my thought , the assignment is very nature,  but  why the interpreter
> refused to do that ?

'Why' is a long question.  The syntax has advantages and disadvantages
(pros and cons), which weigh different amounts in different
languages.  In Python, the cons weigh more.  In C, the pros weigh
more.  The short answer is, there is no such thing as assigning to
objects, only to variables.

You are talking like it could save you ten lines of code or something.

More information about the Python-list mailing list