Tuple unpacking inside lambda expressions

Sam Ezeh sam.z.ezeh at gmail.com
Sat Apr 16 17:36:04 EDT 2022


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


More information about the Python-list mailing list