os.stat() distorts filenames that end with period (nt.stat())
Dave Angel
d at davea.name
Thu Sep 6 21:18:28 EDT 2012
On 09/06/2012 08:55 PM, ruck wrote:
> (This with Python 2.7.2 on Windows 7)
>
> os.stat() won't recognize a filename ending in period.
> It will ignore trailing periods.
> If you ask it about file 'goo...' it will report on file 'goo'
> And if 'goo' doesn't exist, os.stat will complain.
>
> create file goo, then
>
> >>> os.stat('goo')
> nt.stat_result(st_mode=33206, st_ino=0L, st_dev=0, st_nlink=0, st_uid=0, st_gid=0, st_size=0L, st_atime=1346978160L, st_mtime=1346978160L, st_ctime=1346978160L)
> >>> os.stat('goo...')
> nt.stat_result(st_mode=33206, st_ino=0L, st_dev=0, st_nlink=0, st_uid=0, st_gid=0, st_size=0L, st_atime=1346978160L, st_mtime=1346978160L, st_ctime=1346978160L)
>
> rename goo to "goo...", then,
>
> >>> os.stat('goo...')
>
> Traceback (most recent call last):
> File "<pyshell#16>", line 1, in <module>
> os.stat('goo...')
> WindowsError: [Error 2] The system cannot find the file specified: 'goo...'
>
> Puzzling, to me at least.
> Any comments?
> This with Python 2.7.2 on Windows 7.
> Is there a workaround?
> Thanks,
> John
FWIW, it seems to work okay here in Linux 11.04, both Python 2.7 and 3.2
--
DaveA
More information about the Python-list
mailing list