Comment Header Creator
Create a "header" for separating/describing sections of your Python code.
I don't know about you but I like to "organize" my Python methods and functions by putting some sort of comment seperator between them. This helps me when scrolling through my code to find particular categories of routines.
There are basically 2 main methods: Basic or Fancy
- Basic (the uniline() method) returns a formatted string that is a single line with the 'title' centered.
- Fancy (the multiline() method) returns a formatted string that is 3 lines long with the 'title' centered in the center line.
There is a "hidden" function, _generate_line(), is the secret sauce to generating the lines. You can call this directly but bear in mind it returns a Tuple (string and a boolean).
Installation
For some reason that I cannot figure out PyPi changes "comment_header_creator" into "comment-header-creator". This
causes issues in that you have to use "dashes" to pip install but then use "underscores" to import.
pip install comment-header-creator
Example Uses
See example.py for how to use or:
- Create a single-line header but input title from user input:
import comment_header_creator as chc
print(chc.uniline())
yields:
Enter Title: title of section
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- TITLE OF SECTION -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
- Create a multi-line header but input title from user input:
import comment_header_creator as chc
print(chc.multiline())
yields:
Enter Title: Another Section
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ANOTHER SECTION -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
- Create a single-line (or multi-line) header by passing title in function call:
import comment_header_creator as chc
print(chc.uniline(title='Greatest Hits'))
yields:
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- GREATEST HITS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
- You can also set your own 'expander' string:
import comment_header_creator as chc
chc.uniline(title="it's a flesh wound", expander='0i')
"# i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i IT'S A FLESH WOUND i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i0i #"
NOTE: In the previous example notice that we didn't use the print() function. This will return a string, which you then need to "strip" the quotes off the front and end. Thus, I suggest print()'ing your outputs.
Metadata
Release files for comment-header-creator 20210909.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| comment_header_creator-20210909.0.tar.gz | 15.8 kB | Without provenance | Details |
Release files / comment_header_creator-20210909.0.tar.gz
| Download URL | comment_header_creator-20210909.0.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9f7cb6cbfa82ce97b23e9bd77efee5905d44f9fc8ff7bc6064d942b591b243d
|
|
BLAKE2b-256 checksum How to use checksums |
d63f99e0cbbd570cbd92b652d4da2baca518c018ab6ccf1c31ce659444b72b2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
|
Security for comment-header-creator 20210909.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.