Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesSenior Deep-DivesModule 6 · FAANG-2026 deep divesDescriptor lookup order — data vs non-datapredict106 / 161
+150 XP
Task
📝 **Task:** Predict the exact output. Two descriptors: \`DataDesc\` defines both \`__get__\` AND \`__set__\` (data descriptor); \`NonDataDesc\` defines only \`__get__\` (non-data). Both are class attributes on \`Holder\`. Then the test sneaks values into the instance's \`__dict__\` directly — bypassing the descriptor protocol. Which one wins for \`h.d\` and which for \`h.n\`? 📋 Implement the function above. Tests run automatically. 💡 **Hint:** Re-read the theory if you get stuck.
Predict the output

Read the code carefully

class DataDesc:
    def __get__(self, instance, owner):
        print("data:get")
        return 1
    def __set__(self, instance, value):
        print(f"data:set:{value}")


class NonDataDesc:
    def __get__(self, instance, owner):
        print("nondata:get")
        return 2


class Holder:
    d = DataDesc()
    n = NonDataDesc()


h = Holder()
h.__dict__["d"] = "shadow_d"
h.__dict__["n"] = "shadow_n"

print(h.d)
print(h.n)

What will the program print? Write here:

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…