Closed bbelderbos closed 1 year ago
@bbelderbos Is it really necessary to have the if __name__ == "__main__": in https://github.com/vnoelifant/cozmo-companion/blob/packaging/src/cozmo_companion/__main__.py? Good question, Will actually adviced me against it as per docs, so lately I do this in main: from .cli import app app() (example from pybites-search)
@bbelderbos Is it really necessary to have the if __name__ == "__main__": in https://github.com/vnoelifant/cozmo-companion/blob/packaging/src/cozmo_companion/__main__.py?
if __name__ == "__main__":
Good question, Will actually adviced me against it as per docs, so lately I do this in main:
from .cli import app app()
(example from pybites-search)
Reason of not using if name == main in main.py:
Also discussed in this clinic: https://pybites.mykajabi.com/products/pybites-coaching-calls-2/categories/3469727/posts/2166525740
Refactoring suggestion: move the code you currently have in main into cli.py and use the from .cli import app code above, see pybites-search for example: https://github.com/PyBites-Open-Source/search/blob/main/src/pybites_search/cli.py
Reason of not using if name == main in main.py:
Also discussed in this clinic: https://pybites.mykajabi.com/products/pybites-coaching-calls-2/categories/3469727/posts/2166525740
Refactoring suggestion: move the code you currently have in main into cli.py and use the from .cli import app code above, see pybites-search for example: https://github.com/PyBites-Open-Source/search/blob/main/src/pybites_search/cli.py