Created
March 15, 2025 17:31
-
-
Save Tishka17/e06c1a25e7436092a5c889cc097e1459 to your computer and use it in GitHub Desktop.
Assignement modificator in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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