78
Python f-string quiz (fstrings.wtf)
you are viewing a single comment's thread
view the rest of the comments
[-] kryptonianCodeMonkey@lemmy.world 2 points 4 months ago* (last edited 4 months ago)

Walrus operator does an inline assignment to a variable and resolves to the value assigned. If it is in a condition statement, like "if x := y:", it assigns the value of y to x then interprets the expression of the condition as of it just said "if x:". Functionally, that means the assignment happens regardless of the value of y, but the condition only passes if the value of y is "truthy", i.e. if it's not None, an empty collection, numerically equal to zero, or just False.

this post was submitted on 26 Jul 2025
78 points (97.6% liked)

Python

7618 readers
41 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 2 years ago
MODERATORS