← Back to Python

LEGB Rule

Pythonpython

The Question

What is the LEGB rule in Python's scope resolution?

What a Strong Answer Covers

  • L-E-G-B in order
  • "nonlocal
  • "global
  • "closure

Related Questions

  • GIL — What It Is and What It Protects
  • ThreadPoolExecutor & ProcessPoolExecutor
  • Decorators — Under the Hood
  • Generators & yield
  • Context Managers

Practice This Question

Get AI-graded feedback on your answer with follow-up probes on weak points.

Take the Free Assessment
GrindQuestionsAITechnical interview assessment
TermsPrivacyAbout