On Thu, 30 Jun 2022 at 02:49, Johannes Bauer wrote:
> But now consider what happens when we create the lambdas inside a list
> comprehension (in my original I used a generator expresison, but the
> result is the same). Can you guess what happens when we create conds
> like this?
>
> conds = [ lamb
You also forgot to include any information about an error or problem you
got in using this code.
We can't help you if you don't have an actual question to ask.
On Wed, Jun 29, 2022 at 1:36 AM נתי שטרן wrote:
> Sorry but i forgor to delete this token data
>
> בתאריך יום שלישי, 28 ביוני 2022
Or you could try this as an alternative:
conds = [ (lambda code: lambda msg: msg.hascode(code))(z) for z in
("foo", "bar") ]
Op 29/06/2022 om 12:43 schreef Johannes Bauer:
Aha!
conds = [ lambda msg, z = z: msg.hascode(z) for z in ("foo", "bar") ]
Is what I was looking for to explicitly use
Hi list,
I've just encounted something that I found extremely unintuitive and
would like your feedback. This bit me *hard*, causing me to question my
sanity for a moment. Consider this minimal example code (Py 3.10.4 on
Linux x64):
class Msg():
def hascode(self, value):
p
Aha!
conds = [ lambda msg, z = z: msg.hascode(z) for z in ("foo", "bar") ]
Is what I was looking for to explicitly use the value of z. What a
caveat, didn't see that coming.
Learning something new every day.
Cheers,
Joe
Am 29.06.22 um 11:50 schrieb Johannes Bauer:
> Hi list,
>
> I've just en