#46 Python Tutorial for Beginners | Special Variable __name__

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

For More Queries WhatsApp or Call on : +919008963671

In this lecture we will learn:
- What is the starting point of execution of code?
- What is a special variable in Python?
- __name__ variable in python
- How the name variable works in Python?

#1
- __main__ is the starting point of the python.
- The first module name is always main and the code starts from main.
- __name__ is a variable name that return the __main__.
- _name__ is a built-in variable that evaluates the name of the current module.
- The value of the name changes as per the place where it is used, so that's why it is known as a variable.
- If you are an individual file or module, then the name will return main.
- If you are importing another module containing the name variable in any file, then the name variable will return the name of that module.
OR,
- If you are running a file as a main and using a named variable in it, then it will print the main.
- But if you are printing a name that is imported as a module in another file, then it will print the module name.

#2
- The use of a function with the name variable helps the interpreter in checking if it's parsing the currently executed script, or if it's temporarily parsing another external script.
if __name__ == "__main__":
This statement helps us to control the behaviour of different parts of the program.
- It chooses the number of lines of codes that can be executed from the external script as well as the currently executed script depending on the scenarios.

Editing Monitors :

Subscribe to our other channel:
Telusko Hindi :

Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20
Рекомендации по теме
Комментарии
Автор

Summary of this video
1-They are two modules name demo and calc
2- when you are working on demo and print(_name )
Output- _main_(because it is starting point of a code)
3- Now we will work on calc and print hello _name_
Output- hello _main_
This is happening and it is giving name as main output because we are working on same module

Now when we import one module to other ( import calc to demo)
1- All the things in calc will be printed along with demo statements
2- but it will print hello calc (the module name )
Instead of hello main
Because we are importing it to other module
"sooo when you are importing it in same module it will give name output as main
And if in other module it will give name output along with module that's it❤

Thanku sooo much sir great work
Lots of blessing by one of your alien😅❤

nishthasrivastava
Автор

guys u need to watch it more than once, he is crystal clear.

arjunyadav-ktjr
Автор

best video i'have ever seen about __name__ == "__main__", i don't understand why people can't uderstand the video, it was really clear

thebrothershow
Автор

i don't know whether you will ever read this comment or not.
But Bro, you are the only reason i could learn python in this efficient way. You are crystal clear in every topic and your delivery skills are on another level.
I had watched many other videos also but no one was able to replace yours.
You are awesome!

IamNavi
Автор

Once you watch it a couple times it really starts to make a lot of sense. Thank you

Jaysalm
Автор

Watched this 3 times finally understood ... thank you sir.u r one of the best teacher.

abhijeetkumar
Автор

after so many videos and forums about __name__ and __main__, finally this video let me understand clearly what is it and what it does. Thanks!

chingyee
Автор

Really, brilliant brilliant explination. Love your flow, very easy for my brain to follow.

EUCitizenFedUpWithAllThisCrap
Автор

sir u stopped giving the quiz questions at the end of the video.

RahulGupta-lyuu
Автор

You've beaten my instructor and made my concept clear.
Gratitude.

mohinulislammohin
Автор

Incredible tutorial that just absolutely drove the concept right into my head, loved the explanation and the example - this made me have that light bulb moment where I was like "oh wow, so this is what it's all about!"

jonesleung
Автор

So, I was wondering from months, why do we use it. Today, my doubt got cleared finally . Thanks telusko

anugupta
Автор

This is the clearest explanation of name, main I have seen anywhere. Thank you

premprasad
Автор

I understand it now! Thank you genius! You explanation is so cool ❤️

plabonkumersarker
Автор

Sir i think one more video is required for __name__ to get it clearly understood so plz sir give something practical about it thankyou sir

pavanjain
Автор

wow man ! you make things crystal clear

tumul
Автор

Thank You for all the efforts that you've made to make this video. This is a very helpful and informative video and I was able tot understand everything clearly. It also helped me perform better in school.

parikshithishiker
Автор

watched it 3 times, it's crystal clear now

diahidvegi
Автор

After watching 3-4 videos about it, I finally get it! Your explanation is very clear and understandable. Thank you very much!

janosszeman
Автор

Getting confuse.make one more video on __name__.

dishankshah