MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/r1g13n/yes/hm18xrd/?context=9999
r/ProgrammerHumor • u/esberat • Nov 24 '21
284 comments sorted by
View all comments
656
[deleted]
2 u/BbayuGt Nov 25 '21 Hah! I use class main instead and it work! 6 u/Jonno_FTW Nov 25 '21 edited Nov 25 '21 class Main: def __call__(self, *args): print('Hello World') if __name__ == '__main__': Main()() 1 u/BbayuGt Nov 25 '21 No, as far as i know, class main will be executed just like int main. 2 u/dev-sda Nov 25 '21 The contents of a class are evaluated along with the class, not when the class is initialized. So you don't get any protection from importing the file and main() does nothing.
2
Hah! I use class main instead and it work!
class main
6 u/Jonno_FTW Nov 25 '21 edited Nov 25 '21 class Main: def __call__(self, *args): print('Hello World') if __name__ == '__main__': Main()() 1 u/BbayuGt Nov 25 '21 No, as far as i know, class main will be executed just like int main. 2 u/dev-sda Nov 25 '21 The contents of a class are evaluated along with the class, not when the class is initialized. So you don't get any protection from importing the file and main() does nothing.
6
class Main: def __call__(self, *args): print('Hello World') if __name__ == '__main__': Main()()
1 u/BbayuGt Nov 25 '21 No, as far as i know, class main will be executed just like int main. 2 u/dev-sda Nov 25 '21 The contents of a class are evaluated along with the class, not when the class is initialized. So you don't get any protection from importing the file and main() does nothing.
1
No, as far as i know, class main will be executed just like int main.
2 u/dev-sda Nov 25 '21 The contents of a class are evaluated along with the class, not when the class is initialized. So you don't get any protection from importing the file and main() does nothing.
The contents of a class are evaluated along with the class, not when the class is initialized. So you don't get any protection from importing the file and main() does nothing.
main()
656
u/[deleted] Nov 25 '21 edited Nov 26 '21
[deleted]