eBookã«ã¦è³¼å
¥ããããªãã®æ¬ã
ãã¥ã¼ããªã¢ã«ãèªã¿çµãã¦ãã°ããPythonã触ã£ã人ãç¬å¦ã§Pythonããã±ã¼ã¸ãPyPIã«ç»é²ããããã«ãªã£ã人ã¾ã§ãå
¥éè
ãé¤ãåºã層ã«ãå§ãã§ããã
Pythonã£ã¦ãæ¨æºã§ãPython以å¤ã®è¨èªã¯ä½¿ããããã°ã©ãåããã¥ã¼ããªã¢ã«ãããããããã°ã©ãã³ã°èªä½ã¯ããã¦ã®äººåãã®å
¥éæ¸ãåºã¦ãã
ã¾ã Chapter2 ãèªã¿çµããã¨ããã ãã©ãcontextlibã®ä½¿ãæ¹ã¨ãåå¼·ã«ãªã£ããwithæã¯äººã®ä½ã£ãcontext managerã使ã£ããã¨ã¯ãã£ã¦ããèªåã§context managerä½ã£ããã¨ç¡ãã£ãã
ãã ããµã³ãã«ã³ã¼ãã«ã¯ãã°ããææ¬ã¨ãã¦ãµãããããªãç¹ããããä¾ãã°ã
>>> from contextlib import contextmanager >>> from __future__ import with_statement
ãããã¤ã³ã¿ã©ã¯ãã£ãã·ã§ã«ã ããè¯ããã©ãã½ã¼ã¹ã³ã¼ãã«æ¸ã㨠__future__ ããã® import ã¯ã»ãã®æããå
ã«ãªãã¨ãããªãã®ã§SytaxErrorã«ãªãã
ã»ãã«ããã¡ã¤ã«ãéãã®ã« open() ãããªã㦠file() ã使ã£ã¦ãããããã
æ°ã¥ããç¹ã¯å¾ã§ã¾ã¨ãã¦ãã£ã¼ãããã¯ãããã
Twitterä¸ã§ç¿»è¨³ãã¦ã»ããã¨ãã話ããã£ããã ãã©ãæ¬å½ã«ç¿»è¨³ãããªãåºç社ã«è©±ãæã¡ããããããã®ããªï¼æè¡è©è«ç¤¾ãªãPython 3.0 Hacksã§æ å½ãã¦ããã£ã人ã®ååºæã£ã¦ããã©ã