Skip to playerSkip to main content
  • 8 months ago
In Python, "scope" refers to the region of a program where a variable or function is accessible and visible. It determines where a variable can be used and which parts of the code can access it. Python's scope rules are governed by the LEGB rule, which dictates the order in which Python searches for names: Local, Enclosing, Global, and Built-in.

Category

📚
Learning
Transcript
00:00Local which you basically call my home function is my home function.
00:09Then it looks for the parent local.
00:15Then it looks into parents local.
00:22Then it looks in global scope.
00:31These three principles.
00:34Python local scope.
00:38Inner function.
00:39Then it looks in global scope.
00:43My parents home.
00:45Then it looks in global scope.
00:48Then it looks in global scope.
00:54Then it looks like a built-in function.
01:00Right?
01:01For example, this is a variable.
01:03I will return the phone.
01:04This is basically global scope.
01:06This is global scope.
01:11Let's call this parents scope.
01:17And this is basically local scope.
01:21You can remember it.
01:25Your home, parents' home and road.
01:28Road is global scope.
01:30Your home is local scope.
01:31Your home is in between.
01:33Your home is not found.
01:34Parents' home is found.
01:35Then you can see it.
01:36Then you can see it.
01:37Then you can see it.
01:38Python also follows this rule.
01:40Imagine that your phone is found in global scope.
01:45I will take a function.
01:46Let's call it max.
01:48Max function.
01:49Max value returns.
01:51Okay?
01:52Now max is a built-in function.
01:55This is a built-in function.
01:56Because this is a color change.
01:58Now max is not in local scope.
02:01You can see it.
02:02You can see it.
02:03You can see it.
02:04You can see it.
02:05You can see it.
02:06You can see it.
02:07You can see it.
02:08Now Passive is not behind.
02:09You can see its parents withמה.
02:10today.
02:11So what �
02:33mila तो फिर python की जो
02:35installation करते वक्त जो libraries
02:37आपने install की थी या already उसके साथ
02:39install हुई ही थी तो क्यों ना उन में
02:41देखा जाए उन में कोई तो ऐसा को function exist
02:43नहीं करता तो चलिए अब देखते हैं
02:45क्योंकि ये उसमें exist करता है तो ये हमें इसका
02:47memory address हो करेगा कहेगा यार ये function
03:03नहीं मिली तो फूर्थ टाइम उसने built-in function
03:06देखा मिली तो फूर्थ टाइम उसने built-in function
03:09देखा और उसको built-in function मिल गया उसने कहा ये जी built-in function
03:12है excellent
Be the first to comment
Add your comment

Recommended