{"id":3458,"date":"2010-09-10T17:57:11","date_gmt":"2010-09-10T17:57:11","guid":{"rendered":""},"modified":"2026-04-18T22:53:21","modified_gmt":"2026-04-18T22:53:21","slug":"switch-case-statement-in-phyton","status":"publish","type":"post","link":"https:\/\/hellem.org\/wblog\/?p=3458","title":{"rendered":"Switch-case statement in Phyton"},"content":{"rendered":"<p>I&#8217;m not all that familiar with <a href=\"http:\/\/en.wikipedia.org\/wiki\/Python_%28programming_language%29\">Phyton<\/a>, but since <a href=\"http:\/\/en.wikipedia.org\/wiki\/Jython\">Jython <\/a>,which is the Java implementation of Phyton, is the preferred scripting language for WebSphere I do need to dive into it now and then. Today I needed to check if input parameter to a script was equal to a given value, then check a property file for the corresponding key\/value pair. If key\/value pair not present then check if the common default value where there. If if all is false, then just break out of the script. <\/p>\n<p>As you might have figured out this will get a bit messy, so I thought that maybe a switch-case statement could help me out to make it a bit cleaner. First I found this article at Bytebaker <a href=\"http:\/\/bytebaker.com\/2008\/11\/03\/switch-case-statement-in-python\/\">switch-case-statement-in-python<\/a> showing a &#8220;fake&#8221; implementation of swich-case, since it turns out that Phyton does not have this functionality. &#8220;Yes!!!&#8221;, but then it turned out no&#8230;I read the comments to the post and at the end found the follow-up article &#8220;<a href=\"http:\/\/bytebaker.com\/2009\/08\/17\/switch-case-statement-in-python-revisited\/\">Switch-case statement in Python revisited<\/a>&#8220;. So back to square one again&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m not all that familiar with Phyton, but since Jython ,which is the Java implementation of Phyton, is the preferred scripting language for WebSphere I do need to dive into it now and then. Today I needed to check if input parameter to a script was equal to a given value, then check a property [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[],"class_list":["post-3458","post","type-post","status-publish","format-standard","hentry","category-work-geek"],"_links":{"self":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/3458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3458"}],"version-history":[{"count":1,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/3458\/revisions"}],"predecessor-version":[{"id":14143,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=\/wp\/v2\/posts\/3458\/revisions\/14143"}],"wp:attachment":[{"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hellem.org\/wblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}