title: Get IP Mask from IP Address and Mask Length in Python
body: <p>Given an IP Address in dotted quad notation, for example: <br>
  192.192.45.1 <br>
  And a mask length for example 8, 16, 24 typically, but could be anything i.e. 17.</p>
  
  <p>Can somebody please provide the code in python to calculate the subnet mask? Preferably I
  could get the result as 32-bit integer so that it is easy to hash and then reinterpret as dotted quad when necessary for printing. I see that python has a socket library which is basically a wrapper around the unix socket api. I also saw it has the function inet_ntoa(),
  but it returns some sort of packet struct. I'm not terribly familiar with the Python struct library, so I was hoping some other would have some ideas. Thanks!</p>