Skip to content

Instantly share code, notes, and snippets.

@Tishka17
Created March 15, 2025 17:31
Show Gist options
  • Save Tishka17/e06c1a25e7436092a5c889cc097e1459 to your computer and use it in GitHub Desktop.
Save Tishka17/e06c1a25e7436092a5c889cc097e1459 to your computer and use it in GitHub Desktop.
Assignement modificator in python
# logic
MOD x = y
x = MOD.__transform__(t"{y}") # lazy evaluation
x = MOD(y) # general case
# unpack
MOD1 x, MOD2 y = z
_x, _y = z
x = MOD1(x), MOD2(y)
# for loop
for MOD1 x, MOD2 y in z:
...
for x, y in z:
x = MOD1(x)
y = MOD2(y)
...
# function definition
def foo(MOD x):
pass
def foo(x):
x = MOD(x)
# class property definition
class A:
MOD x
class A:
def __setattr__(self, name, value):
if name == "x":
value = MOD(value)
super().__setattr__(name, value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment