Skip to content

Commit

Permalink
chore: refactor main.py for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-gang committed Sep 6, 2024
1 parent 8eb2e87 commit da7f515
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
7 changes: 4 additions & 3 deletions compiled_starters/python/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@


def main():
# You can use print statements as follows for debugging, they'll be visible when running tests.
# You can use print statements as follows for debugging,
# they'll be visible when running tests.
print("Logs from your program will appear here!")

# Uncomment this to pass the first stage
#
# server_socket = socket.create_server(("localhost", 9092), reuse_port=True)
# server_socket.accept() # wait for client
# server = socket.create_server(("localhost", 9092), reuse_port=True)
# server.accept() # wait for client


if __name__ == "__main__":
Expand Down
6 changes: 4 additions & 2 deletions solutions/python/01-vi6/code/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@


def main():
server_socket = socket.create_server(("localhost", 9092), reuse_port=True)
server_socket.accept() # wait for client
print("Logs from your program will appear here!")

server = socket.create_server(("localhost", 9092), reuse_port=True)
server.accept() # wait for client


if __name__ == "__main__":
Expand Down
17 changes: 9 additions & 8 deletions solutions/python/01-vi6/diff/app/main.py.diff
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
@@ -1,15 +1,10 @@
@@ -1,16 +1,12 @@
import socket # noqa: F401


def main():
- # You can use print statements as follows for debugging, they'll be visible when running tests.
- print("Logs from your program will appear here!")
-
- # You can use print statements as follows for debugging,
- # they'll be visible when running tests.
print("Logs from your program will appear here!")

- # Uncomment this to pass the first stage
- #
- # server_socket = socket.create_server(("localhost", 9092), reuse_port=True)
- # server_socket.accept() # wait for client
+ server_socket = socket.create_server(("localhost", 9092), reuse_port=True)
+ server_socket.accept() # wait for client
- # server = socket.create_server(("localhost", 9092), reuse_port=True)
- # server.accept() # wait for client
+ server = socket.create_server(("localhost", 9092), reuse_port=True)
+ server.accept() # wait for client


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions solutions/python/01-vi6/explanation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Study and uncomment the relevant code:
```python
# Uncomment this to pass the first stage

server_socket = socket.create_server(("localhost", 9092), reuse_port=True)
server_socket.accept() # wait for client
server = socket.create_server(("localhost", 9092), reuse_port=True)
server.accept() # wait for client
```

Push your changes to pass the first stage:
Expand Down

0 comments on commit da7f515

Please sign in to comment.