<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">博客园_mr. dave_分类_Python</title><id>http://feed.cnblogs.com/blog/u/60240/category/278779/rss</id><updated>2012-05-31T01:59:52Z</updated><generator>feed.cnblogs.com</generator><link rel="alternate" type="text/html" href="http://www.cnblogs.com/dave_cn/category/278779.html"/><link rel="self" type="application/atom+xml" href="http://feed.cnblogs.com/blog/u/60240/category/278779/rss"/><entry><id>http://www.cnblogs.com/dave_cn/archive/2011/01/06/1929243.html</id><title type="text">Python中switch的实现</title><summary type="text">众所周知Python中是没有switch的，一般而言是用if-else来代替的，如C语言下的在Python中一般表示成if-else足够简单，也足够实用，它也能模拟出多个case完成同样的事，及default情况。不过也有人喜欢dict来实现不过上面的实现没办法模拟出多个case完成同样的事的情况，勉强能够实现default，不过就比较丑陋了自己也尝试利用类实现了一个，结合了使用类模拟了dict部分属性，来扩展dict以可以模拟出多个case完成同样的事，及default情况。不过自己看了后觉得依旧丑陋啊。 ==!上网google了一下，发现了一个大牛的switch不过回头看看，觉得为了一个s</summary><published>2011-01-06T14:48:00Z</published><updated>2011-01-06T14:48:00Z</updated><author><name>mr. dave</name><uri>http://www.cnblogs.com/dave_cn/</uri></author><link rel="alternate" href="http://www.cnblogs.com/dave_cn/archive/2011/01/06/1929243.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/dave_cn/archive/2011/01/06/1929243.html"/><content type="html"/></entry></feed>
