interestingly... I wanted to reuse this code so i wrote function in a file def getParentDir(): import os return os.path.dirname(os.path.abspath(__file__))
and called this function, in another file, its giving me parent directory of file where this function is defined.? how to reuse this piece of code then? or am i doing something wrong? btw using __path__[0], I can get the parent directory of file too... sandip On Nov 5, 5:09 am, Giampaolo Rodola' <[EMAIL PROTECTED]> wrote: > On 3 Nov, 15:46, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > > > > En Sat, 03 Nov 2007 10:07:10 -0300, Giampaolo Rodola' <[EMAIL PROTECTED]> > > escribió: > > > > On 3 Nov, 04:21, klenwell <[EMAIL PROTECTED]> wrote: > > >> In PHP you have the __FILE__ constant which gives you the value of the > > >> absolute path of the file you're in (as opposed to the main script > > >> file.) > > > This is not really 'one-line' since you have to import two modules > > > first, but it looks nicer...: > > > > import sys, os > > > print sys.argv[0] # absolute file name > > > print os.path.dirname(sys.argv[0]) # absolute dir name > > > Note that this returns the location of the *main* script, not the current > > module, as the OP explicitely asked for. > > > -- > > Gabriel Genellina > > Whoops! You're right.
-- http://mail.python.org/mailman/listinfo/python-list