Skip to content

Commit

Permalink
Add print statement to the top of test_project_python.__init__ mo…
Browse files Browse the repository at this point in the history
…dule

- simplifies understanding the differences between
  the following commands:
  - `command_name`
  - `command_name_for_function_in__main__`
  - `python3 -m test_project_python`
  • Loading branch information
shailshouryya committed Feb 20, 2023
1 parent a07c7f2 commit d2ad345
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/test_project_python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
print('Entered test_project_python.__init__ :)')

def function_name():
print('Ran test_project_python.__init__.function_name')
return True
Expand Down
12 changes: 12 additions & 0 deletions python/test_project_python/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

def function_in__main__():
print('Ran test_project_python.__main__.function_in__main__')
print('''
To better understand how commands from the 'console_scripts' key inside
the entry_points dictionary in setup.py works, run and compare
command_name
command_name_for_function_in__main__
python3 -m test_project_python # Linux/macOS
python -m test_project_python # Windows
custom_py -m test_project_python # if you use a custom alias for python command
This assumes you've already installed the package with:
pip install test_project_python # installs from PyPI
pip install . # installs local version (you need to clone this repo and then run this from the test_project/python directory)
''')

if __name__ == '__main__':
print('__name__ == "__main__" is True for test_project_python.__main__')
Expand Down

0 comments on commit d2ad345

Please sign in to comment.