+ 1

can i prescind from a main in Python?

4th Jan 2020, 1:30 AM
Pame
Pame - avatar
5 Respuestas
+ 7
It is not necessary to use a main function in python, but I always like to use if __name__="__main__" In my opinion, this is better because you don't have to worry about the order you defined functions/classes in. It is just a matter of preference in python, I think.
4th Jan 2020, 1:35 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 4
Pamela Horn you can use: def main(): #some code if __main__=="__name__": main()
4th Jan 2020, 3:39 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 4
Pamela Horn no problem!
4th Jan 2020, 3:43 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 1
thank you! do i have to establish one at the end of the classes? Or where do i put it?
4th Jan 2020, 1:46 AM
Pame
Pame - avatar
+ 1
Aymane Boukrouh thank you so much!
4th Jan 2020, 3:43 AM
Pame
Pame - avatar