[Python-de] Anfängerfrage: Verzeichnisinhalt mit Variable vergleichen
Marcus Klein
python at marcus1.de
Sat May 11 17:54:47 EDT 2002
Hallo zusammen,
habe folgendes Problem:
Ich vergleich den Inhalt eines Verzeichnisses mit einer Variablen, um zu
vermeiden, daß eine Datei, falls vorhanden überschrieben wird, leider
klappt's noch nicht ganz so, wie ich es mir vorgestellt habe,
Vielleicht kann mir jemand helfen ?
--8<--
for f in TOGET:
print "getting remote file ", f
fname = PATHTOFILE + f
lfiles = os.listdir(PATHTOFILE)
lfile = re.compile(f, re.M).search(lfiles, 1)
if lfile:
print "Warning: File exists locally"
exit(5)
-->8--
führt zu:
--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--
Danke im Voraus,
marcus
More information about the Python-de
mailing list