<pre><codeclass="python language-python hljs"><bool> = any(<collection>) <spanclass="hljs-comment"># False if empty.</span>
<bool> = all(el[<spanclass="hljs-number">1</span>] <spanclass="hljs-keyword">for</span> el <spanclass="hljs-keyword">in</span><collection>) <spanclass="hljs-comment"># True if empty.</span>
<pre><codeclass="python language-python hljs"><bool> = any(<collection>) <spanclass="hljs-comment"># False if empty.</span>
<bool> = all(el[<spanclass="hljs-number">1</span>] <spanclass="hljs-keyword">for</span> el <spanclass="hljs-keyword">in</span><collection>) <spanclass="hljs-comment"># True if empty.</span>
shutil.rmtree(<path>) <spanclass="hljs-comment"># Deletes an entire directory tree.</span>
</code></pre>
<pre><codeclass="python language-python hljs">os.rename(<spanclass="hljs-keyword">from</span>, to) <spanclass="hljs-comment"># Renames the file or directory.</span>
os.replace(<spanclass="hljs-keyword">from</span>, to) <spanclass="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
<pre><codeclass="python language-python hljs">os.rename(<spanclass="hljs-keyword">from</span>, to) <spanclass="hljs-comment"># Renames the file or directory.</span>
os.replace(<spanclass="hljs-keyword">from</span>, to) <spanclass="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
</code></pre>
<pre><codeclass="python language-python hljs">os.mkdir(<path>, mode=<spanclass="hljs-number">0o777</span>) <spanclass="hljs-comment"># Creates a directory.</span>
<iter> = os.scandir(path=<spanclass="hljs-string">'.'</span>) <spanclass="hljs-comment"># Returns os.DirEntry objects located at path.</span>
<pre><codeclass="python language-python hljs">os.mkdir(<path>, mode=<spanclass="hljs-number">0o777</span>) <spanclass="hljs-comment"># Creates a directory.</span>
<iter> = os.scandir(path=<spanclass="hljs-string">'.'</span>) <spanclass="hljs-comment"># Returns os.DirEntry objects located at path.</span>
</code></pre>
<h4id="direntry">DirEntry:</h4>
<pre><codeclass="python language-python hljs"><str> = <DirEntry>.name <spanclass="hljs-comment"># Final component of the path.</span>
<str> = <DirEntry>.path <spanclass="hljs-comment"># Path with final component.</span>
<bool> = <DirEntry>.is_file()
<pre><codeclass="python language-python hljs"><str> = <DirEntry>.name <spanclass="hljs-comment"># Final component of the path.</span>
<str> = <DirEntry>.path <spanclass="hljs-comment"># Path with final component.</span>
<pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> time <spanclass="hljs-keyword">import</span> time
start_time = time() <spanclass="hljs-comment"># Seconds since Epoch.</span>
start_time = time() <spanclass="hljs-comment"># Seconds since Epoch.</span>
...
duration = time() - start_time
</code></pre>
<h3id="highperformance">High Performance</h3>
<pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> time <spanclass="hljs-keyword">import</span> perf_counter <spanclass="hljs-keyword">as</span> pc
start_time = pc() <spanclass="hljs-comment"># Seconds since restart.</span>
start_time = pc() <spanclass="hljs-comment"># Seconds since restart.</span>