RE: python current path function?

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Mon, 18 Jan 2010 09:25:39 -0500

do the following

import os

path=os.split(fileNamePath)

 

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex Hall
Sent: Monday, January 18, 2010 6:52 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: python current path function?

Hi all,
I am trying to point python to the currently running script's directory so 
it can find an ini file there. I was told to use
ini=os.path.join(sys.argv[0],'name.ini')
but that returns the name.ini filename attached to the full path, including 
the script name:
c:\path\file.pyw\file.ini

I want just the path to the script, not the script itself. Also, I think I 
need it as a raw string or with double backslashes. How do I do this? 
Thanks!


Have a great day,
Alex
Email: mehgcap@xxxxxxxxx 

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: