Skip to content

Instantly share code, notes, and snippets.

@soh-i
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save soh-i/4011eb2b4f106c4b9dc6 to your computer and use it in GitHub Desktop.

Select an option

Save soh-i/4011eb2b4f106c4b9dc6 to your computer and use it in GitHub Desktop.
@header_info decorator
import inspect
import os
import os.path
import datetime
def header_info(func):
def _header(*args, **kwargs):
exec_path = inspect.currentframe().f_back.f_code.co_filename
print "# Run '%s' function in %s" % (func.__name__, os.path.abspath(exec_path))
print "# Host: %s" % (os.uname()[1])
now = datetime.datetime.now()
print "# Created at %s" % (now.strftime('%Y/%m/%d %H:%M:%S'))
return func(*args, **kwargs)
return _header
@soh-i
Copy link
Author

soh-i commented Jul 4, 2015

@header_info
def run_algorithm_or_experimets():
    result = exec_command(...)
    print "%s,%s" % (result[1], result[2])
    ...

@soh-i
Copy link
Author

soh-i commented Jul 4, 2015

# Run 'run_algorithm_or_experiments' function in /Users/yukke/dev/project/scripts/test_analysis.py
# Host: aichan
# Created at 2015/07/04 16:27:30
A,921.000
B,900.002
C,900.002
....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment