Hello everyone, First, thank you all for this grea...
# prefect-community
a
Hello everyone, First, thank you all for this great software 🙂 It is really nice to use 🙂 I want to split the "result" of a task into 2 parts.
Copy code
@task
def return_2_values(x, y):
    return x, y

with Flow("lolilol") as flow:
    a, b = return_2_values(x=2, y=4)
But I can't because task are not iterable 😕 The only trick I found is to use a dictionary inside my task and then use GetItem. Unfortunaly, with this method, I need to know that is inside "return_values" at the level of the Flow in order to get the correct keys. Is there a way to do it without prior information on the task ? Like a normal python function 🙂
n
Hi @alexandre kempf! If I understand your problem correctly, you're having an issue where you need to return two pieces of data from a task and you need to know how to access them, correct?
j
Try something like this where you return as a single object and index accordingly:
Copy code
@task
def a():
    return 1, 2

with Flow('test') as flow:
    res = a()
    other_task(res[0])
    other_task(res[1])
upvote 2
a
Hi Nicholas 🙂 Correct 🙂
👍 1
Damned ! I was sure I tried this solution (which is the first thing I though about). Thank you guys 🙂
You have an amazing response time btw 😍
🚀 3
j
Haha anytime!
n
Let us know if you have any other questions! 😄