I am coding a new python package to be used by others. To demonstrate how it should be used, I am writing a demo script that executes the main parts of the new package.
What is the convention for doing this, so that other will find the script easily? Should it be a separate module (by what name)? Should it be located in the package's root directory? Out of the package? In __init__.py
?
Should it be a separate module (by what name)?
demo/some_useful_name.py
A demo directory contains demo scripts. Similarly, a test directory contains all your unit tests.
Should it be located in the package's root directory?
No. It's not part of the package. It's a demo.
Out of the package?
Yes.
In init.py?
Never.
A package has two lives. (1) as uninstalled source, (2) in the lib/site-packages as installed code.
The "source" should include README, setup.py, demo directory, test directory, and the package itself.
The top-level "source" setup.py should install just the package. The demo and test don't get installed. They get left behind as part of the download.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With