TGViewer
Python Tasks & ML | Задачи по питону и машинному обучению Python Tasks & ML | Задачи по питону и машинному обучению @python_tasks · 8.52K subscribers
Post #3220 1.03K
Что выведет код?
def f():
import sys
locs = sys._getframe(1).f_locals
setattr(locs['self'], 'xy', 4*locs['x'] + 7*locs['y'])

class A:
def __init__(self, x, y):
self.xy = 2*x + 3*y
f()

a = A(2, 3)
A.xy = 99
print(a.xy)
More from @python_tasks
  1. May 25, 2026Post #3221
  2. May 22, 2026Post #3219
  3. May 22, 2026Что выведет код? def f(x): if x < 3: return x y = filter(f, (0, 1, 2, 3, 4)) print(list(y)…
  4. May 21, 2026Post #3217
  5. May 21, 2026Что выведет код? def func(x): if x >= 3: return x y = filter(func, (1, 2, 3, 4)) print(lis…
  6. May 20, 2026Post #3215
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →