
Carl Kleffner wrote:
Ich hatte aber den Effekt, das os.listdir(pfad) keine Exception wirft und gleichzeitig os.path.isdir(pfad) false zurückgibt.
Auf os.path.isdir() (resp. generell auf os.stat()) wuerde ich mich in diesem Kontext auch nicht zu sehr verlassen. Ich habe das seither nicht mehr getestet, aber um aehnliche Probleme unter Windows zu umgehen habe ich vor einiger Zeit mal für Python 1.5.2 folgenden Ersatz gebastelt: def isdir(s): '''For os.path.isdir(), thanks to the broken posix stat(2) on Windows.''' if os.name == 'nt': if s[:2] == '\\\\': # UNC directories are only recognized *with* the trailing "\" if s[-1] != '\\': s = s + '\\' elif len(s) > 3 and s[1] == ':': # drive based paths are only recognized *without* the trailing "\" while s[-1] == '\\' and s[-2] != ':': s = s[:-1] elif len(s) == 2 and s[1] == ':': # except for the root path. s = s + '\\' return os.path.isdir(s) Ich weiss aber jetzt nicht mehr auswendig, welche der Probleme mit, und welche ohne Samba auftraten. Es kann auch sein, dass bei neueren Windows/Samba Versionen die Details anders sind. Vielleicht kann mal jemand mit Zugriff auf diverse Varianten systematischere Tests anstellen? Natürlich wäre es schön, wenn Python bei solchem relativ offensichtlichen Fehlverhalten des unterliegenden Systems das im jeweiligen Standardmodul abfangen würde. Oder hat sich da seither etwas getan? -schorsch -- Georg Mischler -- simulations developer -- schorsch at schorsch com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ _______________________________________________ Python-de maillist - Python-de@python.net http://python.net/mailman/listinfo/python-de