How to correctly pass sockets to a function's parameters

642 views Asked by At

If I create a global socket object like so..

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

and define a function like so..

def function():
    <do something with the socket object>

Would it be considered non-dry programming if I passed the socket object as a function parameter for readability, is this the approach I should take when using sockets inside functions that are declared globally or within a while loop?

Example:

def function(passed_sock):
    <do something with the socket object>
0

There are 0 answers