Why added to python program file ? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Why added to python program file ?

If_name_ ==ā€œ_main_ā€: main()

2nd Jan 2021, 4:02 PM
Rocky Khatete Tonny
Rocky Khatete Tonny - avatar
2 Respostas
+ 3
See this answer and btw it is double underscore if __name__ == "__main__" : https://www.sololearn.com/Discuss/2296422/?ref=app
2nd Jan 2021, 4:12 PM
noteve
noteve - avatar
+ 3
TheĀ __name__Ā variable is a special Python variable.Ā It gets its value depending on how we execute the containing script. If we execute the original script it's value will be main but if we use this script from any other script it's value will be same as your original script's name
2nd Jan 2021, 4:12 PM
Deekshant
Deekshant - avatar