Skip to content

Instantly share code, notes, and snippets.

@SrChach
Last active August 28, 2019 19:05
Show Gist options
  • Save SrChach/c4ed984e2631e8e30902515c8616edfc to your computer and use it in GitHub Desktop.
Save SrChach/c4ed984e2631e8e30902515c8616edfc to your computer and use it in GitHub Desktop.
Code to dynamic imports in python
from importlib import import_module
my_module_new_name = import_module('variable.module.name')
import os
script_dir = os.path.dirname(__file__) # Ruta absoluta del script que estás corriendo
relative_path = "../algo.csv" # Pones la parte relativa de la ruta
abs_file_path = os.path.join(script_dir, relative_path) # Los unes
fp = open(abs_file_path,'r+')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment