[Chicago] Perl Follow-up

Jonathan Hayward christos.jonathan.hayward at gmail.com
Fri Mar 12 20:05:57 CET 2010


On Fri, Mar 12, 2010 at 1:05 PM, Jonathan Hayward <
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> 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.
>>
>> 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
>>
>
>
>
> --
> → Jonathan Hayward, a Senior Web Developer who cares deeply about usability
> → www.linkedin.com/in/jonathanhayward • jonathan.hayward at pobox.com
> → Ajax, CGI, CMS, CSS, HTML, IA, JSON, JavaScript, LAMP, Linux, Perl, PHP,
> Python, SQL, UI, Unix, Usability, UX, XHTML, XML
> → With a good interest in the human side of computing and making software
> and websites a joy to use
>



-- 
→ Jonathan Hayward, a Senior Web Developer who cares deeply about usability
→ www.linkedin.com/in/jonathanhayward • jonathan.hayward at pobox.com
→ Ajax, CGI, CMS, CSS, HTML, IA, JSON, JavaScript, LAMP, Linux, Perl, PHP,
Python, SQL, UI, Unix, Usability, UX, XHTML, XML
→ With a good interest in the human side of computing and making software
and websites a joy to use
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20100312/c09106ef/attachment.html>


More information about the Chicago mailing list