TechToFreedom
Published in

TechToFreedom

Master Python Scope by the LEGB Rule

Master Python Scope by the LEGB Rule
Photo by Angela Compagnone on Unsplash

Introduction

The variables scope (or namespace) is a very fundamental concept in programming languages. Every developer, no matter which language he or she is using, knows the definition of local and global variables. However, things become a little complicated in Python. Following questions appeared lots of times in interviews for Python developers:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store