Pythonã§ã¯ããã¼ã¨å¤ãçµã¿åãããdictionaryï¼è¾æ¸ï¼ãã¨ãããã®ãããã¾ãã è¾æ¸ã使ç¨ãããã¨ã§ãç¹å®ã®è¦ç´ ãæ¤ç´¢ãããã追å ãåé¤ãç°¡åã«ã§ãã¾ãã ããããdictionaryã£ã¦ä½ï¼ dictionaryã®åºæ¬çãªä½¿ãæ¹ãç¥ããã ãã®è¨äºã§ã¯ãPythonã§ããããã£ãå®ç¾©ããæ¹æ³ã解説ãã¾ããããããã£ãå®ç¾©ãããã¨ã§ãããå®å
¨æ§ã®é«ãã¯ã©ã¹ãå®è£
ãããã¨ãã§ãã¾ããããããã£ã¨ã¯ï¼ããããã£ã¨ã¯ãã¯ã©ã¹å¤é¨ããã¯ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã®ããã«ä½¿ç¨ã§ããã¯ã©ã¹å
é¨ã§ã¯ã¡ Python3.4ã§åæåã追å ããã¾ãããåæå(Enum)ã¨ã¯ãæ½è±¡ãã¼ã¿ãå®ç¾©ããããã®ãã®ã§ãæ§å¥ãªã©ã®ãã¸ãã¯ãã³ãã¼ã使ã£ã¦ãã¾ããããªå¤ãåã¨ãã¦å®ç¾©ãããã¨ãã§ãã¾ããããã§ã¯ãããªåæå(Enum)ã®ä½¿ãæ¹ãåå¿è
ã®æ¹ã«åããããã解説ãã¾ãã matlabã§evalé¢æ°ãç¨ãã¦å¤æ°ãä½ãããã«ãname0,name1,name2ã»ã»ã»ã¨ãããããª"æåå"+æ°å¤ãç¹°ãè¿ãæã§ä½ãããã®ã§ãããPythonã®åå¿è
ãªãã®ã§æ¤ç´¢ãã¦ãå
¨ããããã¾ãããããããã ⦠å¤é¨ããã¯ã©ã¹å¤æ°ã«ã¢ã¯ã»ã¹ããã«ã¯ãã¯ã©ã¹å.ã¯ã©ã¹å¤æ°ã§ã¢ã¯ã»ã¹ãããã¤ã³ã¹ã¿ã³ã¹ãçæãã¦ããå ´åã¯ã¤ã³ã¹ã¿ã³ã¹å.ã¯ã©ã¹å¤æ°ã§ãã¢ã¯ã»ã¹ã§ããã ã¯ã©ã¹å¤æ°ãã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¨ãã«ã¯ã©ã¹ã®å¤å´ãã追å ãããã¨ãã§ããã ãã¡ãã§ã¯ã©ã¹å¤æ°ã¨ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã«ã¤ãã¦ã調ã¹ã¦ããã®ã§ãããåãããªããã¨ããã質åããã¦è²°ãã¾ããã. Python ã§ã¯ãããã°ã©ã è¨è¨è
ãæ³å®ãã¦ããªãå¤æ´ãå ãããããã¨ã«ãã£ã¦ãé大ãªã¨ã©ã¼ãçºçãããã¨ãé²ãããã«ãã¯ã©ã¹ã®ããããã£ï¼ã¤ã³ã¹ã¿ã³ã¹å¤æ°ãã¯ã©ã¹å¤æ°ã®å¤ï¼ããå¤é¨ããèªã¿åã£ãããæ´æ°ãããã§ããªãããã«ãããã¨ãã§ãã¾ãã ããã ãã»ã»ã»ã¨ããã®ãã¤ã³ã¹ã¿ã³ã¹å¤æ°ã§ãã ã¡ãªã¿ã«ã__init__ã¯ã¤ãããã¨èªã¿ã¾ãã 3è¡ç®ä»¥éã§ãåã¤ã³ã¹ã¿ã³ã¹å¤æ°ã«ã¤ãã¦ã self. Pythonã§ã¯ã©ã¹å¤æ°ã«ã¢ã¯ã»ã¹ããããã©ã¼ãã³ã¹ã«é¢ããåã質å-@Edward Loperããæ¹é ãããã³ã¼ã. ã§ã¯ãã¤ã³ã¹ã¿ã³ã¹å¤æ°ãé常ã®ã¡ã½ããã¨ã®éããããããã説æãã¾ãã â»ããããã¤ã³ã¹ã¿ã³å¤æ°ã£ã¦ä½ï¼ã¨ããæ¹ã¯ãã¡ãã®è¨äºã«ã¦ç´¹ä»ãã¦ãã¾ãã Pythonã®ã¯ã©ã¹å¤æ°ã¨ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã«ã¯å°ã
çãããã¾ãã ã¯ã©ã¹å¤æ°ã¨ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¯åæã«ä½¿ç¨ããããã¨ãå¤ããããä½æãã `+ Shark +`ã¯ã©ã¹ã使ç¨ãã¦ãã®ä¾ãè¦ã¦ã¿ã¾ãããã ããã°ã©ã ã®ã³ã¡ã³ãã¯ãããã»ã¹ã®åã¹ãããã®æ¦è¦ã示ãã¦ãã¾ãã ã§ã³ãæ³å®ããå
容ã¨ãªã£ã¦ãããPythonã«æ
£ãã¦ããæ¹ã¯è¨è¿°æ¹å¼ãPythonå
¥éè
ã®æ¹ã¯Google Colaboratoryã使ç¨ããç©´åãå½¢å¼ã®æ¼ç¿ãå¯è½ã§ãã æåã®ã±ã¼ã¹ã§ã¯ããªã¹ãã¯ã¯ã©ã¹å±æ§ã§ããã¹ã¦ã®ã¤ã³ã¹ã¿ã³ã¹ã§å
±æããã¾ãã pãã¤ã³ã¹ã¿ã³ã¹åããã¨ãã«è¿½å ãããã®ã¨ãã¤ã³ã¹ã¿ã³ã¹åããf ï¼æåã®å¼ã³åºãã§ãã§ã«æåã®ãã®ã追å ããã¦ããã¨ãï¼ã追å ããã®ã§ã2ã¤ã®ãã¨ãããã¾ãã Python ã§ãæ¢åã®ãªãã¸ã§ã¯ãã«ã¡ã½ããã追å ããæ¹æ³ããç´¹ä»ãã¾ãã æ¢åã®ãªãã¸ã§ã¯ãã«ã¡ã½ããã追å ããæ¹æ³ã¯ 2 éãããã¾ãã ãã®ãªãã¸ã§ã¯ãã®ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ã¡ã½ããã追å ãã ã¤ã³ã¹ã¿ã³ã¹å¤æ°ãã¤ã³ã¹ã¿ã³ã¹ã¡ã½ãããã¯ã©ã¹å¤æ°ãã¯ã©ã¹ã¡ã½ãããã¹ã¿ãã£ãã¯ã¡ã½ãããç¶æ¿ã¨ãè²ã
ã¨ä½¿ãåããããã¨ä¾¿å©ã§ããï¼ æå¾ã«ãªãã¾ããæ¬ããã°ã§ã¯ãããã³ãã¨ã³ãã»Pythonã»æ©æ¢°å¦ç¿ãªã©éå¤ã«æ
å ±çºä¿¡ããã¦ããã¾ãã Python ã«ã¯å¤æ°ã«ã©ãã©ãæååã追å ãã¦ããã¡ã½ãããåå¨ããªãï¼ æ¢ãã¦ã¿ã¾ããããRubyã§ããã<<ãã®ãããªä¾¿å©ãªã¡ã½ããã¯ãªãããã§ããã ãªã¹ããªãã.appendãã¡ã½ãããããã¾ããã ãã¨ã¯é£çµã+ãã§ãã Ruby ãã = ãããã¨æ¸ãã¾ãããããã決ã¾ãã§ãã ããã§ãåæè¨å®ãçµããã¾ããã ä»å㯠Python ã«ãããã¤ã³ã¹ã¿ã³ã¹çææ¹æ³ã¨ãã¤ã³ã¹ã¿ã³ã¹ã®åæåæ¹æ³ã«ã¤ãã¦èª¬æãã¾ããã¤ã³ã¹ã¿ã³ã¹ã¯ãªãã¸ã§ã¯ãæåã«å¿
è¦ãªæ¦å¿µãªã®ã§ããã²ä½¿ããããã«ãã¦ããã¾ãããã ã¤ã³ã¹ã¿ã³ã¹ ⦠self ã«ã¯ Python ãå
é¨ã§èªåçã«æ¸¡ãã¾ãã ã¯ã©ã¹ Card ã®ã¤ã³ã¹ã¿ã³ã¹ã¨ã㦠card1 㨠card9 ãä½æãã¦ãã¾ããcard1 ã® self ã«ã¯ card1 ã®ãcard9 ã® self ã«ã¯ card9 ã®ã¤ã³ã¹ã¿ã³ã¹ãªãã¸ã§ã¯ãã渡ããã¾ãã ãªãprint(game.name1)ã§å¤ãæã£ã¦ãããªããã§ããããï¼ ãPythonå
¥éãã¯ã©ã¹ã®ç¶æ¿ã«ã¤ãã¦ãããã解説 ç¶æ¿ã¨ã¯. a.x = 10 ã¨ä»£å
¥æä½ãè¡ãã¨ãã¤ã³ã¹ã¿ã³ã¹å¤æ° x ãçæãã¦ãããã«å¤ 10 ã代å
¥ãã¾ãããããã£ã¦ã次㫠a.x ãå
¥åããã¨ããã®å¤ 10 ã表示ãã¾ãã ãã®ããã«ãPython ã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¯ã代å
¥æä½ãè¡ãããã¨ãã«çæããã¾ãã ç¶æ¿ï¼Inheritanceï¼ã¯ãã¯ã©ã¹ã®ä¸ã§ãã使ãããæ©è½ã®ä¸ã¤ã§ãã¯ã©ã¹æ©è½ãåå©ç¨ããã追å ã§ããã¨ã¦ããã¯ãã«ãªæ©è½ã TensorFlowãFlaskã¨ãã£ããã¬ã¼ã ã¯ã¼ã¯ç³»ã§ããã使ããã¦ãã¾ããã ã¢ããªãã¥ã¼ãã¨ã¯å¤æ°ã®ãããªãã®ãâã¤ã³ã¹ã¿ã³ã¹å.ã¢ããªãã¥ã¼ãåâã®ããã«ã¤ã³ã¹ã¿ã³ã¹ã«ç¶ãã¦ãããã§åºåã£ã¦è¨ããâã¯ã©ã¹å.ã¢ããªãã¥ã¼ãåâã§ãã¢ããªãã¥ã¼ããå¾ã§ã¯ã©ã¹ã«è¿½å ããããå¤æ°ãå¤æ´ããããããã¨ãã§ããã Pythonè¨èªã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¯ãã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¸ã®ä»£å
¥ãè¡ã£ãæããã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°ãã¯ã©ã¹æã§å®ç¾©ããã¦ããªãã£ãå ´åã«ã¤ã³ã¹ã¿ã³ã¹å
ã«èªåçã«çæãã¦ããã¾ãã ããã«ããã¤ã³ã¹ã¿ã³ã¹å¤æ°ãå¤é¨ãã追å ãããã¨ãã§ãã¾ã ±ãç¥ãããã§ããï¼ Pythonã¯åçè¨èªãªã®ã§ãé常ã«æè»ãªå¦çãå¯è½ã§ãã ãã®ã²ã¨ã¤ããå±æ§ã®åçãªæä½ã§ãã ããç¹æ®ãªå
容ã§ãããããã°ã©ãã³ã°ã§ä½¿ããã©ããã¯å¥ã¨ãã¦ãPythonã®èå°è£ãç¥ããã¨ãã§ãã¾ãã åå¿è
åãã«Pythonã®ã¯ã©ã¹ã«ç¨ããããprivateå¤æ°ã®å©ç¨æ¹æ³ã«ã¤ãã¦ç¾å½¹ã¨ã³ã¸ãã¢ã解説ãã¦ãã¾ããprivateã¯ã¢ã¯ã»ã¹ä¿®æ£åã§ã¯ã©ã¹å
ã§ããã¢ã¯ã»ã¹ã§ããªããã¨ãæå³ãã¦ãã¾ããPythonã®å ´åã¯ãå¤æ°ã®åã«ã¢ã³ãã¼ãã¼ã2ã¤ã¤ãã¦è¡¨ç¾ãã¾ãã