A simple definition of main
Project description
Define a Python main function in one step - no more __main__!
For any non-trivial projects, use typer and dtyper instead!
How to install
Use pip:
pip install def_main
Usage examples
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.9.2.tar.gz
(1.6 kB
view hashes)