Skip to content

Commit 413a65c

Browse files
docs: Clean redundancy in docs and typos.
1 parent aebfe13 commit 413a65c

5 files changed

Lines changed: 140 additions & 159 deletions

File tree

docs/pages/reference/builtins.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ import prod_handler
438438
import dev_handler
439439

440440
def handle(env, request):
441-
return import_module(env + "_handler").handle(request)
441+
return import_module(env + "_handler").handle(request)
442442

443443
handle("prod", req)
444444
handle("dev", req)
@@ -544,18 +544,18 @@ Functions, type objects, and user classes expose `__name__` (the bare declared n
544544

545545
```python
546546
def greet():
547-
pass
547+
pass
548548

549549
class Box:
550-
pass
550+
pass
551551

552552
print(greet.__name__)
553553
print(int.__name__)
554554
print(Box.__name__)
555555
try:
556-
1 / 0
556+
1 / 0
557557
except Exception as e:
558-
print(type(e).__name__)
558+
print(type(e).__name__)
559559
```
560560

561561
```text Output
@@ -591,10 +591,10 @@ print(issubclass(bool, int))
591591
print(issubclass(KeyError, (ValueError, Exception)))
592592

593593
class A:
594-
pass
594+
pass
595595

596596
class B(A):
597-
pass
597+
pass
598598

599599
print(issubclass(B, A))
600600
print(issubclass(A, B))
@@ -745,9 +745,9 @@ fn = globals()['add']
745745
print(fn(3, 4))
746746

747747
def f():
748-
a = 1
749-
b = 2
750-
return locals()
748+
a = 1
749+
b = 2
750+
return locals()
751751
print(f())
752752
```
753753

@@ -765,8 +765,8 @@ Dicts are copies, mutation doesn't change VM bindings.
765765

766766
```python
767767
class Box:
768-
def __init__(self):
769-
pass
768+
def __init__(self):
769+
pass
770770

771771
b = Box()
772772
setattr(b, "x", 42)
@@ -802,9 +802,9 @@ print(xs[slice(0, 5, 2)])
802802

803803
```python
804804
class P:
805-
def __init__(self):
806-
self.x = 1
807-
self.y = 2
805+
def __init__(self):
806+
self.x = 1
807+
self.y = 2
808808

809809
p = P()
810810
print(vars(p))
@@ -822,12 +822,12 @@ print(vars(p))
822822

823823
```python
824824
class A:
825-
def m(self):
826-
return "a"
825+
def m(self):
826+
return "a"
827827

828828
class B(A):
829-
def m(self):
830-
return super().m() + "b"
829+
def m(self):
830+
return super().m() + "b"
831831

832832
print(B().m())
833833
```
@@ -842,14 +842,14 @@ ab
842842

843843
```python
844844
class C:
845-
def __init__(self, x):
846-
self._x = x
847-
@property
848-
def x(self):
849-
return self._x
850-
@x.setter
851-
def x(self, v):
852-
self._x = v
845+
def __init__(self, x):
846+
self._x = x
847+
@property
848+
def x(self):
849+
return self._x
850+
@x.setter
851+
def x(self, v):
852+
self._x = v
853853

854854
c = C(1)
855855
c.x = 9
@@ -878,9 +878,9 @@ Concurrency primitives; full model in [Async](/language/async).
878878

879879
```python
880880
async def animate(node):
881-
for i in range(60):
882-
set_attribute(node, "style", f"transform: translateX({i}px)")
883-
frame()
881+
for i in range(60):
882+
set_attribute(node, "style", f"transform: translateX({i}px)")
883+
frame()
884884
```
885885

886886
### receive
@@ -893,7 +893,7 @@ async def animate(node):
893893

894894
```python
895895
async def task(n):
896-
return n * 2
896+
return n * 2
897897

898898
print(gather(task(1), task(2), task(3)))
899899
```
@@ -908,13 +908,13 @@ print(gather(task(1), task(2), task(3)))
908908

909909
```python
910910
async def slow():
911-
sleep(10)
912-
return "never"
911+
sleep(10)
912+
return "never"
913913

914914
try:
915-
with_timeout(0.1, slow())
915+
with_timeout(0.1, slow())
916916
except TimeoutError:
917-
print("timed out")
917+
print("timed out")
918918
```
919919

920920
```text Output

docs/pages/reference/imports.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ from utils import normalize as n
3434

3535
# Parenthesized name lists, multi-line, optional trailing comma
3636
from utils import (
37-
slugify,
38-
normalize as n,
39-
titlecase,
37+
slugify,
38+
normalize as n,
39+
titlecase,
4040
)
4141

4242
# Plain `import X`, binds the module under its name; access exports via `.`

docs/pages/reference/limits-and-errors.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ print(140737488355327) # inline, fast path
2727
print(2 ** 47) # 140737488355328: auto-promotes to LongInt
2828
print(2 ** 100) # 1267650600228229401496703205376
2929
try:
30-
print(2 ** 127) # past the i128 cap
30+
print(2 ** 127) # past the i128 cap
3131
except OverflowError:
32-
print("overflow")
32+
print("overflow")
3333
```
3434

3535
```text Output
@@ -53,9 +53,9 @@ def loop(n):
5353
return loop(n + 1)
5454

5555
try:
56-
loop(0)
56+
loop(0)
5757
except RecursionError:
58-
print("hit max depth")
58+
print("hit max depth")
5959
```
6060

6161
```text Output
@@ -65,11 +65,11 @@ hit max depth
6565
```python
6666
# Heap quota, a tight loop allocating new objects
6767
try:
68-
xs = []
69-
while True:
70-
xs = xs + [0] * 1000
68+
xs = []
69+
while True:
70+
xs = xs + [0] * 1000
7171
except MemoryError:
72-
print("hit heap limit")
72+
print("hit heap limit")
7373
```
7474

7575
## Source size
@@ -142,14 +142,14 @@ Flat tree rooted at `BaseException -> Exception`. `except` walks parent links, `
142142

143143
```python
144144
try:
145-
raise RuntimeError("oops")
145+
raise RuntimeError("oops")
146146
except Exception as e:
147-
print("caught via parent:", e)
147+
print("caught via parent:", e)
148148

149149
try:
150-
[][0]
150+
[][0]
151151
except Exception:
152-
print("caught IndexError as Exception")
152+
print("caught IndexError as Exception")
153153
```
154154

155155
```text Output
@@ -165,19 +165,19 @@ Caught exceptions expose constructor args as `e.args` (tuple). `raise X("msg")`
165165

166166
```python
167167
try:
168-
raise TypeError("bad input")
168+
raise TypeError("bad input")
169169
except TypeError as e:
170-
print(e.args)
170+
print(e.args)
171171

172172
try:
173-
1 / 0
173+
1 / 0
174174
except ZeroDivisionError as e:
175-
print(e.args)
175+
print(e.args)
176176

177177
try:
178-
raise ValueError
178+
raise ValueError
179179
except ValueError as e:
180-
print(e.args)
180+
print(e.args)
181181
```
182182

183183
```text Output
@@ -190,16 +190,16 @@ except ValueError as e:
190190

191191
```python
192192
def safe(f, x):
193-
try:
194-
return f(x)
195-
except TypeError:
196-
return "type"
197-
except ValueError:
198-
return "value"
199-
except ZeroDivisionError:
200-
return "zero"
201-
except:
202-
return "other"
193+
try:
194+
return f(x)
195+
except TypeError:
196+
return "type"
197+
except ValueError:
198+
return "value"
199+
except ZeroDivisionError:
200+
return "zero"
201+
except:
202+
return "other"
203203

204204
print(safe(lambda x: 1 / x, 0))
205205
print(safe(lambda x: int(x), "abc"))
@@ -229,9 +229,9 @@ Parse but raise `RuntimeError` when executed:
229229

230230
```python
231231
try:
232-
import os
232+
import os
233233
except RuntimeError as e:
234-
print("import:", e)
234+
print("import:", e)
235235
```
236236

237237
Exist for syntactic compatibility. For code reuse, use higher-order functions.

0 commit comments

Comments
 (0)