Skip to content

Commit 47214e2

Browse files
author
Aaron Law
committed
Add a blank link before code block
1 parent 74460c2 commit 47214e2

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Targets Python3.7+
3535
### Use meaningful and pronounceable variable names
3636

3737
**Bad:**
38+
3839
```python
3940
import datetime
4041

@@ -43,6 +44,7 @@ ymdstr = datetime.date.today().strftime("%y-%m-%d")
4344
```
4445

4546
**Good**:
47+
4648
```python
4749
import datetime
4850

@@ -55,6 +57,7 @@ current_date: str = datetime.date.today().strftime("%y-%m-%d")
5557

5658
**Bad:**
5759
Here we use three different names for the same underlying entity:
60+
5861
```python
5962
def get_user_info(): pass
6063
def get_client_data(): pass
@@ -63,6 +66,7 @@ def get_customer_record(): pass
6366

6467
**Good**:
6568
If the entity is the same, you should be consistent in referring to it in your functions:
69+
6670
```python
6771
def get_user_info(): pass
6872
def get_user_data(): pass
@@ -101,6 +105,7 @@ understanding our program, we hurt our readers.
101105
Make your names searchable.
102106

103107
**Bad:**
108+
104109
```python
105110
import time
106111

@@ -110,6 +115,7 @@ time.sleep(86400)
110115
```
111116

112117
**Good**:
118+
113119
```python
114120
import time
115121

@@ -122,6 +128,7 @@ time.sleep(SECONDS_IN_A_DAY)
122128

123129
### Use explanatory variables
124130
**Bad:**
131+
125132
```python
126133
import re
127134

@@ -154,6 +161,7 @@ if matches:
154161
**Good**:
155162

156163
Decrease dependence on regex by naming subpatterns.
164+
157165
```python
158166
import re
159167

@@ -172,6 +180,7 @@ Don’t force the reader of your code to translate what the variable means.
172180
Explicit is better than implicit.
173181

174182
**Bad:**
183+
175184
```python
176185
seq = ("Austin", "New York", "San Francisco")
177186

@@ -184,6 +193,7 @@ for item in seq:
184193
```
185194

186195
**Good**:
196+
187197
```python
188198
locations = ("Austin", "New York", "San Francisco")
189199

@@ -265,12 +275,14 @@ arguments then your function is trying to do too much. In cases where it's not,
265275
of the time a higher-level object will suffice as an argument.
266276

267277
**Bad:**
278+
268279
```python
269280
def create_menu(title, body, button_text, cancellable):
270281
pass
271282
```
272283

273284
**Java-esque**:
285+
274286
```python
275287
class Menu:
276288
def __init__(self, config: dict):
@@ -289,6 +301,7 @@ menu = Menu(
289301
```
290302

291303
**Also good**
304+
292305
```python
293306
from typing import Text
294307

@@ -325,6 +338,7 @@ create_menu(config)
325338
```
326339

327340
**Fancy**
341+
328342
```python
329343
from typing import NamedTuple
330344

@@ -359,6 +373,7 @@ create_menu(
359373
```
360374

361375
**Even fancier**
376+
362377
```python
363378
from typing import Text
364379
from dataclasses import astuple, dataclass
@@ -394,6 +409,7 @@ create_menu(
394409
```
395410

396411
**Even fancier, Python3.8+ only**
412+
397413
```python
398414
from typing import TypedDict, Text
399415

@@ -438,6 +454,7 @@ cleaner. If you take nothing else away from this guide other than this, you'll b
438454
of many developers.
439455

440456
**Bad:**
457+
441458
```python
442459
from typing import List
443460

@@ -459,6 +476,7 @@ def email_clients(clients: List[Client]) -> None:
459476
```
460477

461478
**Good**:
479+
462480
```python
463481
from typing import List
464482

@@ -487,6 +505,7 @@ def email_clients(clients: List[Client]) -> None:
487505
Do you see an opportunity for using generators now?
488506

489507
**Even better**
508+
490509
```python
491510
from typing import Generator, Iterator
492511

@@ -694,6 +713,7 @@ print(fullname) # ["Ryan", "McDermott"]
694713
```
695714

696715
**Good:**
716+
697717
```python
698718
from typing import List, AnyStr
699719

@@ -708,6 +728,7 @@ print(name, surname) # => Ryan McDermott
708728
```
709729

710730
**Also good**
731+
711732
```python
712733
from typing import Text
713734
from dataclasses import dataclass

0 commit comments

Comments
 (0)