Using generator expressions

Chris Angelico rosuav at gmail.com
Mon Sep 25 11:42:27 EDT 2023


On Tue, 26 Sept 2023 at 01:39, Jonathan Gossage via Python-list
<python-list at python.org> wrote:
>
> Many thanks, all. It turned out that my problem was not fully understanding
> the use and power of the unpack operator *. Using it to activate my
> generator made things start to work. I changed the line where I invoked the
> generator to:
>     y = test1(*(a for a in st))
>
> adding the unpack operator.
>

You could simplify this with just the unpacking:

y = test1(*st)

ChrisA


More information about the Python-list mailing list