Can Python function return multiple data?

random832 at fastmail.us random832 at fastmail.us
Thu Jun 4 13:26:15 EDT 2015


On Thu, Jun 4, 2015, at 09:47, Steven D'Aprano wrote:
> 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.

Well, no, because, in Java, if the type of x is int, then the value
really is 23. If it's Integer, then it's a reference to a boxed Integer
object. Which is (thankfully) immutable. But isn't invisible, unknown,
or unknowable at all.

Of course, in CPython, the type of an object reference is PyObject *.
Which isn't invisible, unknown, or unknowable, either.

If the value really were 23, the "is vs ==" problem wouldn't exist.

x = 500
y = x+1
z = y-1

x and z (probably) point to two different objects.



More information about the Python-list mailing list