[Python-au] blind spot with os.path

Tennessee Leeuwenburg tleeuwenburg at gmail.com
Thu Oct 15 09:36:43 UTC 2009


My impression was that Mike had a whole lot of files such as
leave_empty1.text, leave_empty2.txt, leave_empty3.txt, which should all
match the pattern leave_empty*.*

Cheers,
-T

On Thu, Oct 15, 2009 at 8:06 PM, raf <raf at raf.org> wrote:

> Mike Dewhirst wrote:
>
> > The problem I find is that Python seems to be using the wrong default
> > path separator here ...
> >
> >
> 'C:\\users\\miked\\py\\chemdata\\src\\getmsds\\testlinks\\leave_empty/*.*'
> >
> > ... and which line can be seen below in context as part of the traceback.
> >
> > I'm sure Windows did not add the /*.* and I certainly didn't. That
> > leaves Python as the obvious suspect.
> >
> > Any clues appreciated
> >
> > Thanks
> > Mike
>
> hi,
>
> forward slash works fine on windows.
> i don't think that's the problem.
> does the leave_empty directory actually exist?
> that might be the problem. i can't see mkdir
> anywhere in the code.
>
> cheers,
> raf
>
> > --- code being tested on Windows XP with Python 2.6 ---
> >
> > class GetBase(object):
> >
> >     def __init__(self, basedir=basedir, ext=ext):
> >         self.basedir = basedir
> >         self.ext = ext
> >
> >     def filelist(self):
> >         # return list of (ccode, filename) tuples
> >         filelist = os.listdir(self.basedir)
> >         retlist = []
> >         for item in filelist:
> >             if self.ext in item:
> >                 (ccode, toss) = item.split("_", 1)
> >                 retlist.append((ccode, item))
> >         return retlist
> >
> >
> > --- tests.py excerpt ---
> >
> > import os, unittest
> > import sds
> >
> > emptydir = 'leave_empty'
> > testdir = os.getcwd() + os.path.sep + 'testlinks'
> >
> > class test_sds(unittest.TestCase):
> >
> >     def test_files_not_exist(self):
> >         """ 1 """
> >         filesdir = testdir + os.path.sep + emptydir
> >         print(filesdir)
> >         tsto = sds.GetBase(filesdir)
> >         numf = len(tsto.filelist())
> >         print('%s' % numf)
> >         self.assertEqual(numf == 0, True)
> >
> > --- error ---
> >
> > Traceback (most recent call last):
> >   File "tests.py", line 85, in test_files_not_exist
> >     numf = len(tsto.filelist())
> >   File "C:\users\miked\py\chemdata\src\getmsds\sds.py", line 39, in
> > filelist
> >     filelist = os.listdir(self.basedir)
> > WindowsError: [Error 3] The system cannot find the path specified:
> >
> 'C:\\users\\miked\\py\\chemdata\\src\\getmsds\\testlinks\\leave_empty/*.*'
> >
> >
> >
> > _______________________________________________
> > python-au maillist  -  python-au at starship.python.net
> > http://starship.python.net/mailman/listinfo/python-au
>
> _______________________________________________
> python-au maillist  -  python-au at starship.python.net
> http://starship.python.net/mailman/listinfo/python-au
>



-- 
--------------------------------------------------
Tennessee Leeuwenburg
http://myownhat.blogspot.com/
"Don't believe everything you think"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://starship.python.net/pipermail/python-au/attachments/20091015/654d1d66/attachment.htm>


More information about the python-au mailing list