Am 05.10.2011 15:33, schrieb faucheuse:
I was wondering something :
when you do : return value1, value2, value3
It returns a tuple.

Right.

So if I want to pass these value to a function, the function have to
look like :
def function(self,(value1, value2, value3))
[...]

No, you don't have to, but you can:

# example functions
def fni():
    return 1, 2
def fno(v1, v2):
    pass

# store result in a tuple and unpack tuple for function call
t = fni()
fno(*fni)

# store results in individual values
v1, v2 = fni()
fno(v1, v2)


Note that the first variant can be written in a single line, too. A completely different alternative is passing a tuple to the function as a single parameter. You can then access the elements using normal tuple indexing. That said, I don't see a problem with your syntax, except that it's a bit unusual.


Welcome to Python!

Uli
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to