Skip to content

Instantly share code, notes, and snippets.

@lopezpdvn
Last active May 21, 2016 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lopezpdvn/9a89dad82db384021c5e to your computer and use it in GitHub Desktop.
Save lopezpdvn/9a89dad82db384021c5e to your computer and use it in GitHub Desktop.
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