[Chicago] Perl Follow-up

Alex Gaynor alex.gaynor at gmail.com
Fri Mar 12 20:01:09 CET 2010

On Fri, Mar 12, 2010 at 12:54 PM, Clyde Forrester
<clydeforrester at gmail.com> wrote:
> I raised some issues about Perl vs. Python, and I'd like to invite some
> comment and advice.
> First, can anyone recommend a properly Pythonic way of doing translations?
> One example of such translations would be complementing DNA sequences.
> Translating T to A, A to T, C to G, and G to C.

>>> import string
>>> trans = string.maketrans("TACG", "ATGC")
>>> my_dna = "agtcaagta".upper()
>>> my_dna.translate(trans)

> Another example would be ROT-13 encryption and decryption.
> Second, where does one properly look for Python resources such as
> programming examples?
> Third, if I forgot an important question, go ahead and answer it anyway.
> Finally, I left out an anecdote about regular expressions: Someone recently
> posted a Perl data-parsing problem using regular expressions. Many things
> were suggested and tried. Nothing quite worked. Finally, I suggested that
> since the data seemed to be in fixed columns, that substrings should be used
> instead of pattern matching. It seems to have worked. (Oh, but.. but.. but
> regex is so wicked cool!)
> c4
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago


"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

More information about the Chicago mailing list