Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(although': 0.05; 'attribute': 0.09; 'from:addr:timgolden.me.uk': 0.09; 'from:name:tim golden': 0.09; 'message-id:@timgolden.me.uk': 0.09; 'subject:file': 0.14; 'wrote:': 0.14; 'eckhardt': 0.16; 'fwiw': 0.16; 'istm': 0.16; 'it",': 0.16; 'obviously,': 0.16; 'pathname': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'entries': 0.16; 'cc:addr:python-list': 0.17; "hasn't": 0.19; 'issue,': 0.19; 'header:In-Reply-To:1': 0.21; 'file,': 0.22; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'trying': 0.23; 'changed': 0.25; "i'm": 0.27; 'problem': 0.28; 'depends': 0.29; 'skip:" 30': 0.29; "he's": 0.29; 'least': 0.30; 'cc:addr:python.org': 0.30; 'changed.': 0.30; 'tjg': 0.30; '(including': 0.32; 'things': 0.33; 'file': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'platform': 0.36; 'open': 0.36; 'issue': 0.37; 'case': 0.37; 'another': 0.37; 'could': 0.38; 'subject:from': 0.38; 'but': 0.38; 'though': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'happened': 0.39; 'windows.': 0.39; 'your': 0.60; 'opened': 0.63; 'full': 0.63; 'from:addr:mail': 0.65; 'subject:name': 0.67; 'dealing': 0.69; 'afraid': 0.72; 'apart': 0.73; 'with,': 0.77; 'to:none': 0.93 Date: Wed, 25 May 2011 08:29:11 +0100 From: Tim Golden User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 CC: python-list@python.org Subject: Re: Obtaining a full path name from file References: <6af58349-43d3-4132-ab0a-a072852e6f3a@g12g2000yqd.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306308555 news.xs4all.nl 49046 [::ffff:82.94.164.166]:59773 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6200 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