What other languages use the same data model as Python?

Grant Edwards invalid at invalid.invalid
Tue May 3 12:52:26 EDT 2011


On 2011-05-03, Mel <mwilson at the-wire.com> wrote:

> To illustrate the neither-fish-nor-fowl nature of Python calls:
>
> mwilson at tecumseth:~$ python
> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
> [GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> def identify_call (a_list):
> ...   a_list[0] = "If you can see this, you don't have call-by-value"
> ...   a_list = ["If you can see this, you have call-by-reference"]
> ... 
>>>> my_list = [None]
>>>> identify_call (my_list)
>>>> my_list
> ["If you can see this, you don't have call-by-value"]
>
> so it's neither call-by-value nor call-by-reference as (e.g.) C or PL/I 
> programming would have it (don't know about Simula, so I am off topic, 
> actually.)  It's not so wrong to think of Python's parameter handling as 
> ordinary assignments from outer namespaces to an inner namespace.

As long as you think of "ordinary assignments" the Python way and not
the C or PL/I way. :)

-- 
Grant Edwards               grant.b.edwards        Yow! So this is what it
                                  at               feels like to be potato
                              gmail.com            salad



More information about the Python-list mailing list