-
Notifications
You must be signed in to change notification settings - Fork 1
Python
sipke edited this page May 30, 2020
·
9 revisions
import string
import random
''.join([random.choice(string.ascii_letters + string.digits + string.punctuation) for n in xrange(12)])
In [55]: ''.join([random.choice(string.ascii_letters + string.digits + string.punctuation) for n in xrange(12)])
Out[55]: '.F?3<:"INqD]'
Add the following in your python script to catch a Ctrl-C signal and allow it to be run as an application.
#!/usr/bin/env python3
#... your code
def signal_handler(signum, frame):
sys.exit(-1)
if __name__ == "__main__":
import signal
signal.signal(signal.SIGINT, signal_handler)
#... call your code here
https://packaging.python.org/guides/single-sourcing-package-version/