What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-19 15:43:18
os path splitext
import os os.path.dirname(os.path.realpath(__file__)) Add solution -
Python 2021-11-19 14:57:18
template does not exist django
First solution: These settings TEMPLATE_DIRS = ( os.path.join(SETTINGS_PATH, 'templates'), ) mean that Django will look at the templates from templates/ directory under your project. Assuming your Django project is located at /usr/lib/python2.5/sit... Add solution -
Python 2021-11-15 15:40:26
how to determine python project parent dir
import os,sys,inspect currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(currentdir) sys.path.insert(0,parentdir) import mymodule OR import os, sys sys.path.insert(1, os.getcwd()) impo... Add solution -
Python 2021-11-07 08:38:20
configparser error reading relative file path
# the current directory can be changed by your program [or a module] # and it is in general not the directory of your program file import configparser, os config = configparser.ConfigParser() config.read(os.path.join(os.path.dirname(__file__), 'config.cf... Add solution -
Python 2021-11-04 18:38:13
get file in file zip python
from zipfile import ZipFile import os def getfilespath(filename): dir = os.path.dirname(__file__) return os.path.join(dir, filename) path = getfilespath("bbc-fulltext.zip") archive = ZipFile(path, 'r') files = archive.namelist() Add solution -
Python 2021-10-14 23:53:06
import file from parent directory python
import os,sys,inspect currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(currentdir) sys.path.insert(0,parentdir) import mymodule OR import os, sys sys.path.insert(1, os.getcwd()) impo... Add solution -