I went back to the code recently and I remembered what the problem was.

I was using multiprocessing.Pool.pmap which takes a callable (the
lambda here) so I wasn't able to use comprehensions or starmap

Is there anything for situations like these?

Kind Regards,
Sam Ezeh

On Sat, 16 Apr 2022 at 22:36, Sam Ezeh <sam.z.e...@gmail.com> wrote:
>
> Two questions here.
>
> Firstly, does anybody know of existing discussions (e.g. on here or on
> python-ideas) relating to unpacking inside lambda expressions?
>
> I found myself wanting to write the following.
>
> ```
> map(
>     lambda (module, data): result.process(module, data),
>      jobs
> )
> ```
> However, it's of course not legal Python syntax.
>
> The following were potential options but I felt they removed some of
> the meaning from the code, making it less understandable for other
> people.
>
> ```
> map(
>     lambda job: result.process(job[0], job[1]),
>      jobs
> )
> ```
>
> ```
> map(
>     lambda job: result.process(*job),
>     jobs
> )
> ```
>
> Secondly, for situations like these, do you have any go-to methods of
> rewriting these while maintaining clarity?
>
> Kind Regards,
> Sam Ezeh
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to