Been picking up some python and I noticed that you can define a function in a non linear way... meaning the method call could come before defining the method:
def main():
function2()
def function2():
print("this is the second funciton.")
if __name__ == "__main__": main()
That last line there is saying run the file and then the main function after. So function2() called in main gets defined first. Then main is run, so it knows what function2() is.
def main():
function2()
def function2():
print("this is the second funciton.")
if __name__ == "__main__": main()
That last line there is saying run the file and then the main function after. So function2() called in main gets defined first. Then main is run, so it knows what function2() is.
No comments:
Post a Comment