34
you are viewing a single comment's thread
view the rest of the comments
[-] sugar_in_your_tea@sh.itjust.works 2 points 5 months ago

The general form is:

(var := expression) rest of condition

So you can do something awful like this:

lambda: (y := 1) != 2 and y

Not sure if that's "good," but it does kind of let you sneak a statement into the lambda.

this post was submitted on 29 Apr 2024
34 points (100.0% liked)

Python

6284 readers
8 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS