What other languages use the same data model as Python?

Devin Jeanpierre jeanpierreda at gmail.com
Wed May 4 05:56:28 EDT 2011


> 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.
>
>         Mel.

Eh, that example doesn't say what you think it does. It has the same
behavior in C: http://ideone.com/Fq09N . Python is pass-by-value in a
meaningful sense, it's just that by saying that we say that the values
being passed are references/pointers. This is maybe one level of
abstraction below what's ideal, but Scheme, Java, etc. share this
terminology. (Ruby calls it pass-by-reference AFAIK. Whatever, a rose
by any other name...)

Devin Jeanpierre



More information about the Python-list mailing list