471,330 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

inet_addr() in Python

Does Python have an equivalent to C's inet_addr()?

Thanks,
Brad
Jul 23 '07 #1
1 3528
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 -------------

Jul 23 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Emile van Sebille | last post: by
reply views Thread by Emile van Sebille | last post: by
reply views Thread by Emile van Sebille | last post: by
4 posts views Thread by Mike Hubbard | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.