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.1.tar.gz
.
File metadata
- Download URL: python_main-1.0.1.tar.gz
- Upload date:
- Size: 1.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4aa6a0ce0ba72c0b7d31316eebbc88d61154dff1227b51327d1537da026e91f |
|
MD5 | c82e2e6f2ef963c1ff5317a1ee69ea7a |
|
BLAKE2b-256 | e8793dcbde971c0b5b9baee5f59e7d827fe203c5af8b562ee118ff8dede609c2 |
Provenance
The following attestation bundles were made for python_main-1.0.1.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.1.tar.gz
- Subject digest:
c4aa6a0ce0ba72c0b7d31316eebbc88d61154dff1227b51327d1537da026e91f
- Sigstore transparency entry: 149023090
- Sigstore integration time:
- Predicate type:
File details
Details for the file python_main-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: python_main-1.0.1-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 | aaea4d878658e25a1121c2744c883539e0a995588b734b63bd6f08e0d06c5038 |
|
MD5 | a0fbac65fe10c409d56ed021ce0b1149 |
|
BLAKE2b-256 | aedbad04db532680a32344612b4fac48b9ec4aca2ea084a06f512598af04508a |
Provenance
The following attestation bundles were made for python_main-1.0.1-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.1-py3-none-any.whl
- Subject digest:
aaea4d878658e25a1121c2744c883539e0a995588b734b63bd6f08e0d06c5038
- Sigstore transparency entry: 149023092
- Sigstore integration time:
- Predicate type: