🗣 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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bcf9e13f80b1b3c80fc5b83075b948814f5a940afb4fb4aab29732c2109f542
|
|
| MD5 |
9d9d21d99986292aecf1b351651ebf6a
|
|
| BLAKE2b-256 |
752d0cf248d44016d122da8cdf3300e013a6cd6a790d8777bdf4b0b865fb78fb
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7d2bc83855be27cf46bbb3479acb3c8e6749182d0189332da0ee552b2816050
|
|
| MD5 |
5e2e4b2dc1cc3fad663fa89e29455bf6
|
|
| BLAKE2b-256 |
aef6ce9595943e18dac8940b49f90e4baa9ac1dbb224394387b397e925924215
|