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


Groups > comp.lang.python > #6221

Re: Obtaining a full path name from file

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <SRS0=M9gk=YP=ieee.org=davea@srs.perfora.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'sorts': 0.04; 'string.': 0.04; 'string,': 0.05; 'backslash': 0.09; 'filename': 0.09; 'pm,': 0.10; 'subject:file': 0.14; 'wrote:': 0.14; 'literals': 0.16; 'pathname': 0.16; 'cc:addr:python-list': 0.17; 'starts': 0.20; '(which': 0.20; 'work,': 0.20; 'header:In-Reply-To:1': 0.21; 'file,': 0.22; 'cc:2**0': 0.22; 'stuff': 0.22; 'cc:no real name:2**0': 0.23; 'literal': 0.23; 'pointed': 0.25; 'string': 0.26; 'windows': 0.26; 'tried': 0.27; 'skip:" 30': 0.29; 'cc:addr:python.org': 0.30; 'it.': 0.31; 'equal': 0.31; 'generally': 0.33; 'greatly': 0.33; "i've": 0.33; 'header:User- Agent:1': 0.35; 'probably': 0.36; 'specially': 0.37; 'think': 0.38; 'subject:from': 0.38; 'but': 0.38; 'appreciated': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'received:192': 0.38; 'should': 0.39; 'finding': 0.39; 'help': 0.40; 'received:192.168.1': 0.40; 'forward': 0.62; 'double': 0.62; 'full': 0.63; 'saw': 0.64; 'subject:name': 0.67; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72; '02:59': 0.84; 'surprises.': 0.84; 'things:': 0.93
Date Wed, 25 May 2011 07:05:16 -0400
From Dave Angel <davea@ieee.org>
User-Agent Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10
MIME-Version 1.0
To RVince <rvince99@gmail.com>
Subject Re: Obtaining a full path name from file
References <6af58349-43d3-4132-ab0a-a072852e6f3a@g12g2000yqd.googlegroups.com>
In-Reply-To <6af58349-43d3-4132-ab0a-a072852e6f3a@g12g2000yqd.googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:94Qjh4lllkroxht2lcFzuq2jRMhAa+KMuEV/z7b48a1 dt8LtZt4pNRxCEK2dMcwHUfbs9miyWkAX5vJIVqcfoR6KeHr6y spFa1YvzkEsoJ4Cou8dmLyMAOQUu2RuvbBY3bLIxpRkjYEt9ag pjW07npuysvMB03pJ4p10fMtb3HXsTuNLxtiWIn97+rl6uIO2T X2sIhTs3sBtD9CfqoAJlQ==
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To davea@ieee.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2067.1306321544.9059.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 82.94.164.166
X-Trace 1306321545 news.xs4all.nl 49180 [::ffff:82.94.164.166]:37876
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6221

Show key headers only | View raw


On 01/-10/-28163 02:59 PM, 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? (which should
> equal "C:\AciiCsv\Gravity_Test_data"). I've tried all sorts of stuff
> and am just not finding it. Any help greatly appreciated !
>

I saw lots of responses, but I don't think anybody pointed out that the 
filename is probably invalid.  This particular string will work, but if 
you have a directory that starts with a T or an N, you may get some 
surprises.  The backslash is treated specially in a literal string.

When building a Windows directory name in a literal string, you 
generally need to do one of three things:

1) use raw literals
2) double the backslash
3) use a forward slash

DaveA

Back to comp.lang.python | Previous | NextPrevious 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