Skip to main content

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)

Metadata

Release files for def-main 0.12.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for def-main 0.12.0
File Size Uploaded
def_main-0.12.0.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for def-main 0.12.0
File Interpreter ABI Platform
def_main-0.12.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / def_main-0.12.0.tar.gz

Download URL def_main-0.12.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8bcf9e13f80b1b3c80fc5b83075b948814f5a940afb4fb4aab29732c2109f542
BLAKE2b-256 checksum
How to use checksums
752d0cf248d44016d122da8cdf3300e013a6cd6a790d8777bdf4b0b865fb78fb
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / def_main-0.12.0-py3-none-any.whl

Download URL def_main-0.12.0-py3-none-any.whl
Size 1.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7d2bc83855be27cf46bbb3479acb3c8e6749182d0189332da0ee552b2816050
BLAKE2b-256 checksum
How to use checksums
aef6ce9595943e18dac8940b49f90e4baa9ac1dbb224394387b397e925924215
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.12.0 This release

2 release files

0.11.0

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page