Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Program layout
#1
Hi was wanting to know is there a particular way of structuring a python program . For the last year and a half I've been using Basic and am trying to learn python . Been at it about a week and seem to be doing ok. However what I was wondering is how to structure a program like main with multiple subroutines or procedures . As I say I've only been at this a week so any good advice would be welcome .
Reply
#2
Every program is different. A common pattern is to have a main() function from which everything starts, and then invoke it at the end of your script like this:
if __name__ == "__main__":
    main()
Global variables are considered bad, and object-oriented programming is often important to the proposed solution.

Beyond that, I think you'd get the most out of this question by asking about specific circumstances.
Reply
#3
https://docs.python-guide.org/writing/structure/
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020