botify-labs / simpleflow

Python library for dataflow programming.
https://botify-labs.github.com/simpleflow/
MIT License
68 stars 24 forks source link

canvas: support comprehension list in Group #361

Closed pcaneill closed 5 years ago

pcaneill commented 5 years ago

Bring support for comprehension list in the Group canvas.

It is now possible to write:

Group(
    [ActivityTask(to_string, arg=i) for i in range(0, 2)]
)
ybastide commented 5 years ago

One can currently write

Group(
     *[ActivityTask(to_string, arg=i) for i in range(0, 2)]
)

(the * operator converts the list into a variable length argument tuple; the Group constructor receives this tuple as *activities, which is passed to extend and iterated over. This is more or less well described at Arbitrary Argument Lists and Unpacking Argument Lists in the documentation)

pcaneill commented 5 years ago

lets use *