Browse Source

Paths

pull/140/head
Jure Šorn 1 year ago
parent
commit
a9b6ec00e7
2 changed files with 8 additions and 8 deletions
  1. 8
      README.md
  2. 8
      index.html

8
README.md

@ -1636,7 +1636,7 @@ from glob import glob
``` ```
```python ```python
<list> = listdir(path='.') # Returns filenames located at path.
<list> = listdir(path='.') # Returns filenames located at the path.
<list> = glob('<pattern>') # Returns paths matching the wildcard pattern. <list> = glob('<pattern>') # Returns paths matching the wildcard pattern.
``` ```
@ -1648,15 +1648,15 @@ from glob import glob
```python ```python
<stat> = os.stat(<path>) # Or: <DirEntry/Path>.stat() <stat> = os.stat(<path>) # Or: <DirEntry/Path>.stat()
<real> = <stat>.st_mtime/st_size/… # Modification time, size in bytes,
<real> = <stat>.st_mtime/st_size/… # Modification time, size in bytes, ...
``` ```
### DirEntry ### DirEntry
**Unlike listdir(), scandir() returns DirEntry objects that cache isfile, isdir and on Windows also stat information, thus significantly increasing the performance of code that requires it.** **Unlike listdir(), scandir() returns DirEntry objects that cache isfile, isdir and on Windows also stat information, thus significantly increasing the performance of code that requires it.**
```python ```python
<iter> = scandir(path='.') # Returns DirEntry objects located at path.
<str> = <DirEntry>.path # Returns whole path as a string.
<iter> = scandir(path='.') # Returns DirEntry objects located at the path.
<str> = <DirEntry>.path # Returns the whole path as a string.
<str> = <DirEntry>.name # Returns final component as a string. <str> = <DirEntry>.name # Returns final component as a string.
<file> = open(<DirEntry>) # Opens the file and returns a file object. <file> = open(<DirEntry>) # Opens the file and returns a file object.
``` ```

8
index.html

@ -1392,7 +1392,7 @@ value = args.&lt;name&gt;
&lt;str&gt; = path.dirname(&lt;path&gt;) <span class="hljs-comment"># Returns path without the final component.</span> &lt;str&gt; = path.dirname(&lt;path&gt;) <span class="hljs-comment"># Returns path without the final component.</span>
&lt;tup.&gt; = path.splitext(&lt;path&gt;) <span class="hljs-comment"># Splits on last period of the final component.</span> &lt;tup.&gt; = path.splitext(&lt;path&gt;) <span class="hljs-comment"># Splits on last period of the final component.</span>
</code></pre> </code></pre>
<pre><code class="python language-python hljs">&lt;list&gt; = listdir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns filenames located at path.</span>
<pre><code class="python language-python hljs">&lt;list&gt; = listdir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns filenames located at the path.</span>
&lt;list&gt; = glob(<span class="hljs-string">'&lt;pattern&gt;'</span>) <span class="hljs-comment"># Returns paths matching the wildcard pattern.</span> &lt;list&gt; = glob(<span class="hljs-string">'&lt;pattern&gt;'</span>) <span class="hljs-comment"># Returns paths matching the wildcard pattern.</span>
</code></pre> </code></pre>
<pre><code class="python language-python hljs">&lt;bool&gt; = path.exists(&lt;path&gt;) <span class="hljs-comment"># Or: &lt;Path&gt;.exists()</span> <pre><code class="python language-python hljs">&lt;bool&gt; = path.exists(&lt;path&gt;) <span class="hljs-comment"># Or: &lt;Path&gt;.exists()</span>
@ -1400,10 +1400,10 @@ value = args.&lt;name&gt;
&lt;bool&gt; = path.isdir(&lt;path&gt;) <span class="hljs-comment"># Or: &lt;DirEntry/Path&gt;.is_dir()</span> &lt;bool&gt; = path.isdir(&lt;path&gt;) <span class="hljs-comment"># Or: &lt;DirEntry/Path&gt;.is_dir()</span>
</code></pre> </code></pre>
<pre><code class="python language-python hljs">&lt;stat&gt; = os.stat(&lt;path&gt;) <span class="hljs-comment"># Or: &lt;DirEntry/Path&gt;.stat()</span> <pre><code class="python language-python hljs">&lt;stat&gt; = os.stat(&lt;path&gt;) <span class="hljs-comment"># Or: &lt;DirEntry/Path&gt;.stat()</span>
&lt;real&gt; = &lt;stat&gt;.st_mtime/st_size/… <span class="hljs-comment"># Modification time, size in bytes, </span>
&lt;real&gt; = &lt;stat&gt;.st_mtime/st_size/… <span class="hljs-comment"># Modification time, size in bytes, ...</span>
</code></pre> </code></pre>
<div><h3 id="direntry">DirEntry</h3><p><strong>Unlike listdir(), scandir() returns DirEntry objects that cache isfile, isdir and on Windows also stat information, thus significantly increasing the performance of code that requires it.</strong></p><pre><code class="python language-python hljs">&lt;iter&gt; = scandir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns DirEntry objects located at path.</span>
&lt;str&gt; = &lt;DirEntry&gt;.path <span class="hljs-comment"># Returns whole path as a string.</span>
<div><h3 id="direntry">DirEntry</h3><p><strong>Unlike listdir(), scandir() returns DirEntry objects that cache isfile, isdir and on Windows also stat information, thus significantly increasing the performance of code that requires it.</strong></p><pre><code class="python language-python hljs">&lt;iter&gt; = scandir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns DirEntry objects located at the path.</span>
&lt;str&gt; = &lt;DirEntry&gt;.path <span class="hljs-comment"># Returns the whole path as a string.</span>
&lt;str&gt; = &lt;DirEntry&gt;.name <span class="hljs-comment"># Returns final component as a string.</span> &lt;str&gt; = &lt;DirEntry&gt;.name <span class="hljs-comment"># Returns final component as a string.</span>
&lt;file&gt; = open(&lt;DirEntry&gt;) <span class="hljs-comment"># Opens the file and returns a file object.</span> &lt;file&gt; = open(&lt;DirEntry&gt;) <span class="hljs-comment"># Opens the file and returns a file object.</span>
</code></pre></div> </code></pre></div>

Loading…
Cancel
Save