Decorator which runs the tagged function if the current module is being run as a script. No more `if __name__ == "__main__"` madness.
Project description
@main
@main
decorator which runs the tagged function if the current module is being executed as a script.
No more if __name__ == "__main__":
all over the place.
That's it!
Installation
pip install python-main # or
poetry add python-main # ...
Usage
from python_main import main
A = 10
B = 20
@main
def do_print():
"""This will run if this module is executed."""
print(A + B)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python_main-1.0.2.tar.gz
.
File metadata
- Download URL: python_main-1.0.2.tar.gz
- Upload date:
- Size: 1.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5c2f4100eafb991b28bb97b6b1a5218040f7a3665b766aadd766cfe26225f50 |
|
MD5 | 8ab0acdb15e52550e951c8ccc180b626 |
|
BLAKE2b-256 | 96ff834c67dc0dd24db946b6fff10d1e311e48eaa11ba662bb718107fcb88d06 |
Provenance
The following attestation bundles were made for python_main-1.0.2.tar.gz
:
Publisher:
publish.yml
on flipbit03/main
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
python_main-1.0.2.tar.gz
- Subject digest:
d5c2f4100eafb991b28bb97b6b1a5218040f7a3665b766aadd766cfe26225f50
- Sigstore transparency entry: 149261354
- Sigstore integration time:
- Predicate type:
File details
Details for the file python_main-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: python_main-1.0.2-py3-none-any.whl
- Upload date:
- Size: 1.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54092fbc8bb9b979d8fd99dbf4f4ebbe3e75d5dd67fdfe4cc92b5d44595f9fa5 |
|
MD5 | 68e48bf27c463d6f5895fec5191e27a3 |
|
BLAKE2b-256 | 59d27bcb91d9a58ae7d6d94151542171a7aff0eae9777d78e23a5972d48056b7 |
Provenance
The following attestation bundles were made for python_main-1.0.2-py3-none-any.whl
:
Publisher:
publish.yml
on flipbit03/main
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
python_main-1.0.2-py3-none-any.whl
- Subject digest:
54092fbc8bb9b979d8fd99dbf4f4ebbe3e75d5dd67fdfe4cc92b5d44595f9fa5
- Sigstore transparency entry: 149261356
- Sigstore integration time:
- Predicate type: