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
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
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
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
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
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
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
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.
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
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
10 matches
Mail list logo