Placement in File of Classes and main Function - Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Placement in File of Classes and main Function - Python

Where should i place my classes in the file? top of the file? bottom? or it doesnt matter? is there a convension? and where should i be placing the main() function?

7th Aug 2021, 4:32 PM
Yahel
Yahel - avatar
2 Answers
+ 4
Usually imports are in the top of the file. The main() is usually in the bottom. Additional classes, functions are either imported or before the main() – remember: functions, classes... must be defined before you use them somewhere in the script.
7th Aug 2021, 4:45 PM
Lisa
Lisa - avatar
+ 1
Lisa as I thought, Thanks :)
7th Aug 2021, 4:55 PM
Yahel
Yahel - avatar