Към основното съдържание
🔒 Режим за преглед. Първите петнадесет урока на Foundations са безплатни; този е Pro. Стартирайте 7-дневен trial, за да отключите редактора, AI подсказките и останалата част от курса. Изисква се карта, отменете по всяко време в Dashboard.Стартирай 7-дневен trial →
← КурсовеSenior Deep-DivesМодул 1 · Паралелност и асинхронни вътрешни елементиДескрипториpredict6 / 161
+100 XP
Задача🌐 shown in EN
📝 **Task:** Predict the exact output. The \`Tracker\` descriptor prints on bind / get / set. Three things to think about: (1) When does \`__set_name__\` run? (2) Does \`b.x = 10\` go through \`__set__\`? (3) When \`total = b.x + b.y\` runs, which calls fire and in what order? 📋 Implement the function above. Tests run automatically. 💡 **Hint:** Re-read the theory if you get stuck.
Предскажи изхода

Прочети кода внимателно

class Tracker:
    def __set_name__(self, owner, name):
        self.name = name
        print(f"bind:{name}")
    def __get__(self, instance, owner):
        if instance is None:
            return self
        print(f"get:{self.name}")
        return instance.__dict__.get(self.name, 0)
    def __set__(self, instance, value):
        print(f"set:{self.name}={value}")
        instance.__dict__[self.name] = value


class Box:
    x = Tracker()
    y = Tracker()


b = Box()
b.x = 10
b.y = 5
total = b.x + b.y
print(total)

Какво ще изведе програмата? Напиши тук: