On Thu, Sep 6, 2012 at 8:55 PM, ruck <john.ruckst...@gmail.com> 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...' > You can try: the other, then if not there > except:mkdir<http://mail.python.org/mailman/listinfo/python-list>goo > and obviously, don't use ..., use ___, or something else. It also sems that the file must exist, so did you have a file named 'goo...'? If not, it wouldn't create one, so you would have to, either by manual, or coded by a try/except. Below is how it could go: import os try: os.stat('/home/david/whatever') except: os.mkdir('/home/david/whatever') -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com*
-- http://mail.python.org/mailman/listinfo/python-list