Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Platform-independent way to refer to execute path

Reply
Thread Tools

Platform-independent way to refer to execute path

 
 
MK
Guest
Posts: n/a
 
      06-25-2003
What would be the best platform-independent way to refer
to the current (execute) path for a Python script?

self.dirname = ???

This variable should contain directory name for the current path.
It should work on every platform (Linux, Windows...). I'm
not interested in parsing this string. That is, simple

f.write(self.dirname)

should work, withour ever peeking into the string. Thx,


 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      06-25-2003
MK wrote:
>
> What would be the best platform-independent way to refer
> to the current (execute) path for a Python script?
>
> self.dirname = ???
>
> This variable should contain directory name for the current path.


The question seems ambiguous to me. What is the "current path"?
There is a PATH environment variable, but you probably don't mean
that. There is also a current directory, or "current working directory",
which is accessible through os.getcwd(). Will that do? If so, make
sure you read the rest of the docs on the "os" module so you'll
know what is there for later.

-Peter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A way to refer to items in Session object without using Session directly Andy B ASP .Net 7 05-30-2008 10:49 AM
is there a way to refer to public properties in other user controls Web Search Store ASP .Net 11 04-23-2008 07:00 PM
can src attribute of an image tag refer to a unc path? TheUsenetReader@gmail.com HTML 21 12-14-2007 07:42 PM
How to refer path in Javascript ad ASP .Net 1 06-04-2005 03:18 AM
A better way to refer to DB columns? Darrel ASP .Net 3 10-29-2004 03:22 AM



Advertisments