#!/usr/bin/env python3
import click
@click.command()
@click.option('--desiredrange', '-r', default=1)
def main(desiredrange):
print(desiredrange)
print('abcd')
main()
print('!!!!')
Running the above code gives me the following in the terminal:
1
abcd
But I do not get
!!!!
This scenario is true for other variations of code that include ANYTHING after the main() function. The script exits after executing this function. This is also true for any function i.e. if I placed the print('!!!!') inside another function, then called that function after main(), the script exits after main(), ignoring the second function.
If I removed 'click', such that the code looks like:
#!/usr/bin/env python3
def main():
print(1)
print('abcd')
main()
print('!!!!')
I will get the following printed to terminal:
1
abcd
!!!!
I can execute other functions after main(), as well as other commands. I run this script from terminal using ./script.py (applied chmod +x script.py). I also get no errors from BOTH scenarios.
Why is this?