title: Bind IPv6 address to Python socket as source ip address
body: <p>I formerly used the code below to bind IPv4 address to Python socket as source ip address.</p>
  
  <pre><code>import socket
  true_socket = socket.socket
  def bound_socket(*a, **k):
      sock = true_socket(*a, **k)
      sock.bind((sourceIP, 0))
      return sock
  socket.socket = bound_socket
  </code></pre>
  
  <p>Does above code work for IPv6 address? If not, how can I bind an IPv6 address?</p>
  
  <p>Thanks in advance!</p>