Re: inet_addr() in Python
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('127.0.0.1')
'\x7f\x00\x00\x01'
regards
Steve
Thanks! That works great for my needs. I should have read the socket
documentation more thoroughly.
.
Relevant Pages
- Re: how to store list of varying types
... When there's a variable-length string, ... typedef struct { ... pointer null, and the second one the CString object. ... then have to finish constructing the packet by copying the two data objects ... (microsoft.public.vc.mfc) - Re: MVC in C++
... Things are now flowing more along the classic MVC lines. ... > struct Observable ... > string version; ... In that case the Controller would trigger a model update *and it* could ... (comp.object) - A note on personal corruption as a result of using C
... Many people in this ng are personally corrupt and use this ng to take ... "A string cannot contain Nuls" Yes it can. ... "A struct is a class" No, ... It appears that no C maven has read a history of mathematics. ... (comp.programming) - Re: Awfully quiet in here lately...
... before I did a test involving interning a string (resolving it via a hash so that strings with the same value will have the same pointer). ... the issue then is for floating point code, but I have found that even the current 28-bit flonums are "usually good enough" for the stuff I use the scripting for. ... hence, the current usual strategy of giving dynamic type-names to structs, but using static types for all of the struct fields. ... (comp.lang.misc) - Re: Client - server application C++ - C#
... The key word is serialization. ... to XML or to string buffer. ... struct user ... (microsoft.public.win32.programmer.networks) |
|