Python horks on WinXP path names

Eric einazaki668 at yahoo.com
Thu Dec 8 15:16:36 EST 2011


I'm running Python 2.7 on WinXP (ActiveState community version) and
when I try to do this:

if __name__ == '__main__':
    root = Tkinter.Tk()
    root.withdraw()
    fileNames = tkFileDialog.askopenfilenames()
    root.destroy()
    print fileNames
# windows filename gets
for fileName in fileNames:
    print fileName
    file = open(fileName, 'r')
    for line in file.readlines():
	    print line.strip()


I get this:

C:\Documents and Settings\eric\Desktop\PythonShop>python picker.py
{C:/Documents and Settings/eric/Desktop/PythonShop/cereal.py}
{
Traceback (most recent call last):
  File "picker.py", line 31, in <module>
    file = open(fileName, 'r')
IOError: [Errno 2] No such file or directory: u'{'

That is, fileName is in a form that open() doesn't recognize.  On a
BSD box the code works fine.  What's going on with the file name and
how do I fix it?


TIA,
eric



More information about the Python-list mailing list