[Newbie Question] Matching directory content with variable
Lei Chen
llchen223 at hotmail.com
Sun May 12 00:56:25 EDT 2002
Look into glob.glob()
Cheers
Marcus Klein <marcus1 at marcus1.de> wrote in message news:<h1ajba.ni5.ln at news.marcus1.de>...
> Hi out there,
>
> I am trying to match a directory content with a variable to avoid
> overwriting an existing file and it does not work.
>
> Maybe someone knows why ?
>
> --8<--
> for f in TOGET:
> print "getting remote file ", f
> fname = PATHTOFILE + f
>
> lfiles = os.listdir(PATHTOFILE)
> lfile = re.compile(f, re.M).match(lfiles, 1)
> if lfile:
> print "Warning: File exists locally"
> exit(5)
> -->8--
>
> leads to
>
> --8<--
> Traceback (most recent call last):
> File "py/getftp.py", line 33, in ?
> lfile = re.compile(f, re.M).match(lfiles, 1)
> TypeError: expected string or buffer
> -->8--
>
>
> thanx in advance,
>
> marcus
More information about the Python-list
mailing list