Getting a path from a file object

bruno.desthuilliers at gmail.com bruno.desthuilliers at gmail.com
Fri Jul 4 16:07:23 EDT 2008


On 4 juil, 20:37, Andrew Fong <FongAnd... at gmail.com> 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?

Nope. But:

> And if not, how would I define
> it?

Not sure it's worth defining a function:

def some_function(f):
    return f.name




> -- Andrew




More information about the Python-list mailing list