Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6200

Re: Obtaining a full path name from file

Date 2011-05-25 08:29 +0100
From Tim Golden <mail@timgolden.me.uk>
Subject Re: Obtaining a full path name from file
References <6af58349-43d3-4132-ab0a-a072852e6f3a@g12g2000yqd.googlegroups.com> <adkua8-mv4.ln1@satorlaser.homedns.org>
Newsgroups comp.lang.python
Message-ID <mailman.2055.1306308555.9059.python-list@python.org> (permalink)

Show all headers | View raw


On 25/05/2011 07:36, Ulrich Eckhardt wrote:
> RVince wrote:
>> s = "C:\AciiCsv\Gravity_Test_data\A.csv"
>> f = open(s,"r")
>>
>> How do I obtain the full pathname given the File, f?
>
> Apart from the issue that the 'name' attribute is only the name used to open
> the file, there is another issue, though not on the platform you're using:
> Multiple directory entries can point to the same file, all of which can be
> changed (including deletion!) even while you have the file open.

FWIW that's true even on Windows. (Although arguably less common).

> I'm not sure what problem you're trying to solve, but I'm afraid your
> approach is at least limited.

Depends on what the requirement is. If it is, essentially: "give me
at least one of the names this file had when I opened it", then this
approach is surely adequate. Certainly, things could have happened in 
the meantime. Obviously, only the OP can know the circumstances he's 
dealing with, but ISTM that far and away the most common case will
be that the file has exactly one name and that it hasn't changed.

TJG

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Obtaining a full path name from file RVince <rvince99@gmail.com> - 2011-05-24 08:36 -0700
  Re: Obtaining a full path name from file Tim Golden <mail@timgolden.me.uk> - 2011-05-24 16:52 +0100
    Re: Obtaining a full path name from file RVince <rvince99@gmail.com> - 2011-05-24 09:04 -0700
      Re: Obtaining a full path name from file Chris Angelico <rosuav@gmail.com> - 2011-05-25 02:08 +1000
      Re: Obtaining a full path name from file Tim Golden <mail@timgolden.me.uk> - 2011-05-24 17:10 +0100
      Re: Obtaining a full path name from file Jean-Michel Pichavant <jeanmichel@sequans.com> - 2011-05-24 18:13 +0200
    Re: Obtaining a full path name from file Mel <mwilson@the-wire.com> - 2011-05-24 12:04 -0400
  Re: Obtaining a full path name from file Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2011-05-25 08:36 +0200
    Re: Obtaining a full path name from file Tim Golden <mail@timgolden.me.uk> - 2011-05-25 08:29 +0100
  Re: Obtaining a full path name from file Dave Angel <davea@ieee.org> - 2011-05-25 07:05 -0400

csiph-web