Amit Aronovitch wrote:

>Typically, the instructor would say (or imply) something like:
>
> * Variables are named areas of memory storing data of some type.
> * Pointers are variables storing memory addresses of other variables.
> * Python works by reference. This means that variables are actually
>   implemented as pointers (i.e. store memory addresses), but the language
>   does implicit dereference whenever they appear in expressions (i.e.
>   operations other than assignment work on the area pointed to by the
>pointer
>   rather than the pointer itself).
>
>  
>
Just emphasizing the importance of the phrase "other than assignment" above:

Fortran, for example, uses "by reference" arguments passing, but it's
variable concept is much the same - the assignment operator works on the
*value* rather than the pointer (i.e. doing a=b you get a *copy* of b).

In other words - "python vars" vs "common vars" is not the same as "by
reference" vs "by value".

לענות