passing by refference

Joshua Marshall joshway_without_spam at myway.com
Fri May 16 07:17:38 EDT 2003


David Abrahams <dave at boost-consulting.com> wrote:
> Doug Quale <quale1 at charter.net> writes:

>> If Python is not call-by-value, what is an r-value in Python that
>> differs from what is passed to a function?

> I should probably stay out of this, but...

> it doesn't make a whole lot of sense to talk about r-values and
> l-values in Python, because those terms are normally defined in terms
> of assignment:

>    "an r-value is something that can appear on the right hand side of
>    an assignment"

>    "an l-value is something that can appear on the left hand side of
>    an assignment"

> In Python, the only things that can appear on the LHS of an assignment
> are names (not values in any reasonable sense).

This isn't true.  Expressions like "X", "(A, B)", and "A[i]" can be
l-values or r-values, depending on the context--whether they're on the
left side of an assignment or not.  Expressions like "2", "()", and
"f(1)" can only br r-values (you can't assign to them).

The terms "l-value" and "r-value" apply to any language which has assignment.




More information about the Python-list mailing list