To get the directory of the current running script try: import os.path path = os.path.dirname(__file__)
- Gennadiy <gennad.zlo...@gmail.com> On Mon, Mar 14, 2011 at 3:25 PM, Alexander Schatten <asch...@gmail.com>wrote: > Hi, > > could someone help me with a small problem? I wrote a Python script > that does some RegEx... transformations. Now, this script loads some > configuration data from a file located in the same directory: > > open ('config.txt', 'r'). > > However, this only works when I execute the script being in the > directory where the script is locates, because otherwise, of course, > this config file is not found, as the path is relative. Now my > question: is there an easy way (API) to get the directory of the > currently running script? Something along the line of: > > open (API.getCurrentPath + 'config.txt', 'r'). > > > thanks a lot, > > cheers > > Alex > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list