On 03.06.15 02:56, Chris Angelico wrote:
On Wed, Jun 3, 2015 at 7:27 AM, fl <rxjw...@gmail.com> wrote:
I just see the tutorial says Python can return value in function, it does
not say multiple data results return situation. In C, it is possible.
How about Python on a multiple data return requirement?
Technically, neither C nor Python can return multiple values from a
single function call. In Python, the most common way to do this is to
return a tuple, which can then be unpacked; as other posts in this
thread have shown, this can look a lot like returning multiple values,
and it's pretty convenient. In C, the nearest equivalent is passing a
number of pointers as parameters, and having the function fill out
values. Python's model is a lot closer to what you're saying than C's
model is :)
Closer modeling of C's model in python is to pass an object or a list as
an argument and set their attributes or elements in the function.
def f(a, b):
a.x = 4.3
a.y = 1.7
b[:] = [45, 67]
return 3
--
https://mail.python.org/mailman/listinfo/python-list