Python if __name__ == '__main__' ❓
Bro Code Bro Code
2.17M subscribers
36,013 views
1.2K

 Published On Feb 8, 2021

python if _name_ == '__main__' name == main tutorial example explained

#python #name #main

***********************************
if _name_ == '__main__'
***********************************

y tho?
1. Module can be run as a standalone program
or
2. Module can be imported and used by other modules

Python interpreter sets "special variables", one of which is _name_
Python will assign the _name_ variable a value of '__main__' if it's
the initial module being run

def main():
print("Hello!")


if _name_ == '__main__':
main()

***********************************

Bro Code merch store 👟 :
===========================================================
https://teespring.com/stores/bro-code-5
===========================================================

show more

Share/Embed