+ 1
Code __init__
What does the result of this code: def function(): print("This is a module function") if __name__=="__main__": print("This is a script")
2 Antworten
+ 3
Okay I assume you know what function() is (else you failed to learn Python 😂)
__name__ returns the name of the instance where it is running.
Suppose this script was impirted as a module, __name__=="__main__" will be false, hence it will not run. It will only run IF it is run as a script.
+ 2
why don't you try on python idle and verify?