FAQ
Is the best way to do this to just issue a shell command using getstatus or
something similar? I have a file descriptor created with open. I'd rather
not deal with constructing the entire path string if I can avoid it.

Thanks for any advice,

-Gary

Search Discussions

  • Greg Jorgensen at Mar 21, 2001 at 12:07 am

    You can get the name of an open file from the file object's name attribute:

    f = open('foo')
    f.name
    'foo'

    If you always open your files with full absolute paths (rather than relative
    to the current working directory) you can then retrieve that path from the
    f.name attribute. With a full path, deleting the file is simple:
    f.close()
    os.remove(f.name)
    The os.path module has functions for converting relative paths to absolute
    paths.

    "Gary" <glevenson at mediaone.net> wrote in message
    news:RSRt6.2154$nd.2670928 at typhoon.ne.mediaone.net...
    Is the best way to do this to just issue a shell command using getstatus or
    something similar? I have a file descriptor created with open. I'd rather
    not deal with constructing the entire path string if I can avoid it.
    --
    Greg Jorgensen / programmer, pedant, raconteur / Portland, Oregon, USA

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMar 20, '01 at 11:39p
activeMar 21, '01 at 12:07a
posts2
users2
websitepython.org

2 users in discussion

Gary: 1 post Greg Jorgensen: 1 post

People

Translate

site design / logo © 2022 Grokbase