f.name will return the path. But if you want to guarantee getting the absolute pathname use os.path.abspath
>>> import os >>> os.path.abspath(f.name) '/some/path/file.ext' On Fri, Jul 4, 2008 at 1:37 PM, Andrew Fong <[EMAIL PROTECTED]> wrote: > Newbie question: > > Let's say I open a new file for writing in a certain path. How do I > get that path back? > > Example: > > >>> f = open('/some/path/file.ext') > >>> some_function(f) > '/some/path/file.ext' > > Does some_function(f) already exist? And if not, how would I define > it? > > -- Andrew > -- > http://mail.python.org/mailman/listinfo/python-list > -- | _ | * | _ | | _ | _ | * | | * | * | * |
-- http://mail.python.org/mailman/listinfo/python-list