FAQ

Tim Golden wrote:
On 24/05/2011 16:36, 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 !
You're going to kick yourself:

f.name
There's trouble there, though:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
f = open ('xyzzy.txt')
f.name
'xyzzy.txt'
import os
os.getcwd()
'/home/mwilson'
os.chdir('sandbox')
f.name
'xyzzy.txt'


If you open a file and don't get a full path from os.path.abspath right
away, the name in the file instance can get out-of-date.

Mel.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 11 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedMay 24, '11 at 3:36p
activeMay 25, '11 at 11:05a
posts11
users8
websitepython.org

People

Translate

site design / logo © 2021 Grokbase