Skip to content

Commit 8a330d8

Browse files
committed
updade from Atlas repo
1 parent c518bf8 commit 8a330d8

File tree

120 files changed

+2187
-1181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+2187
-1181
lines changed

03-dict-set/dialcodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
print('d1:', d1.keys())
1818
d2 = dict(sorted(DIAL_CODES)) # <2>
1919
print('d2:', d2.keys())
20-
d3 = dict(sorted(DIAL_CODES, key=lambda x:x[1])) # <3>
20+
d3 = dict(sorted(DIAL_CODES, key=lambda x: x[1])) # <3>
2121
print('d3:', d3.keys())
2222
assert d1 == d2 and d2 == d3 # <4>
2323
# end::DIALCODES[]

03-dict-set/index.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# tag::INDEX[]
66
"""Build an index mapping word -> list of occurrences"""
77

8-
import sys
98
import re
9+
import sys
1010

1111
WORD_RE = re.compile(r'\w+')
1212

@@ -15,11 +15,11 @@
1515
for line_no, line in enumerate(fp, 1):
1616
for match in WORD_RE.finditer(line):
1717
word = match.group()
18-
column_no = match.start()+1
18+
column_no = match.start() + 1
1919
location = (line_no, column_no)
2020
index.setdefault(word, []).append(location) # <1>
2121

22-
# print in alphabetical order
22+
# display in alphabetical order
2323
for word in sorted(index, key=str.upper):
2424
print(word, index[word])
2525
# end::INDEX[]

03-dict-set/index0.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# tag::INDEX0[]
66
"""Build an index mapping word -> list of occurrences"""
77

8-
import sys
98
import re
9+
import sys
1010

1111
WORD_RE = re.compile(r'\w+')
1212

@@ -22,7 +22,7 @@
2222
occurrences.append(location) # <2>
2323
index[word] = occurrences # <3>
2424

25-
# print in alphabetical order
25+
# display in alphabetical order
2626
for word in sorted(index, key=str.upper): # <4>
2727
print(word, index[word])
2828
# end::INDEX0[]

03-dict-set/index_default.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# tag::INDEX_DEFAULT[]
66
"""Build an index mapping word -> list of occurrences"""
77

8-
import sys
9-
import re
108
import collections
9+
import re
10+
import sys
1111

1212
WORD_RE = re.compile(r'\w+')
1313

@@ -16,11 +16,11 @@
1616
for line_no, line in enumerate(fp, 1):
1717
for match in WORD_RE.finditer(line):
1818
word = match.group()
19-
column_no = match.start()+1
19+
column_no = match.start() + 1
2020
location = (line_no, column_no)
2121
index[word].append(location) # <2>
2222

23-
# print in alphabetical order
23+
# display in alphabetical order
2424
for word in sorted(index, key=str.upper):
2525
print(word, index[word])
2626
# end::INDEX_DEFAULT[]

04-text-byte/categories.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22
import collections
3-
from unicodedata import name, category
3+
from unicodedata import category
44

55

66
def category_stats():
@@ -19,7 +19,7 @@ def category_scan(desired):
1919
for code in range(sys.maxunicode + 1):
2020
char = chr(code)
2121
if category(char) == desired:
22-
yield char
22+
yield char
2323

2424

2525
def main(args):
@@ -30,7 +30,7 @@ def main(args):
3030
count += 1
3131
if count > 200:
3232
break
33-
print()
33+
print()
3434
print(count, 'characters shown')
3535
else:
3636
counts, firsts = category_stats()

04-text-byte/default_encodings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import sys, locale
1+
import locale
2+
import sys
23

34
expressions = """
45
locale.getpreferredencoding()

04-text-byte/zwj_sample.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
1F469 200D 2764 FE0F 200D 1F48B 200D 1F469 |kiss: woman, woman |E2.0
1111
"""
1212

13-
markers = {'\u200D': 'ZWG', # ZERO WIDTH JOINER
14-
'\uFE0F': 'V16', # VARIATION SELECTOR-16
15-
}
13+
markers = {'\u200D': 'ZWG', # ZERO WIDTH JOINER
14+
'\uFE0F': 'V16', # VARIATION SELECTOR-16
15+
}
1616

1717
for line in zwg_sample.strip().split('\n'):
1818
code, descr, version = (s.strip() for s in line.split('|'))

05-record-like/dataclass/coordinates.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313

1414
@dataclass(frozen=True)
1515
class Coordinate:
16-
1716
lat: float
1817
long: float
1918

2019
def __str__(self):
2120
ns = 'N' if self.lat >= 0 else 'S'
2221
we = 'E' if self.long >= 0 else 'W'
2322
return f'{abs(self.lat):.1f}°{ns}, {abs(self.long):.1f}°{we}'
24-
# end::COORDINATE[]
23+
# end::COORDINATE[]

08-def-type-hints/colors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,5 @@ def demo():
7676
print(n, name2hex(n, o))
7777

7878

79-
8079
if __name__ == '__main__':
8180
demo()

08-def-type-hints/columnize2.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def columnize(sequence: Sequence[T], num_columns: int = 0) -> List[Tuple[T, ...]
1010
return [tuple(sequence[i::num_rows]) for i in range(num_rows)]
1111

1212

13-
1413
def demo() -> None:
1514
nato = ('Alfa Bravo Charlie Delta Echo Foxtrot Golf Hotel India'
1615
' Juliett Kilo Lima Mike November Oscar Papa Quebec Romeo'
@@ -22,7 +21,6 @@ def demo() -> None:
2221
print(f'{word:15}', end='')
2322
print()
2423

25-
2624
print()
2725
for length in range(2, 21, 6):
2826
values = list(range(1, length + 1))

0 commit comments

Comments
 (0)