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 →
← CoursesFastAPI ProductionModule 6 · Real-World PatternsDependency scopespredict102 / 105
+125 XP
Task
📝 **Task:** Predict the output. The script simulates two requests: each calls `get_pool()` and `get_request_id()`. Pool is a module-level singleton; request_id is constructed fresh per call. Equality is checked with `is`. 📋 Implement the function above. Tests run automatically. 💡 **Hint:** Re-read the theory if stuck.
Predict the output

Read the code carefully

class Pool:
    pass

shared_pool = Pool()

def get_pool():
    return shared_pool

def get_request_id():
    return object()

p1 = get_pool()
r1 = get_request_id()
p2 = get_pool()
r2 = get_request_id()

print(p1 is p2)
print(r1 is r2)
print(type(p1).__name__)

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…