Getting a path from a file object

Ken Starks straton at lampsacos.demon.co.uk
Sat Jul 5 13:13:46 CEST 2008


Andrew Fong 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
Read about f.name which is a kind of read-only attribute with caveats
in the documentation:


http://docs.python.org/lib/bltin-file-objects.html



More information about the Python-list mailing list