[Tutor] Socket Module
Danny Yoo
danny.yoo at gmail.com
Mon Jul 20 03:15:35 CEST 2015
> for name in domains:
> socket.gethostbyaddr(name)
> print(name)
>
> output:
> 173.252.120.6
> 98.139.183.24
>
> What am I missing? Thank in advance.
>
You have confused yourself a little because the variable names you've
chosen are slightly misleading. Specifically, "name" is really an IP
address. Hence, your loop here really should be:
for addr in domains:
...
I would also strongly suggest renaming "domains" to something like
"domainAddresses", for similar reasons.
Still, you do want a "name" at some point, since that's what you care about.
Can you say in human language what the following will return?
socket.gethostbyaddr(addr)
Can you give it a good name?
More information about the Tutor
mailing list