Python ã§è¤æ°ã®ãã¼ã¸ã§ã³ããµãã¼ãããã®ãããã©ã
ãã§ã« Python 3.1 ããªãªã¼ã¹ãããã¾ã 2.7 ã®ãªãªã¼ã¹ãè¿ãã¨ããã®ã«ãä¸ã®ä¸ã§ã¯ãã¾ã Python 2.3 ã 2.4 ãç¾å½¹ã§ä½¿ããã¦ããã
ãã¨ãã°ããµã¼ãç¨ OS ã¨ãã¦ãã使ããã CentOS 5 ã§ã¯ãPython ã®ãã¼ã¸ã§ã³ã¯ 2.4 ã§ããã
ã¾ãã¬ã³ã¿ã«ãµã¼ãã® xrea.com ã§ã¯ã2.3 㨠2.4 ãåã ãããã2.5 ã¯ã¤ã³ã¹ãã¼ã«ããããã¦ãªãã
ãããªããã§ãPython ã®ã©ã¤ãã©ãªããªãªã¼ã¹ãããªããä¸ã¯ 2.3 ã 2.4 ãããä¸ã¯ 3.1 ã¾ã§ãµãã¼ãããã®ãæã¾ãããã ãã©ãããããããã¨ãã㨠Python ã¯ããªãããã©ãããã
ãã¨ãã°ãã³ã¬ã¼ã¿ãã¸ã§ãã¬ã¼ã¿å¼ãset()ãå°å ¥ãããã®ã¯ 2.4 ãããªã®ã§ã2.3 ããµãã¼ããããã¨ããã¨ä½¿ããªãã
## ãã³ã¬ã¼ã¿ãã¸ã§ãã¬ã¼ã¿å¼ã¯ 2.4 以é @classmethod def f(cls, *args): print ", ".join(str(x) for x in args) ## 2.3 ããµãã¼ãããã«ã¯ããæ¸ãå¿ è¦ããã def f(cls, *args): print ", ".join([str(x) for x in args]) f = classmethod(f)
ã¾ã try/except 㨠try/finally ãåãã¤ã³ãã³ãã§æ¸ããããã«ãªã£ãã®ã¯ 2.5 ããããã¨æ¡ä»¶æ¼ç®åã 2.5 ããã ããã2.4 ããµãã¼ãããããã°ä½¿ããªãã
## 2.5 ã§ã¯ try/except/finally ãåãã¤ã³ãã³ãã§æ¸ãã f = open('file.txt') try: s = f.read() except Exception, ex: logging.error(ex.message) finally: f.close() ## ã§ã 2.4 ããµãã¼ãããããã°ããã¹ãããªãã¨ãããªã f = open('file.txt') try: try: s = f.read() except Exception, ex: logging.error(ex.message) finally: f.close()
Python ã¯ãã¼ã¸ã§ã³ã¢ãããã¨ã«å°ããã¤æ¹åããã¦ãã£ã¦ããã®ã¯ããããã ãã©ããªãã¨ããããæ§æã¬ãã«ã®å¤æ´ãããã®ã§è¤æ°ã®ãã¼ã¸ã§ã³ããµãã¼ãããã®ãããã©ããexceptã¨finallyãåãã¬ãã«ã§æ¸ããããã«ãªã£ãã®ã 2.5 ããã¨ããã¯ãï¼ã¨ãæããã ãããããããåºæ¬çãªã¨ããã¯ãã£ã¨åæãããµãã¼ããã¦ããã¦ã»ããã
ã»ãã«ã Exception ã¯ã©ã¹ã new-style ã«ãªã£ãã®ã 2.6 ããã¨ããä»ã¾ã§ãªã£ã¦ãªãã£ãã®ããï¼ã¨æããnew-style class ã®å°å ¥èªä½ã¯ãã£ã¨å¤ãããããã¦ããã ããããããªå¤æ´ã¯ 2.3 ã 2.4 ã®ããã§æ¸ã¾ãã¨ãã¦ã»ããã2.6 ã§åãããããã¹ããã¨ã©ã¼ã«ãªãã¾ãã£ã¦ç¦ã£ããã
ãã®ã¸ãã¯ãã¾ã PHP ã Ruby ã®ã»ããã¾ãã ãããRuby ã®æ§æ㯠1.6 ããç¹ã«å¤§ããªå¤æ´ã¯ãªããããµãã¼ãã¯æ¥½ã (ä»ãã 1.6 ããµãã¼ãããå¿ è¦ã¯ãªããã©)ãæ¡ä»¶æ¼ç®åã¯æãã使ããããbegin/rescue/ensure ã¯ãã¤ã§ãåãã¬ãã«ã§æ¸ããããã¯ã©ã¹å®ç¾©ã new-style ã«å¤æ´ããããªãã¦ãã¨ããªãã
人ã«ãã£ã¦æãæ¹ã¯éãã ãããã©ãRuby ã¯è¨èªã®ã³ã³ã»ãããæåãããã£ãããã¦ãã (ããã«æã) ãããæ§æã¬ãã«ã®å¤æ´ã¨ã Object ã¯ã©ã¹ã®ä»çµã¿ãå¤ããã¨ããªãã¦ãå¤ããã®ã¯ã©ã¤ãã©ãªã®ã»ãã ãã ããè¤æ°ãã¼ã¸ã§ã³ã®ãµãã¼ãã¯å¥ã«é£ãããªããã§ã Python ã®ããã« object ã¬ãã«ã§ã®å¤æ´ã¨ãæ§æã¬ãã«ã®å¤æ´ãã¡ããã¡ãããã£ã¦ããã¤å¤ããã¼ã¸ã§ã³ãåºã使ããã¦ãããããã¨ãè¤æ°ãã¼ã¸ã§ã³ã®ãµãã¼ãã¯ããªãããã©ãã
ç¹ã« Python 2.x 㨠3.x ã®ä¸¡ãµãã¼ãã¯æ³£ããããæ§æã¬ãã«ã§äºææ§ããªãããããããããªããã¼ãªæ¸ãæ¹ãããªãã¨ãããªãããã¨ãã£ã¦ã2.x 㨠3.x ã¨ã§ã½ã¼ã¹ãåããã®ãã¡ã³ããã³ã¹ãè¶ ããã©ããããRuby 1.8 㨠1.9 ã®ä¸¡ãµãã¼ããç°¡åãªã®ã«æ¯ã¹ãã¨ãã©ããã¦ãããã
ãã¤ã¾ã§ Python ã®å¤ããã¼ã¸ã§ã³ããµãã¼ãããªãããããªãã®ã ããããå°ãªãã¨ã CentOS 5 ã¯ãã¨æ°å¹´ã¯ç¾å½¹ã§ä½¿ãããã ããããããã®é㯠2.4 ã®ãµãã¼ãã¯å¿ è¦ã ãããã¾ã Google App Engine 㯠2.5.2 ã ãããApp Engine ã¦ã¼ã¶ã¯ Python 3 ã¸ã®ç§»è¡ãªãã¦å½åã§ãããã«ãªããGoogle ãã¨ã£ã¨ã¨ 3 ã«ç§»è¡ãã¦ãããªãã¨ãPython 3 ã主åã«ãªããã¨ã¯ãªãããã«æããæ®å¿µãªããã
ãããªããã§ãã©ãªãã Snow Leopard 㧠2.4 ã 2.5 ãã³ã³ãã¤ã«ããæ¹æ³ãæãã¦ãã ãããããããããã£ã¦ãããã£ã±ã解決ã§ãã¸ãã