åºç« : Pythonãšã¯äœãïŒ
Pythonã®æŠèŠ
Pythonã¯ãéåžžã«äººæ°ã®ããæ±çšçãªããã°ã©ãã³ã°èšèªã§ããããã®æå¿«ãªæ§æãšã³ãŒãã®å¯èªæ§ã¯åå¿è ã«ãæ±ããããç¹åŸŽãšãªã£ãŠããŸãããã®èšèªã¯ãåºç¯ãªé åã§æŽ»çšãããŠããããŠã§ãéçºããããŒã¿åæãæ©æ¢°åŠç¿ããã·ã¹ãã ã¹ã¯ãªããäœæãŸã§å€å²ã«ããããŸããPythonã¯ãªãŒãã³ãœãŒã¹ã§ãããå šäžçã®éçºè ãã¡ããã®æ©èœãæ¡åŒµããæ¹åãç¶ããŠããŸãã
Pythonã®ç¹æ§ãšå©ç¹
Pythonã¯ããã®åªããç¹æ§ãšå©ç¹ã«ãããéçºè ãã¡ã«åºãæãããŠããŸãããŸããPythonã®ç¬ç¹ãªç¹æ§ã§ããã人éããããã«ã€ããŠè§ŠããŠã¿ãŸããããPythonã®æ§æã¯æå¿«ã§ãã³ãŒãã人éã®èšèã«è¿ã圢ã§æžããããããç解ããããã®ãç¹åŸŽã§ããããã¯ãèªã¿ããããéèŠã§ããããšããPythonã®èšèšå²åŠããæ¥ãŠããŸãã
ãŸããPythonã¯ãããããªãŒå梱ïŒbatteries includedïŒããšãèšãããæšæºã©ã€ãã©ãªãè±å¯ã§ããããã®ãŸãŸã§ãå€ãã®ããšãã§ããŸãããŠã§ããµãŒããŒã®éçºããããŒã¿ããŒã¹ã®æ¥ç¶ãGUIã®äœæãŸã§ãPythonã®æšæºã©ã€ãã©ãªã ãã§ãååã«å¯Ÿå¿å¯èœã§ãã
ããã«ãPythonã¯åŒ·åãªã³ãã¥ããã£ãæã£ãŠããŸããäžçäžã®Pythonéçºè ãã¡ã¯åé¡ã解決ããæ°ããã©ã€ãã©ãªãäœæããPythonèšèªãã®ãã®ãæ¹åããããã«ååãåã£ãŠããŸãããã®çµæãPythonã®ãšã³ã·ã¹ãã ã¯éåžžã«æŽ»çºã§ãããã©ããªåé¡ã解決ã§ããå¯èœæ§ããããŸãã
æåŸã«ãPythonã¯å€ç®çãšããå©ç¹ããããŸãããŠã§ãéçºããããŒã¿åæãç§åŠèšç®ãæè²ãã²ãŒã éçºãŸã§ãPythonã¯ã©ããªé åã§ã䜿çšã§ããŸããããã¯Pythonãæã€æ±çšæ§ãšæè»æ§ã«ãããã®ã§ãããã«ããPythonã¯æ§ã ãªã·ãã¥ãšãŒã·ã§ã³ã§ã®åé¡è§£æ±º
ã«é©ããŠããŸãã
以äžãPythonã®æŠèŠãšããã®ç¹æ§ãå©ç¹ã«ã€ããŠã®è§£èª¬ã§ãã次ã®ã»ã¯ã·ã§ã³ã§ã¯ãPythonã®ã€ã³ã¹ããŒã«æ¹æ³ãåºæ¬çãªææ³ãäž»èŠãªããŒã¿åã«ã€ããŠè©³ããèŠãŠãããŸãããã
1. Pythonãå§ããã
Pythonã®ã€ã³ã¹ããŒã«æ¹æ³
Pythonã®ã€ã³ã¹ããŒã«ã¯éåžžã«ç°¡åã§ãå€ãã®å Žåãå ¬åŒãŠã§ããµã€ãããããŠã³ããŒãå¯èœãªã€ã³ã¹ããŒã©ãçšããŠè¡ããŸããå ¬åŒãŠã§ããµã€ãã¯Pythonã®ããŒãžã§ã³ãéžæãã察å¿ããOSãæå®ããããšã§ããŠã³ããŒããªã³ã¯ãæäŸããŸããããŠã³ããŒããå®äºããããã€ã³ã¹ããŒã©ãå®è¡ããæ瀺ã«åŸã£ãŠPythonãã€ã³ã¹ããŒã«ããŸããããããŠPythonãæ£ããã€ã³ã¹ããŒã«ããã°ãã³ãã³ãã©ã€ã³ããPythonãèµ·åããPythonã®ã³ãŒããå®è¡ããããšãå¯èœã«ãªããŸãã
Pythonã®åºæ¬çãªææ³
Pythonã®ææ³ã¯ä»ã®ããã°ã©ãã³ã°èšèªãšæ¯ã¹ãŠãã·ã³ãã«ã§çŽæçã§ããäŸãã°ãå€æ°ã¯ç¹å¥ãªå®£èšãªãã«äœæã§ããå€ã®ä»£å ¥ã¯çå·ïŒ=ïŒã䜿çšããŸãããŸããæ¡ä»¶æïŒifïŒãã«ãŒãïŒforãwhileïŒã容æã«ç解ã§ãã圢ã§æäŸãããŠããŸãã
Pythonã¯ã€ã³ãã³ãïŒåäžãïŒãçšããŠã³ãŒãã®ãããã¯ãå®çŸ©ããŸããããã¯ãä»ã®å€ãã®èšèªãäžæ¬åŒ§ãçšããã®ãšã¯å¯Ÿç §çã§ããããã«ããPythonã®ã³ãŒãã¯èŠãç®ãæŽã£ãŠããŠèªã¿ããããªã£ãŠããŸãããã ããããã¯åæã«ãæ£ããã€ã³ãã³ããè¡ããªããã°ãªããªããšããèŠåãååšãããããããã«ã¯æ³šæãå¿ èŠã§ãã
Pythonã®äž»èŠãªããŒã¿å
Pythonã«ã¯æ°å€ïŒæŽæ°ãæµ®åå°æ°ç¹æ°ãè€çŽ æ°ïŒãæååããªã¹ããã¿ãã«ãèŸæžãéåãªã©ãå€ãã®ããŒã¿åãååšããŸãããããã®ããŒã¿åã¯ããããç°ãªãç¹æ§ãšçšéãæã¡ããŸãããããã«å¯Ÿããå€ãã®æäœïŒã¡ãœããïŒãæäŸãããŠããŸããäŸãã°ããªã¹ãã¯é åºãæã€è€æ°ã®èŠçŽ ãæ ŒçŽããããã®ããŒã¿åã§ãèŠçŽ ã®è¿œå ãåé€ããœãŒããªã©ã®æäœãå¯èœã§ãã
ã³ãŒãã®æžãæ¹ãšãšã©ãŒã®èªã¿æ¹
Pythonã®ã³ãŒãã¯äžè¬çã«äžããäžãžãšå®è¡ãããŸããããããæ¡ä»¶æãã«ãŒããé¢æ°ãã¯ã©ã¹ã®å®çŸ©ãªã©ã«ããããã®æµãã¯å€åããŸãããããã®æ§é ãç解ããé©åã«ã³ãŒããæžãããšã¯éèŠã§ãã
äžæ¹ãPythonã®ã³ãŒããå®è¡ãããšãã«ã¯ãšã©ãŒãçããããšããããŸãããšã©ãŒã¯å€§ããåããŠæ§æãšã©ãŒãšå®è¡æãšã©ãŒã®2çš®é¡ã«åé¡ãããŸããæ§æãšã©ãŒã¯ã³ãŒãã®æžãæ¹ãééã£ãŠããå Žåã«çããå®è¡æãšã©ãŒã¯ã³ãŒãã®å®è¡äžã«åé¡ãçºçããå Žåã«çããŸãããšã©ãŒã¡ãã»ãŒãžã¯ãšã©ãŒã®çš®é¡ãšçºçããå Žæãåå ã瀺ãããããããèªã¿è§£ãèœåã¯éèŠãªã¹ãã«ãšãªããŸãã
以äžãPythonã®åºæ¬çãªæ å ±ã«ã€ããŠã®è§£èª¬ã§ãã次ã®ã»ã¯ã·ã§ã³ã§ã¯ãPythonã®ããã«è©³çŽ°ãªæŠå¿µã«ã€ããŠèª¬æããŸãã
2. Pythonã®åºæ¬æŠå¿µãæ·±æã
ããã°ã©ãã³ã°ã®äžçã¯ãè€éãªåé¡ã解決ããããã®å€æ§ãªããŒã«ãšæŠå¿µã§æºã¡ãŠããŸããPythonãšããèšèªã¯ããã®ã¢ãããŒãã®äžå¿ã«äœçœ®ããŠãããé¢æ°ããªããžã§ã¯ãæåããã°ã©ãã³ã°ãã¢ãžã¥ãŒã«ããšã©ãŒãã³ããªã³ã°ããã¹ãããããã°ãªã©ã®æŠå¿µãçšããŠãåé¡è§£æ±ºã®ããã»ã¹ãã·ã³ãã«ã§å¹ççã«ããŸãã
é¢æ°ãšãªããžã§ã¯ãæåããã°ã©ãã³ã°
Pythonã§ã¯ããé¢æ°ããšããæŠå¿µãäžå¿çãªåœ¹å²ãæãããŸããé¢æ°ã¯äžé£ã®æé ãã«ãã»ã«åããããããåå©çšå¯èœãªã³ãŒããããã¯ãšããŠè¡šçŸããŸããããã«ãããã³ãŒãã®åé·æ§ãåæžããã¡ã³ããã³ã¹ã容æã«ããŸãã
äžæ¹ãããªããžã§ã¯ãæåããã°ã©ãã³ã°ãã¯ãããã°ã©ãã³ã°ãããçŸå®ã®äžçã«è¿ã¥ããããã®ã¢ãããŒãã§ãããã®ã¢ãããŒãã§ã¯ãå®äžçã®ãç©äœãããäºè±¡ããè¡šçŸããããã«ãã¯ã©ã¹ããããªããžã§ã¯ããã䜿çšãããŸããããã«ãããã³ãŒãã¯çµç¹åããã管çãããããªããŸãã
ã¢ãžã¥ãŒã«ãšããã±ãŒãžã®å©çš
Pythonã®å匷ãã®äžéšã¯ããã¢ãžã¥ãŒã«ããšãããã±ãŒãžãã®æŽ»çšã«ãããã®ã§ããã¢ãžã¥ãŒã«ã¯ãé¢é£æ§ã®ããé¢æ°ãã¯ã©ã¹ãäžã€ã®ãã¡ã€ã«ã«ãŸãšãããã®ã§ãããã±ãŒãžã¯ãããã¢ãžã¥ãŒã«ãäžã€ã®ãã£ã¬ã¯ããªã«ãŸãšããçµç¹åãããã®ã§ãã
ããã«ãããPythonã¯å€§èŠæš¡ãªãããžã§ã¯ãã«ã察å¿ã§ããããã«ãªããããã«åºç¯ãªã³ãŒãããŒã¹ã®å ±æãšåå©çšãå¯èœã«ããŠããŸãã
ãšã©ãŒãã³ããªã³ã°ãšäŸå€åŠç
å šãŠã®ããã°ã©ãã³ã°èšèªã¯ãšã©ãŒãã³ããªã³ã°ãšäŸå€åŠçã®æŠå¿µãæã£ãŠããŸãããPythonã§ã¯ãããç¹ã«éèŠã§ããPythonã®ãšã©ãŒãã³ããªã³ã°ã¯ãããã°ã©ã ã®ä¿¡é Œæ§ãšããã¹ãæ§ãåäžãããããã«çšããããŸãã
ãšã©ãŒãçºçãããšããPythonã¯äŸå€ããã¹ããŒãããŸãããããŠããã®äŸå€ãé©åã«ããã£ãããããŠåŠçããããšã§ãããã°ã©ã ã¯ã¯ã©ãã·ã¥ããããšãªããé©åã«ãšã©ãŒãå ±åããããå埩ããããšãå¯èœã«ãªããŸãã
ãã¹ããšãããã°
æåŸã«ãåªããããã°ã©ã ã¯ãã¹ããšãããã°ã®ããã»ã¹ãçµãããšãäžå¯æ¬ ã§ãããã¹ãã¯ãã³ãŒããæåŸ ã©ããã«æ©èœããããšã確èªããŸããäžæ¹ããããã°ã¯ãåé¡ãçºçãããšãã«ãã®åå ãç¹å®ããä¿®æ£ããããã»ã¹ã§ãã
Pythonã«ã¯ããããã®ããã»ã¹ãæ¯æŽããããã®æ§ã ãªããŒã«ããããŸããããã«ãããPythonã¯ä¿¡é Œæ§ãšå¹çæ§ãå Œãåããããã°ã©ãã³ã°èšèªãšãªããŸãã
以äžã®èŠçŽ ãéããŠãPythonã¯ãã®ç°¡æœããšæè»æ§ã掻ãããåå¿è ãããããã§ãã·ã§ãã«ãŸã§å¹ åºããŠãŒã¶ãŒã«å¯ŸããŠåŒ·åãªããã°ã©ãã³ã°ããŒã«ãæäŸããŠããŸãã
3. Pythonã§ããŒã¿ãæäœãã
ããŒã¿ã¯çŸä»£ç€ŸäŒã®ç³æ²¹ãšãèšããã»ã©ãç§ãã¡ã®ç掻ãããžãã¹ã«æ·±ãé¢äžããŠããŸãããããŠãããŒã¿ãå¹æçã«æäœããèœåã¯ãå€ãã®åéã§éèŠãªã¹ãã«ãšãªã£ãŠããŸããPythonã¯ãã®åãçºæ®ããããŸããŸãªåœ¢åŒããœãŒã¹ããã®ããŒã¿æäœã容æã«ããŸãã
ãã¡ã€ã«æäœ
Pythonã¯ããã¹ããã¡ã€ã«ãCSVãJSONãªã©ãå€æ§ãªåœ¢åŒã®ãã¡ã€ã«ãšç°¡åã«å¯Ÿè©±ããããšãã§ããŸãããããã®ãã¡ã€ã«ããã®ããŒã¿èªã¿èŸŒã¿ãããŒã¿ãžã®æžã蟌ã¿ã¯Pythonã®åºæ¬çãªãã¡ã€ã«æäœã«ãã£ãŠå¯èœãšãªããŸãã
äŸãã°ãããã¹ããã¡ã€ã«ããã®èªã¿èŸŒã¿ã¯ãå èµé¢æ°ã®openã䜿çšããŠè¡ããŸãããããŠããã¡ã€ã«ãªããžã§ã¯ãã®ã¡ãœããã䜿ã£ãŠãã¡ã€ã«ã®å 容ãèªã¿èŸŒã¿ãŸãããã®éãå¿ èŠã«å¿ããŠãšã³ã³ãŒãã£ã³ã°ãæå®ããããšãã§ããŸãã
ããŒã¿ããŒã¹æäœ
ããŒã¿ããŒã¹ã¯ãæ§é åãããããŒã¿ãå¹ççã«æ ŒçŽãæ€çŽ¢ãæŽæ°ããããã®ããŒã«ã§ããPythonã¯ãããŸããŸãªçš®é¡ã®ããŒã¿ããŒã¹ãšé£æºããããŒã¿ãæäœããããšãå¯èœã§ãã
Pythonã®æšæºã©ã€ãã©ãªã«ã¯SQLiteãå«ãŸããŠãããããã䜿çšããããšã§ãè€éãªèšå®ããµãŒããŒã®æºåãªãã«SQLããŒã¿ããŒã¹ãšå¯Ÿè©±ããããšãã§ããŸãããŸããPythonããMySQLãPostgreSQLãªã©ã®ä»ã®ããŒã¿ããŒã¹ã·ã¹ãã ãšå¯Ÿè©±ããããã®ã©ã€ãã©ãªãæäŸãããŠããŸãã
Webã¹ã¯ã¬ã€ãã³ã°ãšAPIã®å©çš
Pythonã¯ãŠã§ãããã®ããŒã¿ååŸããµããŒãããŠããŸãããŠã§ãããŒãžããããŒã¿ãååŸããããšãããŠã§ãã¹ã¯ã¬ã€ãã³ã°ããšåŒã³ãPythonã®ã©ã€ãã©ãªã§ããBeautifulSoupãSeleniumãªã©ãçšããããšã§å¯èœãšãªããŸãã
ãŸããAPIïŒApplication Programming InterfaceïŒãéããŠããŒã¿ãååŸããããšãå¯èœã§ããAPIã¯ãããããã°ã©ã ãä»ã®ããã°ã©ã ãšéä¿¡ããããã®ã€ã³ã¿ãŒãã§ãŒã¹ã§ãããPythonã®requestsã©ã€ãã©ãªã䜿çšããããšã§HTTPããŒã¹ã®APIããããŒã¿ãååŸããããšãã§ããŸãã
ãããã®ããŒã«ãå©çšããããšã§ãPythonã¯ããŒã¿ãååŸãæäœããããŠåæãã匷åãªãã©ãããã©ãŒã ãšãªããŸãã
4. Pythonã®Webãã¬ãŒã ã¯ãŒã¯
Webãã¬ãŒã ã¯ãŒã¯ã¯ãWebã¢ããªã±ãŒã·ã§ã³ã®éçºãå©ããéçºè ãç¹°ãè¿ãåãã³ãŒããæžãæéãçããéçºæéãå€§å¹ ã«ççž®ããããšãå¯èœãšãªããŸããPythonã¯ãã®æ©èœãšæè»æ§ããå€ãã®Webãã¬ãŒã ã¯ãŒã¯ãçã¿åºããŠããŸããããã®äžã§ãç¹ã«æ³šç®ãã¹ã2ã€ã®ãã¬ãŒã ã¯ãŒã¯ãFlaskãšDjangoã«ã€ããŠè§£èª¬ããŠãããŸãã
Flaskã®åºæ¬
Flaskã¯ãPythonã§äœããã軜éãªWebãã¬ãŒã ã¯ãŒã¯ã§ãããã®ç¹é·ã¯ã·ã³ãã«ããšæ¡åŒµæ§ã«ãããéçºè ã¯åºæ¬çãªæ©èœã®ã¿ãæäŸããæ žå¿éšåã«éäžããå¿ èŠã«å¿ããŠèªç±ã«æ¡åŒµããããšãå¯èœã§ãã
Flaskã®ããäžã€ã®ç¹åŸŽã¯ãéçºè ãã¢ããªã±ãŒã·ã§ã³ã®æ§é ãèªç±ã«èšèšã§ããç¹ã§ããããã¯å€§èŠæš¡ãªãããžã§ã¯ãã ãã§ãªããå°èŠæš¡ãªãããžã§ã¯ãã«ãé©ããŠããŸããç¬èªã®æ§é ãæ¡çšã§ãããããã¢ããªã±ãŒã·ã§ã³ã®èšèšãå®è£ ã«èªç±åºŠããããããçŽæçã«ãããžã§ã¯ããé²ããããŸãã
Djangoã®åºæ¬
次ã«ãDjangoã§ããDjangoã¯Pythonã®ééçŽWebãã¬ãŒã ã¯ãŒã¯ã§ã”batteries included”ïŒå¿ èŠãªãã®ã¯å šãŠå«ãŸããŠããïŒãšããå²åŠã®ããšãéçºè ãå¿ èŠãšããã»ãŒå šãŠã®æ©èœãæäŸããŸããããã«ã¯èªèšŒãURLã«ãŒãã£ã³ã°ããã³ãã¬ãŒããšã³ãžã³ããªããžã§ã¯ããªã¬ãŒã·ã§ãã«ãããã³ã°ïŒORMïŒãããŒã¿ããŒã¹ã¹ããŒãã®ãã€ã°ã¬ãŒã·ã§ã³ãªã©ãå«ãŸããŸãã
Djangoã®ç¹åŸŽã¯ãã®å æ¬æ§ã§ãããå€æ©èœãã€è€éãªWebã¢ããªã±ãŒã·ã§ã³ãéçºããå Žåã«ç¹ã«æçšã§ãããã ãããã®å šãŠã䜿ãããªãã«ã¯ããçšåºŠã®åŠç¿ã³ã¹ããå¿ èŠãšãªããŸãã
ãã¬ãŒã ã¯ãŒã¯éžã³ã®ãã€ã³ã
ãã¬ãŒã ã¯ãŒã¯ã®éžæã¯ããããžã§ã¯ãã®ç®çãèŠæš¡ãéçºè ã®ã¹ãã«ã¬ãã«ãªã©ã«ãã£ãŠå€ãããŸããäŸãã°ãã·ã³ãã«ãªAPIãå°èŠæš¡ãªWebã¢ããªã±ãŒã·ã§ã³ãéçºããå Žåãã·ã³ãã«ããšæ¡åŒµæ§ã«åªããFlaskãé©ããŠããŸãã
äžæ¹ã倧èŠæš¡ãªWebã¢ããªã±ãŒã·ã§ã³ãéçºããå Žåããå€æ©èœãªWebãµãŒãã¹ãæäŸãããå Žåã«ã¯ãå šãŠã®æ©èœãå å ãããDjangoãé©ããŠããŸãããããããã®åŒ·åãªæ©èœã¯åŠç¿ã³ã¹ãã䌎ããŸãã®ã§ããã®ç¹ãèæ ®ããããšãéèŠã§ãã
ãŸããéçºè ã®Pythonã¹ãã«ã¬ãã«ãéèŠãªèŠçŽ ãšãªããŸããFlaskã¯ãã®ã·ã³ãã«ãããååŠè ã«ãåãçµã¿ãããäžæ¹ãDjangoã¯ãã®æ©èœæ§ããäžçŽè 以äžã®ã¹ãã«ãæ±ããããŸãã
5. Pythonã§ã¢ããªéçºãå§ãã
Pythonã§ã¢ããªéçºãå§ããã«ã¯ããŸãéçºç°å¢ã®ã»ããã¢ããããå§ããŸãããã®åŸãå ·äœçãªãããžã§ã¯ãã®èšç»ãšèšèšãè¡ããå®éã®ã³ãŒãã£ã³ã°ãšãã¹ãã«é²ã¿ãŸãããã®éçšå šäœãã¢ããªéçºã®ãããŒãšãªããŸãã
éçºç°å¢ã®ã»ããã¢ãã
ã¢ããªéçºãå§ããæåã®äžæ©ã¯ãéçºç°å¢ã®ã»ããã¢ããã§ããPythonã®ã€ã³ã¹ããŒã«ããå§ããå¿ èŠãªã©ã€ãã©ãªãããŒã«ãIDEïŒçµ±åéçºç°å¢ïŒã®ã»ããã¢ãããå«ãŸããŸããPythonã®ããŒãžã§ã³ç®¡çã«ã¯pyenvããããã±ãŒãžç®¡çã«ã¯pipãcondaã䜿çšããŸããçµ±åéçºç°å¢ãšããŠã¯ãPyCharmãVSCodeãäžè¬çã§ãã
éçºç°å¢ã®ã»ããã¢ããã§ã¯ãã³ãŒãã®å®è¡ç°å¢ãçµ±äžããéçºè éã§ã®äºææ§ã確ä¿ããããšãç®çãšãªããŸãããŸããéçºç°å¢ã¯å®æçã«ã¢ããããŒãããææ°ã®ã»ãã¥ãªãã£ããããæ©èœãå©çšå¯èœãªç¶æ ã«ä¿ã€ããšãéèŠã§ãã
ãããžã§ã¯ãã®èšç»ãšèšèš
éçºç°å¢ãæŽã£ããã次ã«ãããžã§ã¯ãã®èšç»ãšèšèšã«ç§»ããŸããããã§ã¯ãã¢ããªã®ç®çãšç®æšãæ確ã«ããå¿ èŠãªæ©èœãšããããã©ã®ããã«åäœãããã決å®ããŸãã
ãŸããããŒã¿ããŒã¹ã®èšèšããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹ã®ãã¶ã€ã³ãAPIã®èšèšãªã©ãå ·äœçãªã¢ããªã®æ§é ãèããŸãããããã¯ãããžã§ã¯ãã®å šäœåãæããéçºè ãåãããžã§ã³ãå ±æããç®æãã¹ãæ¹åæ§ãæ確ã«ããããã«å¿ èŠã§ãã
ã³ãŒãã£ã³ã°ãšãã¹ãã®ãã¹ããã©ã¯ãã£ã¹
ã³ãŒãã£ã³ã°ã«å ¥ãåã«ãããã€ãã®ãã¹ããã©ã¯ãã£ã¹ãèŠããŠãããšè¯ãã§ããããPythonã§ã¯ãPEP8ãšããã¹ã¿ã€ã«ã¬ã€ãããããããã«åŸãããšãæšå¥šãããŠããŸãããŸããDRYïŒDon’t Repeat YourselfïŒååãå°éããã³ãŒãã®åå©çšæ§ãä¿ã€ããšãéèŠã§ãã
ãã¹ãã¯ã³ãŒãã£ã³ã°ãšäžŠè¡ããŠè¡ãããã³ãŒããæ£ããåäœããããšãä¿èšŒããŸããPythonã«ã¯unittestãšãããŠããããã¹ãã©ã€ãã©ãªãå èµãããŠããŸãããpytestãªã©ã®ãµãŒãããŒãã£è£œã©ã€ãã©ãªã䜿ãããšããããŸãã
ãã®ããã«ãã¢ããªã®éçºã¯æ®µéçãªããã»ã¹ã§ãããåã¹ããŒãžã§é©åãªå·¥å€«ãšåªåãè¡ãããšã§ãé«å質ã§ã¡ã³ããã³ã¹æ§ã®é«ãã¢ããªã±ãŒã·ã§ã³ãäœæããããšãã§ããŸãã
6. Pythonã¢ããªã®ãããã€ãšã¡ã³ããã³ã¹
ã¢ããªã±ãŒã·ã§ã³éçºã®çµç€ã§ã¯ããããã€ã¡ã³ããšã¡ã³ããã³ã¹ãäž»èŠãªã¿ã¹ã¯ãšãªããŸãããã®ã¹ããŒãžã§ã¯ãéçºããã¢ããªã±ãŒã·ã§ã³ããŠãŒã¶ãŒãå©çšã§ããããã«å ¬éãïŒãããã€ïŒããã®åŸãå®å®ããæ§èœãšã»ãã¥ãªãã£ãç¶æãã€ã€æ°æ©èœãè¿œå ãŸãã¯æ¢åã®åé¡ãä¿®æ£ããïŒã¡ã³ããã³ã¹ïŒããšãæ±ããããŸãã
ãããã€ã¡ã³ãã®åºæ¬
ãããã€ã¡ã³ããšã¯ãéçºããã¢ããªã±ãŒã·ã§ã³ãå®éã®éçšç°å¢ã«é 眮ãããŠãŒã¶ãŒãå©çšã§ããç¶æ ã«ããããšã§ããPythonã¢ããªã±ãŒã·ã§ã³ã®ãããã€ã«ã¯ãWSGIãµãŒããŒã®èšå®ããªããŒã¹ãããã·ã®èšå®ãéçãã¡ã€ã«ã®ç®¡çãªã©ãå€ãã®äœæ¥ãå«ãŸããŸãã
ãŸããã¯ã©ãŠããµãŒãã¹ãå©çšãããšããããã®äœæ¥ãå€§å¹ ã«ç°¡çŽ åã§ããŸããäŸãã°ãHerokuãGoogle Cloud Platformãªã©ã®PaaSïŒPlatform as a ServiceïŒã§ã¯ããœãŒã¹ã³ãŒããã¢ããããŒãããã ãã§ã¢ããªã±ãŒã·ã§ã³ããããã€ãããèªåçã«ã¹ã±ãŒãªã³ã°ãè¡ãããŸãã
ããŒãžã§ã³ç®¡çãšæŽæ°
ã¢ããªã±ãŒã·ã§ã³ã®ã¡ã³ããã³ã¹ã«ã¯ãããŒãžã§ã³ç®¡çãšæŽæ°ãå«ãŸããŸããããŒãžã§ã³ç®¡çã¯ããœãããŠã§ã¢ã®å€æŽå±¥æŽã远跡ããããã®ã·ã¹ãã ã§ãGitãæãåºã䜿çšãããŠããŸããããŒãžã§ã³ç®¡çã·ã¹ãã ã䜿çšããããšã§ãç¹å®ã®ããŒãžã§ã³ã®ãœãããŠã§ã¢ãç°¡åã«åãåºãããšãã§ããåé¡ãçºçããå Žåã«åã®ããŒãžã§ã³ã«æ»ãããšãå¯èœã«ãªããŸãã
ãŸããæ°æ©èœã®è¿œå ãæ¢åã®åé¡ã®ä¿®æ£ãå¿ èŠãªå Žåãã¢ããªã±ãŒã·ã§ã³ãæŽæ°ããå¿ èŠããããŸããããã«ã¯ãæ°ããããŒãžã§ã³ã®ãœãããŠã§ã¢ããããã€ããäœæ¥ãå«ãŸããŸãã
ããã©ãŒãã³ã¹ã®æé©åãšã»ãã¥ãªãã£
ã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ã®æé©åãšã»ãã¥ãªãã£ã®ä¿èšŒãéèŠãªã¡ã³ããã³ã¹äœæ¥ã§ããããã©ãŒãã³ã¹ã®æé©åã«ã¯ãã³ãŒãã®ãªãã¡ã¯ã¿ãªã³ã°ãããŒã¿ããŒã¹ã®æé©åããã£ãã·ã³ã°ã®äœ¿çšãªã©ããããŸãããããã¯ã¢ããªã±ãŒã·ã§ã³ã®å¿çé床ãåäžããããŠãŒã¶ãŒäœéšãæ¹åããŸãã
äžæ¹ãã»ãã¥ãªãã£ã¯ã¢ããªã±ãŒã·ã§ã³ã®ä¿¡é Œæ§ãšãŠãŒã¶ãŒã®æ å ±ä¿è·ã«çŽçµããŠããŸããææ°ã®ã»ãã¥ãªãã£ããããé©çšããå®å šãªã³ãŒãã£ã³ã°ãã©ã¯ãã£ã¹ãå®ãããšã§ãæ»æè ããã¢ããªã±ãŒã·ã§ã³ãå®ããŸãã
çµè«: Pythonã§ã¢ããªãäœã楜ãã
Pythonã§ã¢ããªã±ãŒã·ã§ã³ãäœãããšã¯ãã³ãŒãã£ã³ã°ã¹ãã«ã䌞ã°ãã ãã§ãªããå ·äœçãªåé¡ã解決ããããã®ããŒã«ãäœãåºã楜ãããå³ããããšãã§ããŸããPythonã¯è±å¯ãªã©ã€ãã©ãªãšèŠªåãªã³ãã¥ããã£ããããŠå¹ åºãå©çšã·ãŒã³ãæã£ãŠãããããåŠã¶ããšã§ç¡éã®å¯èœæ§ãåºãããŸãã
Pythonã³ãã¥ããã£ãšãªãœãŒã¹
Pythonã³ãã¥ããã£ã¯å šäžçã«åºãã£ãŠãããããããã®å°éåéã§æŽ»åããŠããå€ãã®éçºè ãããŸããStack OverflowãGitHubãRedditãªã©ã®ãã©ãããã©ãŒã ã§ã¯ãPythonã«é¢ãã質åãè°è«ã掻çºã«è¡ãããŠããŸãããŸããPythonã®å ¬åŒãŠã§ããµã€ãã§ã¯ãæ§ã ãªããã¥ã¡ã³ããŒã·ã§ã³ããã¥ãŒããªã¢ã«ãæäŸãããŠããŸãããããã®ãªãœãŒã¹ã掻çšããããšã§ãPythonã®åŠç¿ãæ·±ããåé¡è§£æ±ºã®æå©ããåŸãããšãã§ããŸãã
次ã®ã¹ããã: Pythonã®é«åºŠãªãããã¯
åå¿è åãã®å 容ãäžéãåŠã³çµãããã次ã¯Pythonã®ããé«åºŠãªãããã¯ã«é²ãããšãããããããŸãããªããžã§ã¯ãæåããã°ã©ãã³ã°ãéåæåŠçããã³ã¬ãŒã¿ããžã§ãã¬ãŒã¿ãªã©ãPythonã®é«åºŠãªæ©èœãç解ããããšã§ãããå¹ççã§é«å質ãªã³ãŒããæžãããšãã§ããããã«ãªããŸãã
ãŸããç¹å®ã®åéã«çŠç¹ãåœãŠãåŠç¿ãæçšã§ããããŒã¿åæãæ©æ¢°åŠç¿ãWebéçºãã¹ã¯ãªããã£ã³ã°ãªã©ãPythonã®äœ¿çšç®çã«åãããŠé©åãªã©ã€ãã©ãªããã¬ãŒã ã¯ãŒã¯ãåŠã¶ããšã§ãèªèº«ã®ã¹ãã«ã»ãããæ¡åŒµããããšãã§ããŸãã