Skip to content

Commit 2543d68

Browse files
committed
defaults!
1 parent 4a4e58f commit 2543d68

3 files changed

Lines changed: 21 additions & 36 deletions

File tree

‎21_tictactoe/itictactoe.py‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,19 @@
55

66

77
class State(NamedTuple):
8-
board: List[str]
9-
player: str
10-
quit: bool
11-
draw: bool
12-
error: Optional[str]
13-
winner: Optional[str]
8+
board: List[str] = list('.' * 9)
9+
player: str = 'X'
10+
quit: bool = False
11+
draw: bool = False
12+
error: Optional[str] = None
13+
winner: Optional[str] = None
1414

1515

1616
# --------------------------------------------------
1717
def main() -> None:
1818
"""Make a jazz noise here"""
1919

20-
state = State(board=list('.' * 9),
21-
player='X',
22-
quit=False,
23-
draw=False,
24-
error=None,
25-
winner=None)
20+
state = State()
2621

2722
while True:
2823
print("\033[H\033[J")

‎21_tictactoe/typehints.py‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,14 @@
55

66

77
class State(NamedTuple):
8-
board: List[str]
9-
player: str
10-
quit: bool
11-
draw: bool
12-
error: Optional[str]
13-
winner: Optional[str]
8+
board: List[str] = list('.' * 9)
9+
player: str = 'X'
10+
quit: bool = False
11+
draw: bool = False
12+
error: Optional[str] = None
13+
winner: Optional[str] = None
1414

1515

16-
state = State(board='.' * 9,
17-
player='X',
18-
quit='False',
19-
draw=False,
20-
error=None,
21-
winner=None)
16+
state = State(quit='False')
2217

2318
print(state)

‎21_tictactoe/typehints2.py‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,14 @@
55

66

77
class State(NamedTuple):
8-
board: List[str]
9-
player: str
10-
quit: bool
11-
draw: bool
12-
error: Optional[str]
13-
winner: Optional[str]
8+
board: List[str] = list('.' * 9)
9+
player: str = 'X'
10+
quit: bool = False
11+
draw: bool = False
12+
error: Optional[str] = None
13+
winner: Optional[str] = None
1414

1515

16-
state = State(board=list('.' * 9),
17-
player='X',
18-
quit=False,
19-
draw=False,
20-
error=None,
21-
winner=None)
16+
state = State(quit=True)
2217

2318
print(state)

0 commit comments

Comments
 (0)