Hi all,
I know that it it is not related to tkinter, but I had troubles in submitting in
the general python list.
I was trying to make my custom FileDialog to handle unicode filenames
and I stuck with the following behavior (python v2.7)
#path = "/home/bnv/Download"
path = u"/home/bnv/Download"
for fn in os.listdir(path):
print(fn,type(fn))
fullpath = os.path.join(path, fn)
If the "path" is defined as unicode I get the following output and error
(u'foo.py', <type 'unicode'>)
('Gewu\xccrzhalter.Part1.nc', <type 'str'>)
Traceback (most recent call last):
File "foo.py", line 20, in <module>
filename = os.path.join(path, fn)
File "/usr/lib/python2.7/posixpath.py", line 73, in join
path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 5: ordinal
not in range(128)
While if the "path" is defined as str. I get
('foo.py', <type 'str'>)
('Gewu\xccrzhalter.Part1.nc', <type 'str'>)
I don't understand why if the path is unicode the output of listdir is unicode
the filenames
containing only ascii and str for the file with the non-ascii character.
While if the path is str, all output is in str
Thanks in advance
Vasilis
_______________________________________________
Tkinter-discuss mailing list
[email protected]
https://mail.python.org/mailman/listinfo/tkinter-discuss