Are multiple return values really harmful? (Re: determining the number of output arguments)

Neil Hodgson nhodgson at bigpond.net.au
Wed Nov 17 15:47:38 EST 2004


Greg Ewing:

> Maybe things would be better if we had "dict unpacking":
>
>    a, c, b = {'a': 1, 'b': 2, 'c': 3}
>
> would give a == 1, c == 3, b == 2. Then we could
> accept outputs by keyword as well as inputs...

    Tuple returns do seem trickier than multiple arguments, partly due to
being more novel for me and partly because the function definition does not
document the tuple in code, although there is often a comment. Perhaps
something like:

def Transform(filename) -> (share, permissions, lock):
...
    return (s, p, l)
...
(s=share, p=permissions) = Transform(name)

   Neil





More information about the Python-list mailing list