Re: Getting a path from a file object

2008-07-05 Thread Ken Starks
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 Rea

Re: Getting a path from a file object

2008-07-04 Thread [EMAIL PROTECTED]
On 4 juil, 20:37, 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) a

Re: Getting a path from a file object

2008-07-04 Thread Michael Mabin
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

Getting a path from a file object

2008-07-04 Thread Andrew Fong
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.pyth