0

I'm wondering if I can call a function in python above its actual definition. I want to put all of my functions at the end of the source code, but I am not sure if this will work. Thanks!

2 Answers2

0

The convention when using python is to call the main function at the end this will resolve any issue you might have with function calls, as the comments suggest, try it out! if that doesn't work, look it up :)

The link @Andy posted does answer your questions (link for reference)

Just make sure to add this:

if __name__ == '__main__':
    main()

at the end of your code.

Community
  • 1
  • 1
MrHaze
  • 3,656
  • 3
  • 25
  • 47
0

The answer is yes, you can call a function before its defined in the same file.

PsyKzz
  • 732
  • 4
  • 14