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.1.tar.gz (1.4 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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

Hashes for python_main-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c4aa6a0ce0ba72c0b7d31316eebbc88d61154dff1227b51327d1537da026e91f
MD5 c82e2e6f2ef963c1ff5317a1ee69ea7a
BLAKE2b-256 e8793dcbde971c0b5b9baee5f59e7d827fe203c5af8b562ee118ff8dede609c2

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on flipbit03/main

Attestations:

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

Hashes for python_main-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aaea4d878658e25a1121c2744c883539e0a995588b734b63bd6f08e0d06c5038
MD5 a0fbac65fe10c409d56ed021ce0b1149
BLAKE2b-256 aedbad04db532680a32344612b4fac48b9ec4aca2ea084a06f512598af04508a

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_main-1.0.1-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