Reputation: 101
I am using a python socket and one of the API of the socket is
(clientsocket, address) = serversocket.accept()
My magic number way is
connected_sock = serversocket.accept()[0]
However, I am interested only in client socket and not address. I can do so that there is just the client socket value and not address. What is the appropriate way in Python to do so that I can avoid magic numbers in my code?
Upvotes: 2
Views: 41
Reputation: 11506
You can use _
as a throwaway variable:
clientsocket, _ = serversocket.accept()
Upvotes: 3