Skip to content

Instantly share code, notes, and snippets.

@grigorisg9gr
Last active June 21, 2017 14:32
Show Gist options
  • Save grigorisg9gr/0b686e1345597a4cd53470e065c7e64c to your computer and use it in GitHub Desktop.
Save grigorisg9gr/0b686e1345597a4cd53470e065c7e64c to your computer and use it in GitHub Desktop.
Copy_file(s)_to_dir_from_python
def save_file(pout):
"""
Copy some of the execution files.
Those are hardcoded and include the file that the function is.
:return:
"""
from os import getcwd, makedirs
from os.path import join
from shutil import copy2
try:
# get the python file name
pfn = __file__
except NameError:
m1 = 'Probably a notebook, cannot save it.'
print(m1)
return -1
p1 = getcwd()
files = [pfn, 'other_file_in_path.py']
for f in files:
makedirs(pout)
po = join(pout, f)
copy2(join(p1, f), po)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment