mainmethod.py
Provides C-like main method support.
Sample usage:
# file: script.py
from mainmethod import mainmethod
@mainmethod
def main():
print('hello, world!')
Running the script defined above will execute the method main.
$ python script.py
hello, world
No more need for
if __name__ == '__main__':
main()
The decorator inspects the method marked as main and supports these signatures;
main(). -> No command line arguments.main(argv)(ormain(args)) -> Getsys.argvpassed to the main method call.
from mainmethod import mainmethod
@mainmethod
def main(argv):
message = 'hello, world'
if '--loud' in argv:
message = message.upper()
print(message)
The decorator also automatically gathers the return value from the main method and uses it as the return status code.
Release files for mainmethod 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mainmethod-0.1.1.tar.gz | 2.2 kB | Details |
Release files / mainmethod-0.1.1.tar.gz
| Download URL | mainmethod-0.1.1.tar.gz |
|---|---|
| Size | 2.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c666a1e89997ecd2c89cf63bf5db58ae71cb0298c324673922ed4fe214ac0e64
|
|
BLAKE2b-256 checksum How to use checksums |
52b9d03ab3518fee2d60e0aaef3ef37aaea8bff318da2dc55ca51c86d5c19bf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
|