[Tutor] listdir, ispath, and unicode

Rob rob@uselesspython.com
Tue, 30 Jul 2002 16:50:50 -0500


I'm also running Win2K on this machine and tried to reproduce your problem.
Here I ran os.listdir on the folder on C:\insight. It displayed its contents
in some detail.

>>> os.listdir('c:\\insight')
['abbrev.html', 'begin.html', 'glossary.html', 'history.html',
'index-author.html', 'index-names.html', 'index-number.html',
'index-similes.html', 'index-subject.html', 'index-sutta.html',
'index-title.html', 'index.html', 'other.html', 'sutta101.html',
'theravada.html', 'tech', 'cdrom', 'pali', 'ptf', 'icon', 'lib', 'canon',
'faq.html', 'help.html', 'news.html', 'search.html', 'bfaq.html',
'Tibet-HTML']

Then I ran os.path.isfile on one of the files in that folder thusly:

>>> os.path.isfile('c:\\insight\\index-sutta.html')
1
>>>

All seems well here. It seems that in your code you are asking if the folder
C:\tmp2 is a file, and you are being correctly told that it is not a file.

Do I have all of your facts correct?

Rob
http://uselesspython.com

> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> Poor Yorick
> Sent: Tuesday, July 30, 2002 3:54 PM
> To: tutor@python.org
> Subject: [Tutor] listdir, ispath, and unicode
>
>
> I am running Windows 2000 and have files which use cyrillic characters
> in their names.  I am running into this problem when I try to work with
> them:
>
>
>  >>> os.listdir('c:\\tmp2')[0]
> '????????.url'
>  >>> os.path.isfile(os.listdir('c:\\tmp2')[0])
> 0
>
>
> Can anyone tell me why os.path.isfile does not recognize my file?
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>