[Chicago] Perl Follow-up

Clyde Forrester clydeforrester at gmail.com
Fri Mar 12 21:11:28 CET 2010

Yes, those are the answers I'm looking for. Thank you!

The transpose function gives me insight as to how Python programmers 
view data and structures. Understanding the way of the language is 
something I have to go through with each language.

And the standard library gives me the built-in best performance, and 
cleaner, maintainable code.


Jonathan Hayward wrote:
> On Fri, Mar 12, 2010 at 1:05 PM, Jonathan Hayward 
> <christos.jonathan.hayward at gmail.com 
> <mailto:christos.jonathan.hayward at gmail.com>> wrote:
>     Someone said that Python /does/ have a switch statement; it's the
>     dictionary.
>     One way to do translations would seem to be:
>     function transpose(input, translations = {'T': 'A', 'A': 'T', 'C':
>     'G', 'G': C'}):
>         result = []
>         for character in input:
>             if character in translations:
>                 result.append(translations[character])
>             else:
>                 result.append(character)
>        return "".join(result)
> Left out a return statement.
>     But it looks like Alex Gaynor found an "It's already solved in the
>     standard library" approach, so I'd vote for his solution.
>     On Fri, Mar 12, 2010 at 12:54 PM, Clyde Forrester
>     <clydeforrester at gmail.com <mailto: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.
>         Another example would be ROT-13 encryption and decryption.

More information about the Chicago mailing list