>> >> The script in the following can do the batch conversion from domain
>> >> name to IP:
>>
>> >  This is a Python list, not Perl!
>>
>> OMG!  It's my mistake, sorry for this.
>
> Lol..thats okay. Now that you are here and have seen what fun we have
> writing Python code - why not join the party?
>
> Don't be shy to join us :p - i bet you won't be sorry.


well, he had to join Tutor to post, unless a mod allowed his msg, so
there should be *some* interest in doing it in Python. after all, the
equivalent code is already slightly shorter and easier to read than
the Perl version...

import socket
import sys

for hp in sys.argv[1:]:
    h, p = hp.strip().split(':')
    print '%s -> %s:%s' % (hp, socket.gethostbyname(h), p)

cheers,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to