What is this in python (__name__) explain it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is this in python (__name__) explain it

Hi everyone Can anybody explain what is uses of __name__ in python, what is important please tell me

1st Mar 2018, 5:07 PM
Maninder $ingh
Maninder $ingh - avatar
2 Answers
+ 1
__name__ is a special variable that tells the script the scope it's called from. When importing the file, the __name__ will be the calling script, if the file is executed from the REPL, directly or through the standard input, __name__ will be "__main__"
1st Mar 2018, 7:27 PM
Amaras A
Amaras A - avatar
2nd Mar 2018, 8:35 AM
J G
J G - avatar