Skip to main content

🗣 A decorator for main 🗣

Project description

def_main: a tiny decorator to define main

Define the main function in one step.

For any non-trivial projects, use typer and dtyper instead!

Usage example

Without an return code

import def_main

@def_main
def main(*argv):
    print('hello,', *argv)

means precisely the same as:

def main(*argv):
    print('hello,', *argv)


if __name__ == '__main__':
    import sys

    main(sys.argv[1:])

With a return code

import def_main

@def_main
def main(*argv):
    print('hello,', *argv)
    return argv

means precisely the same as:

def main(*argv):
    print('hello,', *argv)
    return argv


if __name__ == '__main__':
    import sys

    returncode = main(sys.argv[1:])
    sys.exit(returncode)

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

def_main-0.12.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

def_main-0.12.0-py3-none-any.whl (1.6 kB view details)

Uploaded Python 3

File details

Details for the file def_main-0.12.0.tar.gz.

File metadata

  • Download URL: def_main-0.12.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for def_main-0.12.0.tar.gz
Algorithm Hash digest
SHA256 8bcf9e13f80b1b3c80fc5b83075b948814f5a940afb4fb4aab29732c2109f542
MD5 9d9d21d99986292aecf1b351651ebf6a
BLAKE2b-256 752d0cf248d44016d122da8cdf3300e013a6cd6a790d8777bdf4b0b865fb78fb

See more details on using hashes here.

File details

Details for the file def_main-0.12.0-py3-none-any.whl.

File metadata

  • Download URL: def_main-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 1.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for def_main-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7d2bc83855be27cf46bbb3479acb3c8e6749182d0189332da0ee552b2816050
MD5 5e2e4b2dc1cc3fad663fa89e29455bf6
BLAKE2b-256 aef6ce9595943e18dac8940b49f90e4baa9ac1dbb224394387b397e925924215

See more details on using hashes here.

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