Reading text file with wierd file extension?

Stephen Hansen apt.shansen at
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

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list