<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Dictionaries - Tag - My Notes</title><link>https://blog.emecas.net/tags/dictionaries/</link><description>Dictionaries - Tag - My Notes</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Fri, 07 Jun 2013 09:15:21 +0200</lastBuildDate><atom:link href="https://blog.emecas.net/tags/dictionaries/" rel="self" type="application/rss+xml"/><item><title>Python - replace long if/elif chain with dict mappings</title><link>https://blog.emecas.net/posts/2013-06-07-python-replace-long-if-elif-chain-with-dict-mappings/</link><pubDate>Fri, 07 Jun 2013 09:15:21 +0200</pubDate><author>emecas</author><guid>https://blog.emecas.net/posts/2013-06-07-python-replace-long-if-elif-chain-with-dict-mappings/</guid><description><![CDATA[<p>Python - Avoiding long if/elif chain with dictionary mappings<br>
Three ways to handle the keys of a Pong game: a long if/elif chain, a dictionary that maps each key to a function, and a dictionary that maps each key to the arguments of one update. From the Pong mini-project of Rice University&rsquo;s &ldquo;An Introduction to Interactive Programming in Python&rdquo; on Coursera, written in CodeSkulptor with its <code>simplegui</code> module.<br>
Course: <a href="https://www.coursera.org/learn/interactive-python-1" target="_blank" rel="noopener noreffer ">https://www.coursera.org/learn/interactive-python-1</a><br>
CodeSkulptor: <a href="https://py2.codeskulptor.org/" target="_blank" rel="noopener noreffer ">https://py2.codeskulptor.org/</a></p>]]></description></item></channel></rss>