Reading text file with wierd file extension?

Stephen Hansen apt.shansen at gmail.com
Mon Feb 2 16:29:55 EST 2009


> class MyUtilityClass:
>    def __init__(self, DataFilepath):
>        Resourcepath  = DataFilepath + ".rsc"
>        DataFileH     = open(DataFilepath)
>        ResourceFileH = open(Resourcepath)


There's nothing wrong with this code. You have to look elsewhere in your
program-- perhaps what calls it. Perhaps in the filesystem to ensure there
really happens to be a rsc for this data file (maybe it got accidentally
deleted?)

Before you do any openings, try printing like:

print repr(DataFilepath)
print repr(Resourcepath)
print os.path.exists(Resourcepath)
print os.listdir(os.dirname(Resourcepath))

Something must jump out at that point to be obviously the problem. If not
and you still get a traceback, try mailing the list the output and the
actual traceback.

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090202/64b20d6b/attachment-0001.html>


More information about the Python-list mailing list