Python Tutorial: Variable Scope - Understanding the LEGB rule and global/nonlocal statements

preview_player
Показать описание
In this Python Tutorial, we will be going over variable scope in Python. Scope is important because we need to understand it in just about every program we write. It allows us to understand where our variables can be seen from within our program and also what values these variables hold. It also helps with debugging, because scope is a common problem when errors are thrown. Let's get started.

The code from this video can be found at:

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:

#Python
Рекомендации по теме
Комментарии
Автор

I think many people don't even realize how well-thought-out and well-prepared your videos are. Your step by step explanation skills are unsurpassable

julianmahler
Автор

Mate, I'm being forced to watch some random Python tutorial at my Python Internship and it's a real pain in the ass to do so once one knows your channel. I just realized that theese might honestly be the best tutorials in the web...

kobas
Автор

Corey. Man. It's so great that you exist. Thank you.

saitaro
Автор

I have never seen a better explain tutorial of LEGB, thank corey, wish you all the best!

ousmanetall
Автор

Man you are a heaven send! I literally was thinking I need to study scope more since being new to python and programming in general I was having lots of problems, and then Google notifies me about this video being released 10 mins latter, wow its just perfect, absolutely perfect, it even covered everything I was thinking about. Thank You so much.

gideonfelt
Автор

Amazing work, we are really living a great era of transformation where such high level of information is widely available and accessible, what a blessing !!

PedroHenrique-pskj
Автор

Just wanted to write this after what you said about global variables (not to overuse them). You are not just teaching stuff, also giving great informations and insights about programming. That's a gem!

cemalcakir
Автор

this video has been an awakening. I don't understand why anyone has come up with such an eloquent explanation as yours before.

janick
Автор

Again a very crisp video. I learnt programming in 1994 on IBM mainframe and did work on Cobol/DB2/CICS etc. but soon moved into managerial role. One of my biggest problems with lot of videos is that they all spend lot of time on useless explanations... I need someone like you who is short and crip and to the point(because I know programming as such..but need specifics)... I get every minute worth in your videos with no waste of time.

nitkap
Автор

1st year compSci student here and this helped in more ways than you can imagine. started coding in delphi so there was no need for Enclosing or Builtins and didnt know why my global values were not changing but thank God for you. Much appreciated 🙏

jonathanessien
Автор

People has But YOU are a real teacher who says the truth ... The "shape of my heart" song is meant for you❤

jazmonark
Автор

I has been frantically searching for a proper tutorial on sending emails using Python. I was literally pulling my hair off by reading and implementing solutions from Stack Overflow which introduced some other bus in my project. I accidentally stumbled upon your channel and boy am I glad that I did. Thank you so much for doing this mate, you are making a difference in the lives of other people, I hope you are doing well in these times. Thank you once again!

the_xibalba
Автор

Wonderful work @Corey Schafer. I have seen so many tutorials, but your tutorials are the best. Many thanks to @Krish naik for suggesting me your tutorials.

hussainmadar
Автор

Every single thing i look up during my python course always leads me to your channel, you're an absolute blessing.

Airless_Grind
Автор

I'm glad you added the part about "Look, that's how it works, but you shouldn't overuse it." Globals are dangerous beasts. Certain (now deceased) Toyota owners learned that the hard way.

It's an easy thing to have overlooked, but very important.

liesdamnlies
Автор

Corey I have never seen anyone to explain this basic and very important information. Thanks.

andresvodopivec
Автор

Awesome video, It cleared out my many doubts. Thumbs up to Mr. Schafer. Keep up the good work. I wish I found you earlier when I was struggling to learn java but I hated Python because I couldn't find a good instructor like you, the instructors I found made this language look very hard but now I have found you, I am changed my ambition from becoming a java developer to a python developer. Love you, Corey.

wizard-
Автор

if i had access to a million mail id's, i would have subscribed this channel with each of them...this is in my opinion #1 channel for python..this video cleared every doubt i had in this topic..tysm dude!!

caydanphoenix
Автор

I totally agree on Julian M's comments. This lecture is very well-planned and highly organized. I came to Corey's video after several stops that I wasn't satisfied much. Happy to find Corey S videos.

appletreegfx
Автор

Masterful clarity in simple conversational language. What a relief

davidalexander