Can Python function return multiple data?

Alain Ketterlin alain at universite-de-strasbourg.fr.invalid
Fri Jun 5 02:59:54 EDT 2015


Steven D'Aprano <steve at pearwood.info> writes:

> On Fri, 5 Jun 2015 04:17 am, Alain Ketterlin wrote:
>
>> Steven D'Aprano <steve at pearwood.info> writes:
>> 
>> [...]
>>> But you still find a few people here and there who have been exposed to
>>> Java foolishness, and will argue that Python is "pass by value, where the
>>> value is an implementation dependent reference to the thing that you
>>> thought was the value".
>> 
>> I find this clear and concise. Can you exhibit an example that would not
>> match this description?
>> 
>>> In other words, according to this Java philosophy, following `x = 23`,
>>> the value of x is not 23 like any sane person would expect, but some
>>> invisible and unknown, and unknowable, reference to 23.
>> 
>> No, Java doesn't work like that for primitive types (assuming that by
>> "Java" you mean the language and execution environment defined in
>> reference documents).
>
> Perhaps the fact that I used Python syntax was too ambiguous <wink> but I
> was talking about Python. However, the same applies to Java, if you
> substitute an object for the primitive value:
>
>     Integer x = new Integer(23);
>
> According to the Java philosophy, the value of x is not the object
> Integer(23) like any sane person would expect,

Yes, clear (except for sanity).

> but some invisible and unknown reference to that object.

I think Python does exactly this (Grant Edwards has a good explanation
of it els ethread).

At least, that is how I understand it, and that is how I teach it, and I
have never met a single case where it failed to describe and explain the
actual behavior of the program.

That's why I was asking for an example to motivate your claim on sanity.

-- Alain.



More information about the Python-list mailing list