Skip to main content

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

PyPI - Python Version PyPI - Version

@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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_main-1.0.2.tar.gz (1.3 kB view details)

Uploaded Source

Built Distribution

python_main-1.0.2-py3-none-any.whl (1.7 kB view details)

Uploaded Python 3

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

Hashes for python_main-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d5c2f4100eafb991b28bb97b6b1a5218040f7a3665b766aadd766cfe26225f50
MD5 8ab0acdb15e52550e951c8ccc180b626
BLAKE2b-256 96ff834c67dc0dd24db946b6fff10d1e311e48eaa11ba662bb718107fcb88d06

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_main-1.0.2.tar.gz:

Publisher: publish.yml on flipbit03/main

Attestations:

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

Hashes for python_main-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 54092fbc8bb9b979d8fd99dbf4f4ebbe3e75d5dd67fdfe4cc92b5d44595f9fa5
MD5 68e48bf27c463d6f5895fec5191e27a3
BLAKE2b-256 59d27bcb91d9a58ae7d6d94151542171a7aff0eae9777d78e23a5972d48056b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_main-1.0.2-py3-none-any.whl:

Publisher: publish.yml on flipbit03/main

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page