Re: The folder a script is executed in

2007-08-22 Thread Benjamin
On Aug 21, 10:23 am, Benjamin <[EMAIL PROTECTED]> wrote: > On Aug 21, 4:10 am, [EMAIL PROTECTED] wrote:> Hi, > > > How do I find out what folder a script is in while it is executing? > > > For example, for the file "C:/folder/script.py" contain the following > > two lines of code - > > > myLocation

Re: The folder a script is executed in

2007-08-21 Thread kyosohma
On Aug 21, 10:23 am, Benjamin <[EMAIL PROTECTED]> wrote: > On Aug 21, 4:10 am, [EMAIL PROTECTED] wrote:> Hi, > > > How do I find out what folder a script is in while it is executing? > > > For example, for the file "C:/folder/script.py" contain the following > > two lines of code - > > > myLocation

Re: The folder a script is executed in

2007-08-21 Thread Benjamin
On Aug 21, 4:10 am, [EMAIL PROTECTED] wrote: > Hi, > > How do I find out what folder a script is in while it is executing? > > For example, for the file "C:/folder/script.py" contain the following > two lines of code - > > myLocation = GetMyLocation() > print myLocation def GetMyLocation(): run

Re: The folder a script is executed in

2007-08-21 Thread Bjoern Schliessmann
Ant wrote: > Fair point. On Win32 sys.argv[0] always seems to give the full > path rather than the relative path Strange. > - hadn't realised it was different for linux (?). Yes, I used GNU/Linux for the example. Regards, Björn -- BOFH excuse #148: Insert coin for new game -- http://ma

Re: The folder a script is executed in

2007-08-21 Thread Ant
On Aug 21, 10:47 am, Bjoern Schliessmann wrote: > Ant wrote: ... > | print os.path.split(sys.argv[0])[0] > > $ cd tmp > ~/tmp$ ../test.py > .. > ~/tmp$ > > That's rather not what's intended. I'd try os.path.abspath(__file__) > instead. Fair point. On Win32 sys.argv[0] always seems to give the ful

Re: The folder a script is executed in

2007-08-21 Thread Bjoern Schliessmann
Ant wrote: > Do you mean the folder containing the script? Or the current > working directory? > > If the former, then look at os.path.split(sys.argv[0])[0] test.py: | #!/usr/bin/env python | import sys,os | print os.path.split(sys.argv[0])[0] $ cd tmp ~/tmp$ ../test.py .. ~/tmp$ That's rath

Re: The folder a script is executed in

2007-08-21 Thread Ant
On Aug 21, 10:29 am, [EMAIL PROTECTED] wrote: > On 21 Aug, 11:27, Ant <[EMAIL PROTECTED]> wrote: > > > > > On Aug 21, 10:10 am, [EMAIL PROTECTED] wrote: > > ... > > > > myLocation = GetMyLocation() > > > print myLocation > > > > >> C:/folder > > > Do you mean the folder containing the script? Or th

Re: The folder a script is executed in

2007-08-21 Thread aine_canby
On 21 Aug, 11:27, Ant <[EMAIL PROTECTED]> wrote: > On Aug 21, 10:10 am, [EMAIL PROTECTED] wrote: > ... > > > myLocation = GetMyLocation() > > print myLocation > > > >> C:/folder > > Do you mean the folder containing the script? Or the current working > directory? > > If the former, then look at os.

Re: The folder a script is executed in

2007-08-21 Thread Ant
On Aug 21, 10:10 am, [EMAIL PROTECTED] wrote: ... > myLocation = GetMyLocation() > print myLocation > > >> C:/folder Do you mean the folder containing the script? Or the current working directory? If the former, then look at os.path.split(sys.argv[0])[0] If the latter, try something like: os.path

The folder a script is executed in

2007-08-21 Thread aine_canby
Hi, How do I find out what folder a script is in while it is executing? For example, for the file "C:/folder/script.py" contain the following two lines of code - myLocation = GetMyLocation() print myLocation >> C:/folder Thanks, Aine. -- http://mail.python.org/mailman/listinfo/python-list