Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
python_tmpl
#!/usr/bin/env python
# coding=utf-8
'''Module docstrings title.
Don't use keywords only arguments (for functions), sphinx.ext.autodoc will
fail if you do.
When in doubt consult [PEP8]_.
Citations
=========
.. [PEP8] http://www.python.org/dev/peps/pep-0008/.
'''
# Standard library imports.
from __future__ import division
from pprint import pprint
import sys
import os
import atexit
import gc
# Related third party imports.
# import third_party_mod
# Local application/library specific imports.
# import app_specific_mod
# Relevant ``__all__`` specification here.
# __all__ = ...
# GLOBAL CONSTANT names. *if main* section at bottom sets global names too.
def on_exit():
'''Actions to do on exit.'''
print('on_exit', LOGF)
# Invoke the garbage collector.
gc.collect()
def main():
'''Main program function.'''
pass
if __name__ == "__main__":
# Program name from file name.
PN = os.path.splitext(sys.argv[0])[0]
# Log file.
LOGF = ''.join([PN, '_log', '.txt'])
atexit.register(on_exit)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment