Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28666

Re: os.stat() distorts filenames that end with period (nt.stat())

Newsgroups comp.lang.python
Date 2012-09-06 18:54 -0700
References <da480cba-c79a-44bc-bcfc-b192ce5aca69@googlegroups.com> <mailman.341.1346980737.27098.python-list@python.org>
Subject Re: os.stat() distorts filenames that end with period (nt.stat())
From ruck <john.ruckstuhl@gmail.com>
Message-ID <mailman.345.1346982861.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Thursday, September 6, 2012 6:19:11 PM UTC-7, Dave Angel wrote:
> 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

Thanks, I agree, I expect this is Windows 7 or win32 specific.

Also, in creating a test case to demonstrate, I may have clouded my intent.
I want to walk() a dir, 
reporting the output of os.stat() for files below the dir.
One of the existing files happens to be named like "goo..."
And os.stat('goo...') fails to see the file.
I am not trying to rename the file, just hoping to stat an existing file.
John

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

os.stat() distorts filenames that end with period (nt.stat()) ruck <john.ruckstuhl@gmail.com> - 2012-09-06 17:55 -0700
  Re: os.stat() distorts filenames that end with period (nt.stat()) Dave Angel <d@davea.name> - 2012-09-06 21:18 -0400
    Re: os.stat() distorts filenames that end with period (nt.stat()) ruck <john.ruckstuhl@gmail.com> - 2012-09-06 18:54 -0700
    Re: os.stat() distorts filenames that end with period (nt.stat()) ruck <john.ruckstuhl@gmail.com> - 2012-09-06 18:54 -0700
  Re: os.stat() distorts filenames that end with period (nt.stat()) alex23 <wuwei23@gmail.com> - 2012-09-06 18:49 -0700
    Re: os.stat() distorts filenames that end with period (nt.stat()) ruck <john.ruckstuhl@gmail.com> - 2012-09-06 19:46 -0700
  Re: os.stat() distorts filenames that end with period (nt.stat()) Terry Reedy <tjreedy@udel.edu> - 2012-09-06 22:05 -0400
    Re: os.stat() distorts filenames that end with period (nt.stat()) ruck <john.ruckstuhl@gmail.com> - 2012-09-06 22:54 -0700
    Re: os.stat() distorts filenames that end with period (nt.stat()) ruck <john.ruckstuhl@gmail.com> - 2012-09-06 22:54 -0700
  Re: os.stat() distorts filenames that end with period (nt.stat()) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-07 02:32 +0000
  Re: os.stat() distorts filenames that end with period (nt.stat()) Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-06 21:12 -0600

csiph-web