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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_main-1.0.3-py3-none-any.whl (1.9 kB view details)

Uploaded Python 3

File details

Details for the file python_main-1.0.3.tar.gz.

File metadata

  • Download URL: python_main-1.0.3.tar.gz
  • Upload date:
  • Size: 1.5 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.3.tar.gz
Algorithm Hash digest
SHA256 a580d2c81b0726b1570b796e19ab452056637f92a22580bec832ee2228bafd47
MD5 1c268cbac330b250053b5ece64d8a455
BLAKE2b-256 89335762a6791f559b519580c7f57ddbb14deeee0fd6cf8c2cf3e3d2ac5281db

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on flipbit03/main

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_main-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: python_main-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 1.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3bf5687115cf9021a706671f5a098e8fad89ce003a654272924e1db8a21a753a
MD5 19dc8796c941c18d24bde133d1075b96
BLAKE2b-256 d7b05862bb85df2d334ba4badf63f9b62f774a82b40ea16f66ad077debac7213

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on flipbit03/main

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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