Is It Generally A Good Idea To Put A Console Client Into Module's __name__ == __main__ Section?
Is it generally a good idea to put a console client into module's if __name__ == '__main__': section? E.g. code to setup argparser and preprocess user input.
Solution 1:
With this, a program will effectively double as a module and a script. There's nothing wrong with this per se. The pdb
standard module is an example and e.g. programs that run as Windows services using win32serviceutil.ServiceFramework
are usually done this way.
Your only concern here is if you have several scripts and/or modules, you can still tell which is which. See Is a Scripts directory an anti-pattern in Python? If so, what's the right way to import? for a related discussion.
Post a Comment for "Is It Generally A Good Idea To Put A Console Client Into Module's __name__ == __main__ Section?"