Wed 7 February 2018
Create reusable codes across Projects and potentially ShareIt!
I am programming in modules, and it is easy to share
*.py within a project. How?
- Always code in a
class. Never code outside one.
- For main code, never code outside a block, but code main code inside
if __name__ == '__main__':
- Share using
from ... import ...
But sharing across projects is a different story, but today, I found out how:- https://python-packaging.readthedocs.io/en/latest/
- When you have done the packaging, you can run
pip install -e .to share it for any
*.pyfiles you will run in the future.
- This will also facilitate others to run
pip install ., and they can use your git now. (They will have to clone your git first, though.)
- You can publish on PyPI using
python setup.py register
setup.pya bit, it is
Good luck modular programming!