Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to check if user is using main file or importing the file and using in python

def calculate_adding(num1,num2):
    return num1 + num2
if __name__ == '__main__':
    print("Hi you are using editor not importing")
    print(calculate_adding(90,10))
if __name__ != '__main__':
    print("You are importing me and using me")
#output
'''
Hi you are using editor not importing
100
'''
 
PREVIOUS NEXT
Tagged: #check #user #main #file #importing #file #python
ADD COMMENT
Topic
Name
8+1 =