Getting Started
Wish brings selectable return values to Python.
Overview¶
It's already very easy to deal with functions having several possible sets of arguments in Python. Why? Because the language supports natively:
Now for return values, beyond tuples to deal with multiple values, Python provides actually little constructs. Using functions that return many values is often tedious. Wish provides selectable return values to solve this issue.
Quickstart¶
-
Install wish with pip (instructions).
-
Replace your function with many arguments
f
def f(...): ... return a, b, c, ..., z
with
import wish def f(..., returns="a, b"): ... return wish.grant(returns)
-
Update the documentation of your function
Parameters:
-
...
-
returns
: string, optional. Select the returned values, amonga
,b
, ...,z
. Default is"a, b"
.
Returns:
-
a
: ... -
b
: ... -
c
: ..., not returned by default -
...
-
z
: ..., not returned by default
-
-
Use the flexibility of the new API
>>> a, b = f(...) >>> w, i, s, h = f(..., returns="w, i, s, h")