Тёмный
No video :(

What is Scope in Python?? 

b001
Подписаться 258 тыс.
Просмотров 48 тыс.
50% 1

Опубликовано:

 

20 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 60   
@armpitpuncher
@armpitpuncher Год назад
Would have been good if you covered how scopes relate to loop bodies and if/else blocks, because it's not intuitive in python. For example, in every language which I'm familiar with besides python, a variable declared inside an if block is scoped to that block, and not accessible outside it. This is not the case in python.
@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.
@MoonFrogg
@MoonFrogg Год назад
these are VERY important things to learn, love the video and thanks for the clear + concise explanation!!
@chsh9993
@chsh9993 8 месяцев назад
Your explanation of coding is truly ingenious. Suddenly, all those encrypted coding lines aren't that confusing anymore.
@NickWrightDataYT
@NickWrightDataYT Год назад
Great stuff! Good to learn more about how Python "thinks" lol
@aliplayer1
@aliplayer1 Год назад
Love the videos. Concise yet full of information for new learners. Thanks.
@porlando12
@porlando12 Год назад
Wow this was awesome. Your channel is criminally underrated!
@LilJollyJoker
@LilJollyJoker 8 месяцев назад
Thank you for this video!
@bab4953
@bab4953 8 месяцев назад
ur channel deserves more subs. Your content is amazing👍
@nadiaezzarhouni300
@nadiaezzarhouni300 Год назад
Bro you are insane, can you do a python course , by the way where do you get all this knowledge
@SHAYANGUHA
@SHAYANGUHA 2 месяца назад
really informative 😍😍😍😍😍
@SusanAmberBruce
@SusanAmberBruce Год назад
Probably one of the most important videos to watch if someone is new to python
@user-pf8ww2im6f
@user-pf8ww2im6f Год назад
Man your video really helps. I couldn't understand the explanation on the official doc. Tyvm!
@BiyHappy
@BiyHappy Год назад
Thanks man what a smooth explanation
@soniablanche5672
@soniablanche5672 8 месяцев назад
I knew of "global", but I didn't know about "nonlocal"
@adammarley5616
@adammarley5616 8 месяцев назад
Beautifully taught!
@elancedin7204
@elancedin7204 Год назад
bro literally did a few vids and already 82k subs, gut 4 u
@sayanta01
@sayanta01 3 месяца назад
thanks man
@killerboyak
@killerboyak 7 месяцев назад
Amazing Explanation , Thank you.
@naifal-ghamdi483
@naifal-ghamdi483 Год назад
Best scope explanation ever, many thanks to you
@birzhanabdikhan8175
@birzhanabdikhan8175 9 месяцев назад
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.
@mind_of_a_darkhorse
@mind_of_a_darkhorse Год назад
Great explanation of scope! You made it very easy to understand!
@yaraa.a5237
@yaraa.a5237 8 месяцев назад
the music is fire it got me dancing. and it remind me of minecraft
@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.
@arunalakmal9031
@arunalakmal9031 6 месяцев назад
Thnak you broo!!!
@alanlado1602
@alanlado1602 11 месяцев назад
I like the way you explain things. Subscribe button smashed.
@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
@vuIent
@vuIent Год назад
Good video
@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.
@Nicky411
@Nicky411 11 месяцев назад
Lovely video!
@udishe
@udishe Год назад
Ty
@faisal99129
@faisal99129 11 месяцев назад
very good explanation... very helpful
@KrAsHeDD
@KrAsHeDD Год назад
Thanks, you answered my awaited long question.
@Joe_Brig
@Joe_Brig Год назад
2:30 not obvious if you coming from a compiled language.
@karthiksundaram544
@karthiksundaram544 Год назад
Great stuff
@TMinusRecords
@TMinusRecords Год назад
9:17 This whole thing is a disgusting mess
@charlesrussell6183
@charlesrussell6183 Год назад
great explanation
@fatiheee1996
@fatiheee1996 Год назад
Thank you for this great explaination!
@harshaljani2266
@harshaljani2266 6 дней назад
If there were 4 functions nested then would there be a way to access the 2nd function’s variable in the innermost 4th function?
@vvv3876
@vvv3876 Год назад
I learned this on practice, i wish i viewed this video before
@mossdem
@mossdem Год назад
Could you do a video which does a clear breakdown of classes?
@dongchen7940
@dongchen7940 11 месяцев назад
There is no compile time in python, it is called interpret.
@swaggitypigfig8413
@swaggitypigfig8413 Год назад
Can you do a video on 360 no scope in Python next?
@samsungcurved
@samsungcurved 4 дня назад
Which theme you are using?
@reynaparker2961
@reynaparker2961 Месяц назад
5:26
@yazanabdoush7030
@yazanabdoush7030 4 месяца назад
Can you share what color theme you are using?
@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
@xcc4010
@xcc4010 Год назад
What is the name of the theme?
@Hotwire_RCTrix
@Hotwire_RCTrix 5 месяцев назад
This language is conflicting coming from C++. We were taught that this kind of programming was for those ignorant BASIC programmers of the 70s. 😳
@OsirisRD
@OsirisRD Год назад
what is your theme vscode ?
@magdalenacoman9120
@magdalenacoman9120 4 месяца назад
bru put the music louder pls
@ismahelo
@ismahelo Год назад
What font is that? And what theme?
@amoghgc8712
@amoghgc8712 5 месяцев назад
SynthWave '84
@KeithKazamaFlick
@KeithKazamaFlick Год назад
dont use global guys.
@maker0824
@maker0824 Год назад
Too basic for me
@pppluronwrj
@pppluronwrj Год назад
Js scope is better
Далее
5 Good Python Habits
17:35
Просмотров 497 тыс.
Python Scope tutorial for Beginners
19:50
Просмотров 7 тыс.
Ik Heb Aardbeien Gemaakt Van Kip🍓🐔😋
00:41
PEDRO PEDRO INSIDEOUT
00:10
Просмотров 1,6 млн
The Algorithm Behind Spell Checkers
13:02
Просмотров 411 тыс.
Python Yield Keyword??
3:18
Просмотров 128 тыс.
How To Use List Comprehension In Python
6:41
Просмотров 7 тыс.
Why You Shouldn't Use the Global Keyword in Python
17:59
Please Master These 10 Python Functions…
22:17
Просмотров 135 тыс.
5 Useful Python Decorators (ft. Carberra)
14:34
Просмотров 97 тыс.