Skip to content

Commit b000813

Browse files
committed
ch04: update from book draft
1 parent a9fb6dc commit b000813

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

04-text-byte/locale_sort.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import locale
2+
my_locale = locale.setlocale(locale.LC_COLLATE, 'pt_BR.UTF-8')
3+
print(my_locale)
4+
fruits = ['caju', 'atemoia', 'cajá', 'açaí', 'acerola']
5+
sorted_fruits = sorted(fruits, key=locale.strxfrm)
6+
print(sorted_fruits)

04-text-byte/stdout_check.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
from unicodedata import name
3+
4+
print(sys.version)
5+
print()
6+
print('sys.stdout.isatty():', sys.stdout.isatty())
7+
print('sys.stdout.encoding:', sys.stdout.encoding)
8+
print()
9+
10+
test_chars = [
11+
'\u2026', # HORIZONTAL ELLIPSIS (in cp1252)
12+
'\u221E', # INFINITY (in cp437)
13+
'\u32B7', # CIRCLED NUMBER FORTY TWO
14+
]
15+
16+
for char in test_chars:
17+
print(f'Trying to output {name(char)}:')
18+
print(char)

0 commit comments

Comments
 (0)