Perl Hacker, Python Initiate

Gary Chambers gwchamb at gwcmail.com
Wed Feb 2 17:00:11 CET 2011


All,

> Insight will be easier to provide once we see your Python code.

Thanks to all of you who replied to my original request for assistance.  All
points are valid and well-taken.

I'm afraid that I can no longer locate the original Python code where I was
encountering the problem I described in my request.  Unfortunately, I chose
to teach myself Python by first porting that script directly (for better or
worse, just trying to make it work).  Time constraints, a bit of
frustration, and simply being comfortable and efficient in Perl have
relegated the task to a far back burner.  Since then, I've forwarded the
Perl code to a few others to see if they could provide a solution, but have
heard nothing in reply -- which is why I presented it to a world of real
Python experts.

If you can't make heads or tails of the Perl code, all I'm trying to do is
loop through some dig output of a DNS zone transfer.  There are two
conditions I need to test: whether it's an A or CNAME record.  Ultimately, I
need to assemble the data into a single line listing first the canonical
hostname (A), followed by the aliases (CNAME), and finally the IP address.
For example:

were-on-vacation wov vacation vaca holiday 192.168.110.121

Finally, the problem I encountered in the Python code was having the script
fail when it encountered a line that didn't match either of the two regular
expressions.  What I'm seeking is either some Python code that mimics what
my Perl script is doing, or to be shown the Python way of how to accomplish
something like that.  Surprisingly, there's no mention of regular
expressions in the Perl Phrasebook at
http://wiki.python.org/moin/PerlPhrasebook.

-- Gary Chambers



More information about the Python-list mailing list