inet_addr() in Python

brad byte8bits at
Mon Jul 23 22:22:48 CEST 2007

Steve Holden wrote:
> brad wrote:
>> Does Python have an equivalent to C's inet_addr()?
> socket.inet_aton() produces a four-byte string you can pass as a struct 
> in_addr, if that's what you are looking for. If you want a number then 
> use the struct module to manipulate it further.
>  >>> s.inet_aton('')
> '\x7f\x00\x00\x01'
> regards
>  Steve

Thanks! That works great for my needs. I should have read the socket 
documentation more thoroughly.

More information about the Python-list mailing list