Skip to content

Commit 9194d7b

Browse files
committed
blackifying
1 parent 7c98c75 commit 9194d7b

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

subprocess/choice_react.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
print(
77
"A letter will appear on screen after a random amount of time,\n"
8-
+ "when it appears, type the letter as fast as possible and then press enter\n"
8+
"when it appears, type the letter as fast as possible "
9+
"and then press enter\n"
910
)
1011
print("Press enter when you are ready")
1112
input()

subprocess/create_new_project.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ def create_new_project(name):
88

99
project_folder = PurePath.joinpath(Path.cwd(), name)
1010
project_folder.mkdir()
11-
os.chdir(
12-
project_folder
13-
) # Should change to call git with -C flag which would mean that this line would not be needed
11+
os.chdir(project_folder) # Should change to call git with -C flag
12+
# which would mean that this line would not be needed
1413
project_folder.joinpath("README.md").touch()
1514
project_folder.joinpath(".gitignore").touch()
1615
with open(".gitignore", mode="w") as f:

subprocess/simple_react_popen_read_write.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,33 @@
22

33

44
process = subprocess.Popen(
5-
["python", "simple_react_perf.py"], stdin=subprocess.PIPE, stdout=subprocess.PIPE
5+
["python", "simple_react_perf.py"],
6+
stdin=subprocess.PIPE,
7+
stdout=subprocess.PIPE,
68
)
79

8-
# https://stackoverflow.com/questions/57726771/what-the-difference-between-read-and-read1-in-python
10+
# https://stackoverflow.com/q/57726771
11+
# what-the-difference-between-read-and-read1-in-python
912

1013
buffer = ""
1114

1215
while True:
1316
b = process.stdout.read(1)
1417
if b != "":
1518
buffer = buffer + b.decode()
16-
if buffer == "Press enter to play\n" or buffer == "Press enter to play\r\n":
19+
if (
20+
buffer == "Press enter to play\n"
21+
or buffer == "Press enter to play\r\n"
22+
):
1723
print(buffer)
1824
buffer = ""
1925
process.stdin.write(b"\n")
2026
process.stdin.flush()
2127

2228
while True:
23-
l = process.stdout.read(1)
24-
print(l.decode(), end="")
25-
if l.decode() == "g":
29+
character = process.stdout.read(1)
30+
print(character.decode(), end="")
31+
if character.decode() == "g":
2632
process.stdin.write(b"\n")
2733
process.stdin.flush()
2834
break
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import subprocess
22

33

4-
process = subprocess.run(["python", "simple_react_perf.py"], input="\n\n", text=True)
4+
process = subprocess.run(
5+
["python", "simple_react_perf.py"], input="\n\n", text=True
6+
)
57

68

79
"""
810
OUTPUT
9-
11+
1012
Press enter to play
1113
go!
1214
0.0
1315
"""
1416

1517

16-
# process = subprocess.run(["python", "simple_react.py"], input="\n\n", encoding="utf-8")
18+
# process = subprocess.run(
19+
# ["python", "simple_react.py"], input="\n\n", encoding="utf-8"
20+
# )

0 commit comments

Comments
 (0)