Friday, September 29, 2023

python if __name__ == "__main__" : why we use it

 sample.py

==========================

def fun():

return "hello"

fun()

if __name__ == "__main__" :

print ("This will run when the script will run directly like python sample.py and not imported.")


No comments:

Post a Comment

virtual environment on python on Ubuntu

 # 1. Update system and install Python tools sudo apt update && sudo apt install python3-pip python3-venv -y # 2. Setup Django in a ...