• FYI: "iterdir" of "pathlib" on "Windows"

    From Stefan Ram@21:1/5 to All on Mon Jun 12 18:50:02 2023
    I did some work today on a project to verify a backup copy
    of a large directory with subdirectories.

    To give some context: the calls "iterdir" and "exists" below
    belong to "pathlib.Path" objects, in the first case to a directory.

    At first, one part in my code looked like this:

    for entry in source.iterdir():
    if not entry.exists():
    print( "Can't happen." )

    . Soon, "Can't happen." appeared on my screen (and there was nothing
    deleted from the directory between the "iterdir" and the "exists")!

    Now I edited it thus:

    for entry in source.iterdir():
    if not entry.exists():
    print( "\007\nSomething's is wrong with this path. "+
    "It's probably too long. I can't use it this way.\n" +
    "In this case, it might help to shorten it manually "+
    "in source and target and restart!\n" + str( entry ))

    .

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)