Skip to content

Commit cdad61a

Browse files
committed
paginação
1 parent 71b9ee7 commit cdad61a

File tree

16 files changed

+75
-64
lines changed

16 files changed

+75
-64
lines changed

code/05-data-classes/dataclass/hackerclub.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
"""
33
``HackerClubMember`` objects accept an optional ``handle`` argument::
44
5-
>>> anna = HackerClubMember('Anna Ravenscroft', handle='AnnaRaven')
5+
>>> anna = HackerClubMember('Anna Ravenscroft', handle='raven')
66
>>> anna
7-
HackerClubMember(name='Anna Ravenscroft', guests=[], handle='AnnaRaven')
7+
HackerClubMember(name='Anna Ravenscroft', guests=[], handle='raven')
88
99
If ``handle`` is omitted, it's set to the first part of the member's name::
1010
1111
>>> leo = HackerClubMember('Leo Rochael')
1212
>>> leo
1313
HackerClubMember(name='Leo Rochael', guests=[], handle='Leo')
1414
15-
Members must have a unique handle. The following ``leo2`` will not be created,
15+
Handles must be unique. The following ``leo2`` will not be created,
1616
because its ``handle`` would be 'Leo', which was taken by ``leo``::
1717
1818
>>> leo2 = HackerClubMember('Leo DaVinci')

code/05-data-classes/dataclass/resource.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212
# tag::DOCTEST[]
1313
1414
>>> description = 'Improving the design of existing code'
15-
>>> book = Resource('978-0-13-475759-9', 'Refactoring, 2nd Edition',
15+
>>> book = Resource('978-0-13-475759-9',
16+
... 'Refactoring, 2nd Edition',
1617
... ['Martin Fowler', 'Kent Beck'], date(2018, 11, 19),
1718
... ResourceType.BOOK, description, 'EN',
1819
... ['computer programming', 'OOP'])
1920
>>> book # doctest: +NORMALIZE_WHITESPACE
20-
Resource(identifier='978-0-13-475759-9', title='Refactoring, 2nd Edition',
21-
creators=['Martin Fowler', 'Kent Beck'], date=datetime.date(2018, 11, 19),
22-
type=<ResourceType.BOOK: 1>, description='Improving the design of existing code',
23-
language='EN', subjects=['computer programming', 'OOP'])
21+
Resource(identifier='978-0-13-475759-9', title='Refactoring, 2nd Edition', creators=['Martin Fowler', 'Kent Beck'], date=datetime.date(2018, 11, 19), type=<ResourceType.BOOK: 1>, description='Improving the design of existing code', language='EN', subjects=['computer programming', 'OOP'])
2422
2523
# end::DOCTEST[]
2624
"""

code/05-data-classes/frenchdeck.doctest

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,17 @@ Card(rank='Q', suit='hearts')
3535
Sort with *spades high* overall ranking
3636

3737
# tag::SPADES_HIGH[]
38-
>>> Card.suit_values = dict(spades=3, hearts=2, diamonds=1, clubs=0) # <1>
39-
>>> def spades_high(card): # <2>
38+
>>> Card.suit_values = dict(spades=3, hearts=2,
39+
... diamonds=1, clubs=0) # <1>
40+
>>> def spades_high(card): # <2>
4041
... rank_value = FrenchDeck.ranks.index(card.rank)
4142
... suit_value = card.suit_values[card.suit]
4243
... return rank_value * len(card.suit_values) + suit_value
4344
...
44-
>>> Card.overall_rank = spades_high # <3>
45+
>>> Card.overall_rank = spades_high # <3>
4546
>>> lowest_card = Card('2', 'clubs')
4647
>>> highest_card = Card('A', 'spades')
47-
>>> lowest_card.overall_rank() # <4>
48+
>>> lowest_card.overall_rank() # <4>
4849
0
4950
>>> highest_card.overall_rank()
5051
51

code/08-def-type-hints/charindex.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ def tokenize(text: str) -> Iterator[str]: # <1>
2525
for match in RE_WORD.finditer(text):
2626
yield match.group().upper()
2727

28-
def name_index(start: int = 32, end: int = STOP_CODE) -> dict[str, set[str]]:
28+
def name_index(
29+
start: int = 32, end: int = STOP_CODE
30+
) -> dict[str, set[str]]:
2931
index: dict[str, set[str]] = {} # <2>
3032
for char in (chr(i) for i in range(start, end)):
3133
if name := unicodedata.name(char, ''): # <3>
3234
for word in tokenize(name):
3335
index.setdefault(word, set()).add(char)
3436
return index
37+
3538
# end::CHARINDEX[]

images/flpy_0405.png

3.08 KB
Loading

images/flpy_0406.png

2.47 KB
Loading

images/flpy_0407.png

-18.1 KB
Loading

images/flpy_0408.png

-5.71 KB
Loading

ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
line-length = 100
1+
line-length = 73
22
[format]
33
# Use single quotes for strings, like Python's repr()
44
quote-style = "single"

vol1/cap03.adoc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,11 @@ O <<example3-1>> mostra o uso de compreensões de `dict` para criar dois dicion
107107
... ]
108108
>>> country_dial = {country: code for code, country in dial_codes} # <2>
109109
>>> country_dial
110-
{'Bangladesh': 880, 'Brazil': 55, 'China': 86, 'India': 91, 'Indonesia': 62,
111-
'Japan': 81, 'Nigeria': 234, 'Pakistan': 92, 'Russia': 7, 'United States': 1}
112-
>>> {code: country.upper() # <3>
113-
... for country, code in sorted(country_dial.items())
110+
{'Bangladesh': 880, 'Brazil': 55, 'China': 86, 'India': 91,
111+
'Indonesia': 62, 'Japan': 81, 'Nigeria': 234, 'Pakistan': 92,
112+
'Russia': 7, 'United States': 1}
113+
>>> {code: country.upper() for country, code # <3>
114+
... in sorted(country_dial.items())
114115
... if code < 70}
115116
{55: 'BRAZIL', 62: 'INDONESIA', 7: 'RUSSIA', 1: 'UNITED STATES'}
116117
----

0 commit comments

Comments
 (0)