Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python if main

# if __name__ == '__main__' checks if a file is imported as a module or not.
# example: 
def main():
    print('Hello World')
    
if __name__ == '__main__':
    # This code won't run if this file is imported.
    main()
Comment

if main python

# Python program to execute
# main directly
print ("Always executed")
 
if __name__ == "__main__":
    print ("Executed when invoked directly")
else:
    print ("Executed when imported")
Comment

PREVIOUS NEXT
Code Example
Python :: how to use argparse 
Python :: python pandas csv append 
Python :: python dict setdefault 
Python :: tkinter window size 
Python :: selenium select element by id 
Python :: pygame get keypress code 
Python :: matplotlib display graph on jupyter notebook 
Python :: python initialize dict with empty list values 
Python :: adding roles discord py 
Python :: how to setup django ionos hostig 
Python :: download from colab to local drive 
Python :: print font size python 
Python :: python format 001 
Python :: camel case in python 
Python :: entered_text_1 = textbox_1.get(1.0, tk.END+"-1c") 
Python :: word2number python 
Python :: how to fix valueerror in python 
Python :: how to get value from txtbox in flask 
Python :: python projects with source code 
Python :: how to display values on top of bar in barplot seaborn 
Python :: detect character in string python 
Python :: python for/else 
Python :: Sending POST request in Django 
Python :: group by, aggregate multiple column -pandas 
Python :: python array scalar multiplication 
Python :: Error: The file/path provided (flaskr) does not appear to exist. Please verify the path is correct. If app is not on PYTHONPATH, ensure the extension is .py 
Python :: Python string to var 
Python :: delete element list python 
Python :: change float column to percentage python 
Python :: php datatables serverside 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =