Saved Bookmarks
| 1. |
Explain LEGB rule. |
|
Answer» LEGB rule: when a name is encountered during the execution of the program, it searches for that name in the following order: L. Local – It first makes a local search, i.e. in a current def statement. E. Enclosing functions – It searches in all enclosing functions, from inner to outer. G. Global (module) – It searches for global modules or for names declared global B. Built-in (Python) – Finally it checks for any built-in functions in Python. |
|