Where should your definitions of your functions be in your code? Should they be down below or above? What is the best way?
Beginner Question - Thanks for your support.
Where should your definitions of your functions be in your code? Should they be down below or above? What is the best way?
Beginner Question - Thanks for your support.
The rule is that you need to define your function before you call it. The rule relaxes if you call one function from another function.
Generally line up your imports, then your classes, and then your functions before you go at them.
Apart from what vegaseat said (you really do need to define before you call) it's a matter of personal taste.
I use http://www.python.org/dev/peps/pep-0008/ because the resulting code is easy to understand.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.