Monika Jisswel wrote:
import sys      #a module that gives access to the system
import os        #a module that gives access to the os

print sys.argv[0]   #prints file name of the script
print os.getcwd()   #print current working directory
print os.getcwd()+sys.argv[0]   #

but os.getcwd() returns the current working directory, not necessarily the directory containing the script. os.getcwd()+sys.argv[0] will quite often not yield a useful result. Even if it did, os.path.join is better than + when joining pathnames.





2008/7/5 Nathan Farrar <[EMAIL PROTECTED]>:

 I'm new to python and wondering if there is a way to reference information
about the script that is running.  For example, if I was running a script
named "FileInfo.py" from the directory "/home/username", I'm looking for
attributes such that something similar to:

print self.name
print self.path

would output:

FileInfo.py
/home/username

... Thanks!
Nathan

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor




------------------------------------------------------------------------

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to