8000 List, Paths · gto76/python-cheatsheet@5328b93 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5328b93

Browse files
committed
List, Paths
1 parent 2d08cb5 commit 5328b93

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if __name__ == '__main__': # Skips next line if file was imported.
2929
List
3030
----
3131
```python
32-
<list> = [<el_1>, <el_2>, ...] # Creates new list. Also list(<collection>).
32+
<list> = [<el_1>, <el_2>, ...] # Creates a list object. Also list(<collection>).
3333
```
3434

3535
```python
@@ -1664,7 +1664,7 @@ from pathlib import Path
16641664
<iter> = os.scandir(path='.') # Returns DirEntry objects located at the path.
16651665
<str> = <DirEntry>.path # Returns the whole path as a string.
16661666
<str> = <DirEntry>.name # Returns final component as a string.
1667-
<file> = open(<DirEntry>) # Opens the file and returns a file object.
1667+
<file> = open(<DirEntry>) # Opens the file and returns its file object.
16681668
```
16691669

16701670
### Path Object

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
<body>
5858
<header>
59-
<aside>May 2, 2025</aside>
59+
<aside>May 3, 2025</aside>
6060
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
6161
</header>
6262

@@ -111,7 +111,7 @@
111111
main() <span class="hljs-comment"># Runs `def main(): ...` function.</span>
112112
</code></pre></div>
113113

114-
<div><h2 id="list"><a href="#list" name="list">#</a>List</h2><pre><code class="python language-python hljs">&lt;list&gt; = [&lt;el_1&gt;, &lt;el_2&gt;, ...] <span class="hljs-comment"># Creates new list. Also list(&lt;collection&gt;).</span>
114+
<div><h2 id="list"><a href="#list" name="list">#</a>List</h2><pre><code class="python language-python hljs">&lt;list&gt; = [&lt;el_1&gt;, &lt;el_2&gt;, ...] <span class="hljs-comment"># Creates a list object. Also list(&lt;collection&gt;).</span>
115115
</code></pre></div>
116116

117117
<pre><code class="python language-python hljs">&lt;el&gt; = &lt;list&gt;[index] <span class="hljs-comment"># First index is 0. Last -1. Allows assignments.</span>
@@ -1414,7 +1414,7 @@
14141414
<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; = os.scandir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns DirEntry objects located at the path.</span>
14151415
&lt;str&gt; = &lt;DirEntry&gt;.path <span class="hljs-comment"># Returns the whole path as a string.</span>
14161416
&lt;str&gt; = &lt;DirEntry&gt;.name <span class="hljs-comment"># Returns final component as a string.</span>
1417-
&lt;file&gt; = open(&lt;DirEntry&gt;) <span class="hljs-comment"># Opens the file and returns a file object.</span>
1417+
&lt;file&gt; = open(&lt;DirEntry&gt;) <span class="hljs-comment"># Opens the file and returns its file object.</span>
14181418
</code></pre></div>
14191419

14201420

@@ -2940,7 +2940,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29402940

29412941

29422942
<footer>
2943-
<aside>May 2, 2025</aside>
2943+
<aside>May 3, 2025</aside>
29442944
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29452945
</footer>
29462946

0 commit comments

Comments
 (0)
0