Lambda returning tuple question, multi-expression

Cameron Simpson cs at cskk.id.au
Thu Mar 9 16:31:42 EST 2023


On 09Mar2023 09:06, Alan Gauld <learn2program at gmail.com> wrote:
>On 08/03/2023 21:56, aapost wrote:
>> When making a UI there are a lot of binding/trace operations that need
>> to occur that lead to a lot of annoying 1 use function definitions. I
>> don't really see lambda use like below.
>
>Lambdas are very common in GUI callbacks but I admit I've never seen
>tuples used to create multiple expressions. That's a neat trick I
>hadn't thought of and will probably use.

I often uses as a debugging hack. Given:

     foo=lambda: expr

I'll often write:

     foo=lambda: (X("foo happening here!"), ...maybe more..., expr)[-1]

to embed some debug tracing in a lambda defined expression.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list