A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20160410/ae882c9a/attachment.html below:

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">


  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    I talked to my colleague. He didn't remember the concrete use-case,
    though, he instantly mentioned three possible things (no order of
    preference):<br>
    <br>
    1) pathlib + mtime<br>
    2) os.walk and pathlib<br>
    3) creation/removal of paths<br>
    <br>
    He wasn't too sure but I checked with the docs and his memories
    seemed to be correct:<br>
    <br>
    <br>
    -----<br>
    <br>
    1) <a class="moz-txt-link-freetext" href="https://docs.python.org/3/library/pathlib.html#pathlib.Path.stat">https://docs.python.org/3/library/pathlib.html#pathlib.Path.stat</a><br>
    <br>
    High-level path objects should return high-level [insert type here]
    objects. Put differently, an API for retrieving time-stats as real
    date/time objects would be nice. I think that can be expanded to
    other pathlib methods as well, to make them less "os-wrapper"-like
    and provide added value.<br>
    <br>
    <br>
    -----<br>
    <br>
    2) I remember a discussion on python-ideas about using "glob" or
    "rglob". However, when searching the docs for "walk" like in
    "os.walk" or for "iter", I don't find "glob"/"rglob". I can imagine
    ourselves (pathlib newbies back then), we didn't discover them.<br>
    <br>
    It would be great if the docs could be improved like the following:<br>
    <br>
    """<br>
    Path.rglob(pattern)<br>
    Walk down a given path; a wrapper for "os.scandir"/"os.listdir".
    This is like calling glob() with â€œ**” added in front of the given
    pattern:<br>
    """<br>
    <br>
    I think it would make "glob" and "rglob" more discoverable to new
    users.<br>
    <br>
    NOTE: """
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    Using the â€œ**” pattern in large directory trees may consume an
    inordinate amount of time.""" sounds not really encouraging. This is
    especially true for  "rglob" as it is defined as "like calling
    glob() with â€œ**”".<br>
    <br>
    That leads to wondering whether "rglob" performs slow globbing
    instead of a "os.scandir"/"os.listdir".<br>
    <br>
    <a class="moz-txt-link-freetext" href="https://docs.python.org/3/library/pathlib.html#basic-use">https://docs.python.org/3/library/pathlib.html#basic-use</a> even
    promotes "glob" with "**" in the beginning which seems rather
    discouraging to use "rglob" as a fast alternative to
    "os.walk/scandir/listdir". Renaming "rglob"/adding a "scan" method
    would definitely help here.<br>
    <br>
    <br>
    -----<br>
    <br>
    3) Again searching the docs for "create", "delete" (nothing found)
    and "remove", I found "Path.touch", "Path.rmdir" and "Path.unlink".<br>
    <br>
    It would be great if we had an easy way to remove a complete subtree
    as with "shutil.rmtree". We mostly don't care if a directory is
    empty. We need the system to be in a state of "this path does not
    exist anymore".<br>
    <br>
    Moreover, touching a file is good enough to "create" it if you don't
    care about changing its mtime. It you care about its mtime, it's a
    problem to "touch".<br>
    <br>
    ------<br>
    <br>
    <br>
    That's it for our issues with pathlib from the past. Additionally, I
    got two further observations:<br>
    <br>
    A) pathlib tries to mimic/publish some low-level APIs to its users.
    "unlink" is not something people would expect to use when they want
    to "delete" or to "remove" a file or a directory. I know where the
    term stems from but it's the wrong layer of abstraction IMHO. Same
    for "touch" or "chmod".<br>
    <br>
    B) "rename" vs "replace". The difference is not really clear from
    the docs. You need to read "Path.replace" in order to understand
    "Path.rename" completely. (one raises an exception, the other don't
    if I read it correctly).<br>
    <br>
    <br>
    If there's some agreement to change things with respect to those 5
    points, I am willing to put some time into it.<br>
    <br>
    <br>
    Best,<br>
    Sven<br>
  </body>
</html>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4