What is Scope in Python??

  Рет қаралды 47,157

b001

b001

Жыл бұрын

⭐ Join my Patreon: / b001io
💬 Discord: / discord
🐦 Follow me on Twitter: / b001io
🔗 More links: linktr.ee/b001io
Background Music:
Gentle Lo-Fi Vlog Background Music | Cookies by Alex-Productions | onsound.eu/
Music promoted by www.free-stock-music.com
Creative Commons / Attribution 3.0 Unported License (CC BY 3.0)
creativecommons.org/licenses/...

Пікірлер: 58
@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.
@MoonFrogg
@MoonFrogg Жыл бұрын
these are VERY important things to learn, love the video and thanks for the clear + concise explanation!!
@porlando12
@porlando12 Жыл бұрын
Wow this was awesome. Your channel is criminally underrated!
@LilJollyJoker
@LilJollyJoker 7 ай бұрын
Thank you for this video!
@aliplayer1
@aliplayer1 Жыл бұрын
Love the videos. Concise yet full of information for new learners. Thanks.
@bab4953
@bab4953 7 ай бұрын
ur channel deserves more subs. Your content is amazing👍
@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.
@NickWrightDataYT
@NickWrightDataYT Жыл бұрын
Great stuff! Good to learn more about how Python "thinks" lol
@BiyHappy
@BiyHappy Жыл бұрын
Thanks man what a smooth explanation
@chsh9993
@chsh9993 7 ай бұрын
Your explanation of coding is truly ingenious. Suddenly, all those encrypted coding lines aren't that confusing anymore.
@adammarley5616
@adammarley5616 7 ай бұрын
Beautifully taught!
@killerboyak
@killerboyak 7 ай бұрын
Amazing Explanation , Thank you.
@mind_of_a_darkhorse
@mind_of_a_darkhorse Жыл бұрын
Great explanation of scope! You made it very easy to understand!
@user-pf8ww2im6f
@user-pf8ww2im6f Жыл бұрын
Man your video really helps. I couldn't understand the explanation on the official doc. Tyvm!
@naifal-ghamdi483
@naifal-ghamdi483 Жыл бұрын
Best scope explanation ever, many thanks to 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
@SHAYANGUHA
@SHAYANGUHA Ай бұрын
really informative 😍😍😍😍😍
@sayanta01
@sayanta01 2 ай бұрын
thanks man
@alanlado1602
@alanlado1602 11 ай бұрын
I like the way you explain things. Subscribe button smashed.
@Nicky411
@Nicky411 10 ай бұрын
Lovely video!
@fatiheee1996
@fatiheee1996 Жыл бұрын
Thank you for this great explaination!
@KrAsHeDD
@KrAsHeDD Жыл бұрын
Thanks, you answered my awaited long question.
@nadiaezzarhouni300
@nadiaezzarhouni300 Жыл бұрын
Bro you are insane, can you do a python course , by the way where do you get all this knowledge
@arunalakmal9031
@arunalakmal9031 5 ай бұрын
Thnak you broo!!!
@karthiksundaram544
@karthiksundaram544 Жыл бұрын
Great stuff
@udishe
@udishe 11 ай бұрын
Ty
@SusanAmberBruce
@SusanAmberBruce Жыл бұрын
Probably one of the most important videos to watch if someone is new to python
@elancedin7204
@elancedin7204 Жыл бұрын
bro literally did a few vids and already 82k subs, gut 4 u
@faisal99129
@faisal99129 10 ай бұрын
very good explanation... very helpful
@charlesrussell6183
@charlesrussell6183 Жыл бұрын
great explanation
@vuIent
@vuIent Жыл бұрын
Good video
@mossdem
@mossdem Жыл бұрын
Could you do a video which does a clear breakdown of classes?
@soniablanche5672
@soniablanche5672 8 ай бұрын
I knew of "global", but I didn't know about "nonlocal"
@yaraa.a5237
@yaraa.a5237 7 ай бұрын
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.
@birzhanabdikhan8175
@birzhanabdikhan8175 8 ай бұрын
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.
@vvv3876
@vvv3876 Жыл бұрын
I learned this on practice, i wish i viewed this video before
@yazanabdoush7030
@yazanabdoush7030 4 ай бұрын
Can you share what color theme you are using?
@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.
@OsirisRD
@OsirisRD Жыл бұрын
what is your theme vscode ?
@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?
@swaggitypigfig8413
@swaggitypigfig8413 Жыл бұрын
Can you do a video on 360 no scope in Python next?
@Joe_Brig
@Joe_Brig Жыл бұрын
2:30 not obvious if you coming from a compiled language.
@reynaparker2961
@reynaparker2961 27 күн бұрын
5:26
@dongchen7940
@dongchen7940 10 ай бұрын
There is no compile time in python, it is called interpret.
@TMinusRecords
@TMinusRecords Жыл бұрын
9:17 This whole thing is a disgusting mess
@ismahelo
@ismahelo Жыл бұрын
What font is that? And what theme?
@amoghgc8712
@amoghgc8712 5 ай бұрын
SynthWave '84
@magdalenacoman9120
@magdalenacoman9120 4 ай бұрын
bru put the music louder pls
@KeithKazamaFlick
@KeithKazamaFlick Жыл бұрын
dont use global guys.
@Hotwire_RCTrix
@Hotwire_RCTrix 4 ай бұрын
This language is conflicting coming from C++. We were taught that this kind of programming was for those ignorant BASIC programmers of the 70s. 😳
@pppluronwrj
@pppluronwrj Жыл бұрын
Js scope is better
@maker0824
@maker0824 Жыл бұрын
Too basic for me
Python Scope tutorial for Beginners
19:50
Dave Gray
Рет қаралды 7 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 464 М.
A little girl was shy at her first ballet lesson #shorts
00:35
Fabiosa Animated
Рет қаралды 15 МЛН
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 10 МЛН
How To Use List Comprehension In Python
6:41
Taylor's Software
Рет қаралды 6 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,1 МЛН
The Algorithm Behind Spell Checkers
13:02
b001
Рет қаралды 409 М.
Water powered timers hidden in public restrooms
13:12
Steve Mould
Рет қаралды 648 М.
What is Python scope resolution? 🔬
5:34
Bro Code
Рет қаралды 30 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 287 М.
3 PYTHON AUTOMATION PROJECTS FOR BEGINNERS
17:00
Internet Made Coder
Рет қаралды 1,6 МЛН
Why You Shouldn't Use the Global Keyword in Python
17:59
Tech With Tim
Рет қаралды 47 М.
Todos os modelos de smartphone
0:20
Spider Slack
Рет қаралды 64 МЛН
My iPhone 15 pro max 😱🫣😂
0:21
Nadir Show
Рет қаралды 1,3 МЛН
iPhone socket cleaning #Fixit
0:30
Tamar DB (mt)
Рет қаралды 18 МЛН
Копия iPhone с WildBerries
1:00
Wylsacom
Рет қаралды 8 МЛН
Как удвоить напряжение? #электроника #умножитель
1:00
Hi Dev! – Электроника
Рет қаралды 1,1 МЛН