inet_addr() in Python

Steve Holden steve at holdenweb.com
Mon Jul 23 16:14:56 EDT 2007


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('127.0.0.1')
'\x7f\x00\x00\x01'

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------




More information about the Python-list mailing list