What is Scope in Python??

  Рет қаралды 54,496

b001

b001

Күн бұрын

Пікірлер: 62
@chsh9993
@chsh9993 11 ай бұрын
Your explanation of coding is truly ingenious. Suddenly, all those encrypted coding lines aren't that confusing anymore.
@MoonFrogg
@MoonFrogg Жыл бұрын
these are VERY important things to learn, love the video and thanks for the clear + concise explanation!!
@AntonioZL
@AntonioZL Жыл бұрын
2:34 while this is indeed obvious for anyone experienced with interpreted languages, it could be confusing for begginers coming from compiled languages, like C, which is quite commonly used in intro to programming classes, so it's worth to point it out.
@epsi
@epsi Жыл бұрын
I think you meant it's obvious for anyone experienced with compiled languages. Some interpreted languages like JavaScript, awk, various BASIC dialects, and some flavors of shell script do not require variables to be defined before they are used. I've never encountered a compiled language that allows you to use a variable without first defining it.
@aliplayer1
@aliplayer1 Жыл бұрын
Love the videos. Concise yet full of information for new learners. Thanks.
@曾忠凱
@曾忠凱 Жыл бұрын
Man your video really helps. I couldn't understand the explanation on the official doc. Tyvm!
@NickWrightDataYT
@NickWrightDataYT Жыл бұрын
Great stuff! Good to learn more about how Python "thinks" lol
@birzhanabdikhan8175
@birzhanabdikhan8175 Жыл бұрын
1:37 by first-indentation he means that variable was defined outside of classes and functions. This part confused me too because I though that he meant 1st line.
@soniablanche5672
@soniablanche5672 11 ай бұрын
I knew of "global", but I didn't know about "nonlocal"
@harshaljani2266
@harshaljani2266 3 ай бұрын
If there were 4 functions nested then would there be a way to access the 2nd function’s variable in the innermost 4th function?
@eric_d
@eric_d Жыл бұрын
I didn't participate in the poll, but from very recent experience I knew it would be an error as soon as I looked at it. A couple weeks ago I was working on a script where I wanted to redefine a global variable, but I didn't use global inside the function. What's even weirder is I tried doing it with 2 different variables, and only the second one gave an error. The first variable was redefined, and printed what I was expecting, but then I got the error when trying to print the second variable. This may be a bug in Python 3.10 that I need to further explore.
@LilJollyJoker
@LilJollyJoker 11 ай бұрын
Thank you for this video!
@SusanAmberBruce
@SusanAmberBruce Жыл бұрын
Probably one of the most important videos to watch if someone is new to python
@porlando12
@porlando12 Жыл бұрын
Wow this was awesome. Your channel is criminally underrated!
@FocusProj
@FocusProj Ай бұрын
Very applied learning! Thank you!
@naifal-ghamdi483
@naifal-ghamdi483 Жыл бұрын
Best scope explanation ever, many thanks to you
@montagetm
@montagetm Жыл бұрын
What if you want to reference a local variable two scopes out, how would you do that? Nonlocal only references the previous scope and global only references the global scope.
@epsi
@epsi Жыл бұрын
def outer(): x = 1 def inner(): # x = 2 def func(): nonlocal x # refers to x=1 If you uncomment the x=2 line, you'd be referencing that x variable instead, and you'd be forced to rename one of those two x variables to be able to reference both of them. The nonlocal keyword is kind of a hack because Python is designed in a way that it prefers creating shadowed variables instead of unexpectedly modifying variables from outside scopes. Unfortunately, that means you encounter variable shadowing issues more frequently if you don't name things uniquely enough, along with the surprising error that is the answer to the poll question.
@montagetm
@montagetm Жыл бұрын
@@epsi so the only way is basically to rename them or remove them
@epsi
@epsi Жыл бұрын
@@montagetm Yes, but that's true for any other language as well. Variable shadowing: just don't do it.
@nadiaezzarhouni300
@nadiaezzarhouni300 Жыл бұрын
Bro you are insane, can you do a python course , by the way where do you get all this knowledge
@bab4953
@bab4953 11 ай бұрын
ur channel deserves more subs. Your content is amazing👍
@mind_of_a_darkhorse
@mind_of_a_darkhorse Жыл бұрын
Great explanation of scope! You made it very easy to understand!
@BiyHappy
@BiyHappy Жыл бұрын
Thanks man what a smooth explanation
@mossdem
@mossdem Жыл бұрын
Could you do a video which does a clear breakdown of classes?
@SHAYANGUHA
@SHAYANGUHA 5 ай бұрын
really informative 😍😍😍😍😍
@yazanabdoush7030
@yazanabdoush7030 8 ай бұрын
Can you share what color theme you are using?
@killerboyak
@killerboyak 10 ай бұрын
Amazing Explanation , Thank you.
@tobiasm161
@tobiasm161 Жыл бұрын
Great explanation with examples ! Bravo I would love to see kind a approach about OOP. Because sometimes there is an overkill to use it. But otherwise its good practice i think. What do you think or whats your approach. I tend to do less OOP cause often "one time" use of my scripts
@yaraa.a5237
@yaraa.a5237 11 ай бұрын
the music is fire it got me dancing. and it remind me of minecraft
@alanlado1602
@alanlado1602 Жыл бұрын
I like the way you explain things. Subscribe button smashed.
@samsungcurved
@samsungcurved 3 ай бұрын
Which theme you are using?
@adammarley5616
@adammarley5616 11 ай бұрын
Beautifully taught!
@elancedin7204
@elancedin7204 Жыл бұрын
bro literally did a few vids and already 82k subs, gut 4 u
@vuIent
@vuIent Жыл бұрын
Good video
@OsirisRD
@OsirisRD Жыл бұрын
what is your theme vscode ?
@Joe_Brig
@Joe_Brig Жыл бұрын
2:30 not obvious if you coming from a compiled language.
@saadqayyum4739
@saadqayyum4739 Жыл бұрын
i though python was interpreded so it reads code line by line, shouldn't it print x and then make a local variable x instead of giving error
@faisal99129
@faisal99129 Жыл бұрын
very good explanation... very helpful
@xcc4010
@xcc4010 Жыл бұрын
What is the name of the theme?
@KrAsHeDD
@KrAsHeDD Жыл бұрын
Thanks, you answered my awaited long question.
@sayanta01
@sayanta01 6 ай бұрын
thanks man
@rabi_saith
@rabi_saith 2 ай бұрын
Thanks
@vvv3876
@vvv3876 Жыл бұрын
I learned this on practice, i wish i viewed this video before
@arunalakmal9031
@arunalakmal9031 9 ай бұрын
Thnak you broo!!!
@swaggitypigfig8413
@swaggitypigfig8413 Жыл бұрын
Can you do a video on 360 no scope in Python next?
@sungodfatih
@sungodfatih Жыл бұрын
Thank you for this great explaination!
@dongchen7940
@dongchen7940 Жыл бұрын
There is no compile time in python, it is called interpret.
@charlesrussell6183
@charlesrussell6183 Жыл бұрын
great explanation
@udishe
@udishe Жыл бұрын
Ty
@Nicky411
@Nicky411 Жыл бұрын
Lovely video!
@karthiksundaram544
@karthiksundaram544 Жыл бұрын
Great stuff
@ismahelo
@ismahelo Жыл бұрын
What font is that? And what theme?
@amoghgc8712
@amoghgc8712 8 ай бұрын
SynthWave '84
@reynaparker2961
@reynaparker2961 4 ай бұрын
5:26
@magdalenacoman9120
@magdalenacoman9120 7 ай бұрын
bru put the music louder pls
@KeithKazamaFlick
@KeithKazamaFlick Жыл бұрын
dont use global guys.
@TMinusRecords
@TMinusRecords Жыл бұрын
9:17 This whole thing is a disgusting mess
@Hotwire_RCTrix
@Hotwire_RCTrix 8 ай бұрын
This language is conflicting coming from C++. We were taught that this kind of programming was for those ignorant BASIC programmers of the 70s. 😳
@Maker0824
@Maker0824 Жыл бұрын
Too basic for me
@pppluronwrj
@pppluronwrj Жыл бұрын
Js scope is better
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 301 М.
Dijkstra's Hidden Prime Finding Algorithm
15:48
b001
Рет қаралды 167 М.
Молодой боец приземлил легенду!
01:02
МИНУС БАЛЛ
Рет қаралды 1,9 МЛН
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 5 МЛН
How Much Tape To Stop A Lamborghini?
00:15
MrBeast
Рет қаралды 211 МЛН
Long Nails 💅🏻 #shorts
00:50
Mr DegrEE
Рет қаралды 14 МЛН
5 Good Python Habits
17:35
Indently
Рет қаралды 622 М.
Become a Malloc() Pro
6:58
thedoubleeguy
Рет қаралды 2,5 М.
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 414 М.
local and Global Scope in Python | Python Tutorials for Beginners #lec78
14:34
Jenny's Lectures CS IT
Рет қаралды 47 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 215 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 329 М.
Молодой боец приземлил легенду!
01:02
МИНУС БАЛЛ
Рет қаралды 1,9 МЛН