Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python 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

main function python


print("Hello")

print("__name__ value: ", __name__)


def main():
    print("python main function")


if __name__ == '__main__':
    main()
Comment

python main

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

__main__(python)

<class '__main__.CoolClass'>
Comment

PREVIOUS NEXT
Code Example
Python :: selenium python find all links 
Python :: The following packages have unmet dependencies: libnode72 : Conflicts: nodejs-legacy E: Broken packages 
Python :: httpie on windows 
Python :: pip pickle 
Python :: colab im show 
Python :: add bearer token in python request 
Python :: copy text to clipboard python 
Python :: python format seconds to hh mm ss 
Python :: python capture exception 
Python :: how to get file name without extension in python 
Python :: url decode python 
Python :: flip a plot matplotlib 
Python :: how to check the django version on a mac 
Python :: python plot frequency of column values 
Python :: plot image without axes python 
Python :: simple imputer python 
Python :: rgb to grayscale python opencv 
Python :: color to black and white cv2 
Python :: matplotlib text too small 
Python :: python delete contents of file 
Python :: unzip file python 
Python :: NameError: name ‘np’ is not defined 
Python :: python cv2 read image grayscale 
Python :: ValueError: cannot mask with array containing NA / NaN values 
Python :: python read file line by line 
Python :: dataframe find nan rows 
Python :: xlim python 
Python :: filter dataframe columns vy a list of columns 
Python :: selenium python enter text 
Python :: adding whitenoise to middleware in django 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =