<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>행복한 아빠</title>
<link>https://greatkim91.tistory.com/</link>
<description>씨티홀릭 CTO</description>
<language>ko</language>
<pubDate>Sat, 03 Jul 2021 16:45:44 +0900</pubDate>
<generator>TISTORY</generator>
<ttl>100</ttl>
<managingEditor>행복한아빠</managingEditor>
<item>
<title>Ubuntu에 장고 애플리케이션 배포</title>
<link>https://greatkim91.tistory.com/200</link>
<description>&lt;h1&gt;Installation On Ubuntu 14.04.3 LTS&lt;/h1&gt;&lt;ul style=&quot;list-style-type: square;&quot;&gt;&lt;li&gt;OS : Ubuntu 14.04.3 LTS&lt;/li&gt;&lt;li&gt;Python : 3.5&lt;/li&gt;&lt;li&gt;WSGI : uWSGI&lt;/li&gt;&lt;li&gt;Web : Nginx&lt;/li&gt;&lt;li&gt;DB : MySQL&lt;/li&gt;&lt;li&gt;Application 설치 디렉토리 :&amp;nbsp;/home/ubuntu/hello-web&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Python 3.5 설치&lt;/h3&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;Python 3.5&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Ubuntu 14 LTS는 python 2.7, python 3.4가 설치되어있다. 따라서 3.5는 따로 설치해야 한다. (그냥 기본 python 쓰기 위해서는 설치 불필요)&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;$ sudo add-apt-repository ppa:fkrull/deadsnakes&lt;br /&gt;$ sudo apt-get update&lt;br /&gt;$ sudo apt-get install python3.5&lt;br /&gt;$ python3.5 -V&lt;/p&gt;&lt;/div&gt;&lt;p&gt;python 3.5 명령어는 &quot;python3.5&quot;이다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;pip3 &amp;amp; virtualenv&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;python 3.5에 맞게 pip3와 virtualenv를 설치해야 한다.&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;$ wget https://bootstrap.pypa.io/get-pip.py&lt;br /&gt;$ sudo python3.5 get-pip.py&lt;br /&gt;$ sudo pip3 install virtualenv&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;mysql client 모듈&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;python mysqlclient 모듈 설치를 위해 다음을 설치해야 한다.&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;$ sudo apt-get install libmysqlclient-dev&lt;br /&gt;$ sudo apt-get install python3.5-dev&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Git 설치&lt;/h3&gt;&lt;p&gt;Git을 이용하여 소스를 관리하고 application을 배포한다면 git을 설치한다.&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;$ sudo apt-get install git&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Application 설치 (Git을 사용할 경우)&lt;/h3&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;$ git clone https://yourgitserver/hello/hello-web.git&lt;br /&gt;$ cd hello-web&lt;br /&gt;$ virtualenv venv&lt;br /&gt;$ source venv/bin/activate&lt;br /&gt;$ pip install -r requirements.txt&lt;/p&gt;&lt;/div&gt;&lt;p&gt;각자 다른 형상관리도구를 사용하면 그 도구에 맞게 소스를 옮긴다.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;uWSGI 구성&lt;/h3&gt;&lt;p&gt;실제 서비스는 WSGI Container에서 한다. WSGI Container로 uWSGI를 사용한다. uWSGI는 Emperor 모드로 실행한다.&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;$ pip install uwsgi&lt;br /&gt;$ mkdir /home/ubuntu/hello-web/logs&lt;br /&gt;$ sudo mkdir -p /etc/uwsgi/sites&lt;br /&gt;$ cd /etc/uwsgi/sites&lt;br /&gt;$ sudo vi hello.ini&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;/etc/uwsgi/sites/hello.ini&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;[uwsgi]&lt;br /&gt;project = hello-web&lt;br /&gt;base = /home/ubuntu&lt;br /&gt;&lt;br /&gt;chdir = %(base)/%(project)&lt;br /&gt;home = %(base)/%(project)/venv&lt;br /&gt;module = hello.wsgi:application&lt;br /&gt;&lt;br /&gt;master = true&lt;br /&gt;processes = 5&lt;br /&gt;&lt;br /&gt;socket = %(base)/%(project)/%(project).sock&lt;br /&gt;chmod-socket = 664&lt;br /&gt;vacuum = true&lt;br /&gt;logto = %(base)/%(project)/logs/%n.log&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;uWSGI를 Upstart 추가&lt;/h3&gt;&lt;p&gt;uWSGI 프로세스 관리를 upstart로 한다.&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;$ sudo vi /etc/init/uwsgi.conf&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;/etc/init/uwsgi.conf&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;description &quot;uWSGI application server in Emperor mode&quot;&lt;br /&gt;&lt;br /&gt;start on runlevel [2345]&lt;br /&gt;stop on runlevel [!2345]&lt;br /&gt;&lt;br /&gt;setuid ubuntu&lt;br /&gt;setgid www-data&lt;br /&gt;&lt;br /&gt;exec /home/ubuntu/hello-web/venv/bin/uwsgi --emperor /etc/uwsgi/sites&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;NGINX 구성&lt;/h3&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;$ sudo apt-get install nginx&lt;br /&gt;$ sudo vi /etc/nginx/sites-available/hello-web&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;/etc/nginx/sites-available/hello-web&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;server {&lt;br /&gt;&amp;nbsp; &amp;nbsp; listen 80;&lt;br /&gt;&amp;nbsp; &amp;nbsp; server_name hello.co.kr, www.hello.co.kr;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; location = /favicon.ico { access_log off; log_not_found off; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; location /static/ {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; root /home/ubuntu/hello-web;&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; location / {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; include &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;uwsgi_params;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; uwsgi_pass &amp;nbsp; &amp;nbsp; unix:/home/ubuntu/hello-web/hello-web.sock;&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;/p&gt;&lt;/div&gt;&lt;p&gt;hello-web 설정을 nginx 구동 디렉토리에 옮기고(symlink) 기본 설정은 삭제한다.&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;ln -s /etc/nginx/sites-available/hello-web /etc/nginx/sites-enabled/&lt;br /&gt;rm /etc/nginx/sites-enabled/default&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;구동&lt;/h3&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding: 10px;&quot;&gt;&lt;p&gt;$ sudo restart nginx restart&lt;br /&gt;$ sudo start uwsgi&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
<category>Python</category>
<category>Django</category>
<category>nginx</category>
<category>Python</category>
<category>Ubunt</category>
<category>uWSGI</category>
<category>장고</category>
<category>파이썬</category>
<author>행복한아빠</author>
<guid isPermaLink="true">https://greatkim91.tistory.com/200</guid>
<comments>https://greatkim91.tistory.com/200#entry200comment</comments>
<pubDate>Fri, 07 Oct 2016 11:13:58 +0900</pubDate>
</item>
<item>
<title>Java Jigsaw가 도대체 뭐지? - Java9의 핵심</title>
<link>https://greatkim91.tistory.com/197</link>
<description>&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:820px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2570403757E8DF751F&quot; filemime=&quot;image/jpeg&quot; filename=&quot;jigsaw-puzzle-712465_1920.jpg&quot; height=&quot;545&quot; width=&quot;820&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Java 9 이야기가 솔솔 들립니다. Java 9의 특징 중 가장 주목할 만한 것이 Java jigsaw라는 프로젝트에서 착안한 모듈화 시스템이라는데 대충 소개한 글로는 뭔 소리인지 몰라서 한 번 찾아봤습니다. 자세한 스펙이나 기능요소보다는 Java Jigsaw가 말하려는 개념을 구체적으로 이해할 수 있도록 정리합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;새로운 모듈 시스템?&lt;/h3&gt;&lt;p&gt;Java는 패키지의 name space나 패키징 방법을 제공하는 JAR 그리고 Maven이나 Gradle 같은 모듈 관련 기능 및 생태계가 비교적 잘 되어 있다고 믿었는데 난데없이 왜 새로운 모듈 시스템을 들고 나왔는지 이해가 안 갑니다.&lt;/p&gt;&lt;p&gt;그래서 Project Jigsaw DRAFT 문서의 프로젝트의 목적을 살펴봤습니다. (&lt;a href=&quot;http://openjdk.java.net/projects/jigsaw/goals-reqs/03&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://openjdk.java.net/projects/jigsaw/goals-reqs/03&lt;/a&gt;)&lt;/p&gt;&lt;ul style=&quot;list-style-type: square;&quot;&gt;&lt;li&gt;SE 플랫폼과 JDK를 작은 컴퓨터 디바이스에 보다 쉽게 경량화(scalable down)할 수 있게 한다.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Java SE 플랫폼의 전반적인 구현 부분과 특히&amp;nbsp;JDK 부분의 보안성과 유지관리성(maintainability)을 향상시킨다.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;애플리케이션의 성능을 높일 수 있게 하고&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Java SE 그리고 EE 플랫폼에서 개발자들이 라이브러리와 애플리케이션 구성과 유지를 쉽게 만들어 준다.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;음... 모듈화 잘 해서 위와 같이 한다는데 좋은 소리인데 뭘 어케하겠다는 건지...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h3&gt;뭐가 문제였나?&lt;/h3&gt;&lt;div&gt;기존의 Java 패키징 메커니즘의 문제로 JAR/Classpath hell, 보안, performance 등의 문제도 지적하지만 이 모든 것의&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;원인은 캡슐화 지원이 부족&lt;/span&gt;&lt;/b&gt;한 것 때문이 아닌가 합니다. Java는 public, private과 같은&amp;nbsp;클래스 수준의 가시성 한정자(visibility modifier)가 있습니다. 그러나 이것은 클래스까지만 유효하지 패키지를 넘어서는 힘을 잃어버리게 됩니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;예를 들어 우리는 JAR로 제공된 패키지의 클래스를 보면 어느 클래스를 써야할 지 알 수가 없습니다. 대부분의 클래스가 public이고 접근이 가능합니다. 그 안에는 API 설계자가 내부 구현을 위해 만든 내부용 API도 있을 겁니다. 기존에는 이 내부용 API(public 이라면) 접근이 가능합니다, JAR 로 제공되고 문서화가 잘 되더라도 클래스와 메소드가 public이라면 여러가지 이유로 API 설계자가 의도하지 않은 호출이 발생할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;문제는 API 제공자가 기능 향상이나 리팩토링을 위해 이러한 내부용 API를 바꾸고 싶을 때 입니다. 누가 쓸 지 알 수 없는 상황에서 쉽게 바꿀 수 없는 노릇입니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;b&gt;&lt;u&gt;Java Jigsaw는 어떻게 이 문제를 푸는가?&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;모듈을 만들고 모듈에 명시적으로 외부에서 호출할 수 있는 API를 선언합니다. 언어레벨에서 API 작성자가 외부에 노출한 API외에는 접근할 수가 없습니다.&lt;/div&gt;&lt;div&gt;뿐만 아니라 모듈은 그 모듈에서 사용할 다른 모듈을 선언합니다. JDK는 이 기능(feature)을 통해 모든 내부 API를 캡슐화하여 구성합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;모듈 선언 예) $ cat src/com/mycompany/module-info.java&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0px; padding: 0px; border: none; background-color: rgb(39, 39, 39); border-radius: 4px; width: 393px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;393&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;module&amp;nbsp;com.mycompay&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;com.yourcomapny&amp;nbsp;를&amp;nbsp;사용할&amp;nbsp;거야&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;requires&amp;nbsp;com.yourcompany;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;com.mycompany를&amp;nbsp;사용할&amp;nbsp;수&amp;nbsp;있어&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;exports&amp;nbsp;com.mycompany;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align: bottom; padding: 0px 2px 4px 0px; width: 95px;&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;경험담&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;프로젝트를 하면서 컴포넌트 기반 개발(CBD)을&amp;nbsp;위한 아키텍처를 구성하고 개발을 해 왔습니다. CBD의 일반적인 아키텍처는 컴포넌트의 인터페이스를 정의하고 이 인터페이스의 구현을 제공하는 것입니다. 외부 클라이언트는 이 인터페이스를 통해서만 그 기능을 호출하는 것이죠.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:508px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/245D263B57E8D3D626&quot; filemime=&quot;image/jpeg&quot; filename=&quot;스크린샷 2016-09-26 오후 4.52.28.png&quot; height=&quot;138&quot; width=&quot;508&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left; clear: none; float: none;&quot;&gt;&lt;br /&gt;예를 들어 위의 구성을 가지면 UserService 인터페이스로 이 컴포넌트를 사용해야 합니다. 그런데 누군가 내부 구현을 위한 UserHelper 클래스에 유용한 API가 있어 이것을 사용하게 되었습니다. 말릴 수가 없습니다. 그리고 이 컴포넌트 설계자는 누군가 UserHelper 를 호출 했을지도 모른다는 두려움에 기능 개선을 위해&amp;nbsp;UserHelper 클래스를 변경할 수가 없습니다.&lt;/p&gt;&lt;p&gt;이러한 제약은 아키텍처 문서나 개발자 가이드에 적시하여 규칙으로 관리할 수 밖에 없습니다. 그러나 누군가는 약속되지 않은 API 호출을 하고는 합니다.&lt;br /&gt;Java jigsaw의 모듈화 시스템은 이러한 문제를 깔끔하게 해결합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;지금까지 잘 살고 있는데 왜?&lt;/h3&gt;&lt;div&gt;뭐 설계상의 난점과 그와 관련된 문제도 있지요. 그러나&amp;nbsp;그러지 않아도 Java 는 잘 돌고 있는데 위험(아래에 설명)을 무릅쓰고&amp;nbsp;이와 같은 큰 변화를 시도하는 이유가 뭘까요?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Project Jigsaw의 주요 목표는 한마디로 &lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;유연한 런타임 이미지를 만들 수 있도록 Java 플랫폼을 모듈화&lt;/span&gt;&lt;/b&gt;하는 것입니다. 즉 필요한 모듈만으로&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;경량화된 이미지&lt;/span&gt;&lt;/b&gt;를 만들기 위함입니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;기존에는 JRE 일부분만 배포할 수가 없었습니다. 애플리케이션이 사용하지 않더라도 XML, SQL, Swing 같은 패키지는 항상 같이 배포되었습니다.&lt;/div&gt;&lt;div&gt;언어 레벨에서 모듈간의 의존성을 알 수 있으니 애플리케이션이 사용하는 모듈만 모아서 런타임 환경(이미지)를 만들 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:820px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2604E03E57E924422E&quot; filemime=&quot;image/jpeg&quot; filename=&quot;jdk.png&quot; height=&quot;144&quot; width=&quot;820&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;a href=&quot;https://bugs.openjdk.java.net/secure/attachment/57772/jdk.png&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://bugs.openjdk.java.net/secure/attachment/57772/jdk.png&lt;/a&gt;&lt;/p&gt;&lt;p&gt;JDK의 모듈 구조는 위와 같은 형태로 작게 나뉘어 질 것이며, 표준 API(SE, EE)뿐만 아니라 &amp;nbsp;3rd party 라이브러리 심지어&amp;nbsp;우리가 만든 라이브러리에서도 필요한 것만 골라서 배포할 수 있습니다.&lt;/p&gt;&lt;/div&gt;&lt;div&gt;런타임 이미지가 작아진다는 것은 아래 이야기 하는 것들이 가능하다는 이야기입니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;소형 디바이스&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;서버 사이드야 용량도 크고 성능도 좋아 상관없지만 라우터나 셋톱박스 같은&amp;nbsp;작은 디바이스는 괴롭습니다. 런타임 이미지가 작아지면 소형 디바이스에 여러모로 유리합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;서버 아키텍처&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;서버 쪽은 도커에 의해 애플리케이션이 컨테이너화 되는 추세입니다. 런타임 이미지가 작다면 경량의 도커 이미지가 가능하고 배포하고 관리하기 유리해집니다.&lt;/div&gt;&lt;div&gt;클라우드 컴퓨팅, 마이크로 서비스 등의 아키텍처 트랜드에 맞추기 위해,&amp;nbsp;런타임의 경량화&amp;nbsp;기반을 준비하는 것으로 볼 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;스타트업 시간과 성능&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;현재는 필요한 클래스를 순차적으로 로드하느라 JVM 구동 타임에 시간이 걸립니다. 또한 암시적으로 모든 클래스를 동적으로&amp;nbsp;호출할 수 있는 구조입니다. 모듈화 시스템은 필요한 모듈을 알기에 그것만 로드할 수 있습니다. 또한&amp;nbsp;모듈간의 호출구조가 정의되어 있기에 성능향상을 위한 기회를 얻을 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;JDK, JRE 통합?&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;JRE와 JDK는 사용목적에 따라 다르게 배포하고 있습니다. JDK가 JRE를 포함하여 추가적인 패키지를 더 제공하고 있죠. 모듈화 시스템을 제공하면 이러한 분리가 필요 없고 두 플랫폼은 같은 구조를 가지게 된다고 합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;넘어야 할 산들&lt;/h3&gt;&lt;div&gt;언어 레벨에서 모듈간의 의존관계를 확실히 하면 이처럼 좋은 점이 많습니다. 그러나 넘어야 할 산들이 많습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;레가시 코드는 어쩌나&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Java의 큰 장점 중 하나가 하위 호환성(Backward compatibility)인데, 이거 어떻게 풀지 두고 봐야겠습니다. Java 9에 레가시 코드를 쓸 경우 모듈화 시스템 관련 부분이&amp;nbsp;가장 큰 혼란이지 않을까 합니다.&lt;/div&gt;&lt;div&gt;Java 9을 쓴다면 자신의 코드 중 나도 모르게 내부 API 쓴 부분이 있는지 검사해야 할 듯 합니다. (컴파일러나 다른 도구가 체크하겠지만..)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;com.sun.*&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;com.sun과 같은 비공식적인 API는 되도록 사용하지 말라고 경고했습니다. 그러나 성능 등의 많은 이유 때문에 비공식 API를 사용하고는 합니다.&lt;/div&gt;&lt;div&gt;이런 종류의 API를 쓴 코드는 그 대가를 치를지도 모르겠습니다만. com.sun.* 같이&amp;nbsp;특별한 이유로 흔히 사용했던 API에 대한 고민과 지원이 있을 듯 합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;개발도구들&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;lib/rt.jar나 lib/tool.jar 같은 내부 JAR파일들의 접근이 불가합니다. 이러한 JAR 파일은 IDE나 빌드도구들이 많이 사용하는데 개발도구들이 영향을 많이 받을 듯 합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;이와 같이 람다같은 기능과는 달리 레거시 코드에 상당한 영향을 줄 수가 있습니다. Java 9이 출시 되더라도 바로 Java 9으로 이전 하는 것은 위험요소가 있을 듯 합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;언어 레벨에서의 모듈화 시스템&lt;/h3&gt;&lt;div&gt;언어 레벨에서 모듈화를 지원한다는 것은 도구 레벨에서 불가능한 것들을 가능하게 할 것입니다. 제일 큰 부분은 기본적으로 java runtime 부분을 쪼갤 수 없었던 것을 쪼갤 수 있게 한 것이죠. 이러면 배포시 사용하지 않는 Swing, XML, SQL 같은 패키지는 제외하고 배포할 것입니다.&lt;/div&gt;&lt;div&gt;이런 특징은 여러분의 프로젝트에서도 가능하여 최소한의 런타임 이미지를 배포하여 가볍게 운용할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;지금처럼 굉장히 많은 클래스 집단이 하나의 JAR로 배포되고 관리되는 대신 굉장히 작은 모듈단위로 배포될 것입니다.&lt;/div&gt;&lt;div&gt;모듈의 단위가 작아질 때의 문제점은 모듈간의 의존관리가 어려워지고 매우 복잡해 진다는 것입니다.&lt;/div&gt;&lt;div&gt;잘못하면 cyclic dependency(모듈간 상호 참조)가 빈번히 발생할 가능성도 적지 않습니다. 필요한 API 있다고 마구 호출하지 말고 설계에 신경을 써야 할 것입니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;그래서&lt;/h3&gt;&lt;div&gt;제가 요즘,&amp;nbsp;규칙에 좀&amp;nbsp;관대한 언어를 쓰고 있지만 경우에 따라 Java와 같이 규칙이 엄격한 언어가 유리하기도 합니다.&lt;/div&gt;&lt;div&gt;개인적으로는 규칙이 엄격한 Java 언어에서 무척 반길 만한 내용입니다. 실제 어떻게 적용될 지, 그리고 이 방식의 API 구성이 얼마나 확산될 지 기대됩니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;blockquote class=&quot;tx-quote-tistory&quot;&gt;&lt;div&gt;처음은 Java 클래스의 가시성 정도로 충분하다고 생각 했었지&lt;/div&gt;&lt;div&gt;그러나 프로그램이 커지다 보니 클래스의 묶음도 필요 했지&lt;/div&gt;&lt;div&gt;클래스 묶음&amp;nbsp;단위로 관리하고 싶었는데 클래스들 사이가 좋아 다른 동네의 클래스도 막 호출하는 거야&lt;/div&gt;&lt;div&gt;도대체 어떤 클래스가 어떤 클래스를 호출 하는지 알 수가 없네&lt;/div&gt;&lt;div&gt;안되겠어. 클래스 묶음에서 호출할 수 있는 대표를 정하고 대표 하고만 이야기 하도록 하자&lt;/div&gt;&lt;div&gt;그래 클래스 묶음 단위로 관리하려고 하는 거야.&lt;/div&gt;&lt;div&gt;그걸 모듈이라고 불러...&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;참조:&lt;/p&gt;&lt;ul style=&quot;list-style-type: square;&quot;&gt;&lt;li&gt;http://openjdk.java.net/projects/jigsaw/&lt;/li&gt;&lt;li&gt;http://blog.codefx.org/java/dev/motivation-goals-project-jigsaw/&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
<category>잡다한기록</category>
<category>Java</category>
<category>java9</category>
<category>Jigsaw</category>
<category>모듈</category>
<category>자바</category>
<category>직소</category>
<author>행복한아빠</author>
<guid isPermaLink="true">https://greatkim91.tistory.com/197</guid>
<comments>https://greatkim91.tistory.com/197#entry197comment</comments>
<pubDate>Tue, 27 Sep 2016 00:57:47 +0900</pubDate>
</item>
<item>
<title>(지난 간 이야기) CBD에 관하여</title>
<link>https://greatkim91.tistory.com/198</link>
<description>&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:594px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/237AAA3C57E941C320&quot; filemime=&quot;image/jpeg&quot; filename=&quot;CQKKM6MG4D3ZTUJFDNPB.jpg&quot; height=&quot;360&quot; width=&quot;594&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;오늘은 집에서 소주 한 잔 하고 글을 남겨 봅니다. 이 다음은 그냥 구어체로 이야기합니다. 뭐 내 블로그니까. 크하하~ (술 취했음)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;완벽(?)해지고 싶은 아키텍트&lt;/h3&gt;&lt;p&gt;얼라 빡센 프로젝트에 들어왔지. 200명이 넘는 개발자를 대상으로 아키텍처 가이드 제시해야 해...&lt;br /&gt;그리고 우리는 그 당시(2005년) 최신 기술? 트랜드였던 컴포넌트 기반 설계/개발을 위한 아키텍처를 수립했어.&lt;br /&gt;아주 정교한 그리고 현실적인 아키텍처로 말이야...&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;CBD 전략&lt;/h3&gt;&lt;p&gt;우리의 전략은 이랬지(Java 그리고 j2EE를 기반으로...). 우선 컴포넌트마다 패키지를 정의해. 그리고 그 패키지에 외부에서 접근을 허락한 인터페이스를 정의해. 외부에서 우리가 작성한 컴포넌트는 이 인터페이스로만 호출할 수 있는 거야. 이건 약속이야 아키텍처니까.&lt;/p&gt;&lt;p&gt;우리의 패키지는 인터페이스와 그 구현 그리고 흔히 이야기하는 Value Object, 그 외 각종 로직을 담고 있는 helper 클래스가 존재해. 이건 컴포넌트 내부 구현을 위한 클래스야. 관심 두지마. 그냥 인터페이스만 보고 호출해...&lt;/p&gt;&lt;p&gt;그런데 말이야... Javadoc 주석을 충실히 달기를 바래. 소스코드는 문서화의 마지막 보루야. Javadoc 잘 달아야 다음 개발자가 무리없이 작업할 수 있어. 우리는 프로니까... 소명감을 가지고 충실히 달자.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;뭔가 잘못됨&lt;/h3&gt;&lt;p&gt;우리는 훌륭한 빌드 시스템을 구축하여 빌드 뿐만 아니라 Java API 문서화 시스템도 훌륭히 갖추었지. 이제는 우리가 예측한 데로 결합도는 낮으면서 응집도는 높은 아주 훌륭한 설계를 가진 시스템이 탄생할 거야...&lt;/p&gt;&lt;p&gt;그런데...&lt;/p&gt;&lt;p&gt;예측하지 못한 일이 발생했어. 우리 컴포넌트를 사용하는 개발자들이 우리 인터페이스만 이용하는게 아니야. 우리 컴포넌트 패키지의 모든 클래스를 훑어보고는 괜찮은 API는 죄다 사용하는 거지. 훌륭한 Java document가 문제였던 거지.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;오 마이 갓~. 나는 인터페이스만 사용하기를 바랬어. 급하게 만든 MyCalculator나 MyStringUtil 같은 클래스의 API는 나중에 바꿀라고 했어. 그런데 이걸 누군가 사용했다는 거네. 촌스럽게 지은 클래스 이름과 API 이름.. 이거 어떻게.&lt;/p&gt;&lt;p&gt;우리는 고민했지. 도대체 어떻게 이 일이 번지는 걸 막을 수 있지? 우선 규칙을 정했지. 컴포넌트의 최상위 패키지에 있는 클래스나 인터페이스만 너희들이 쓸 수 있는 물건이라고... 그 아래는 구현과 관련된 내부 클래스나 API이니 관심갖지 말라구.&lt;/p&gt;&lt;p&gt;그러나... 개발자들은 대단해. 괜찮은 API 있으면 어떻게든 찾아서 그냥 써 버려. 이건 우리의 경우만 아니야. 개발자들은 원래 그래. 파고 들고 해결하려는 경향이 있어. 우리는&amp;nbsp;이것을 hack 이라고 하지. 소프트웨어가 발전한 원동력이기도 하지.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:820px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/241E773C57E944B20A&quot; filemime=&quot;image/jpeg&quot; filename=&quot;73b2f-thinkstockphotos-460930919.jpg&quot; height=&quot;568&quot; width=&quot;820&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;물리적으로 제어할 메커니즘이 필요해. 내가 호출 하라고 정의한 것만 호출하게... 더 나아가 내부 문서화를 위한 document 주석은 외부로 내 보내지 않았으면 좋겠어. 그러나... 그런 장치는 없어. 아키텍처 문서나 개발 가이드 잘 작성해서 규칙을 따르자고&amp;nbsp;이야기를 할 수 밖에...&lt;/p&gt;&lt;p&gt;그런데 개발자들이 이 문서는 잘 안 보네.&lt;/p&gt;&lt;p&gt;뭐 완벽한 게 어디있어. Java는 원래 그래. 원칙적으로 그냥 다 열려 있어. 아키텍처 규칙 잘 정하고 잘 통제하는 수 밖에... (잘 안되어서 그렇지)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그렇게 잊고 살았는데.... &lt;a href=&quot;http://greatkim91.tistory.com/197&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;잉 Java Jigsaw 이건 또 뭐야?&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
<category>잡다한기록</category>
<category>CBD</category>
<category>Component</category>
<category>Java</category>
<category>Jigsaw</category>
<author>행복한아빠</author>
<guid isPermaLink="true">https://greatkim91.tistory.com/198</guid>
<comments>https://greatkim91.tistory.com/198#entry198comment</comments>
<pubDate>Tue, 27 Sep 2016 00:36:59 +0900</pubDate>
</item>
<item>
<title>Vi를 좋아하시는 분들을 위하여</title>
<link>https://greatkim91.tistory.com/196</link>
<description>&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:610px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/21279F3857E4D7A818&quot; filemime=&quot;image/jpeg&quot; filename=&quot;vim.png&quot; height=&quot;502&quot; width=&quot;610&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;(출처:&amp;nbsp;&lt;a href=&quot;http://www.redbubble.com/shop/vim+t-shirts&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://www.redbubble.com/shop/vim+t-shirts&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;오랜~만에 개발과 시스템 작업할 일이 있어 주요도구가 파워포인트, 키노트 에서 개발도구들로 바뀌었습니다. 그래서 그동안 내 컴퓨터에 없었던 개발관련 설정 중 기본적인 에디터 관련 설정을 기록해 둡니다. 뭐 매번 찾기도 귀찮으니...&lt;/p&gt;&lt;p&gt;개발도구는 여러 개 있을지라도&amp;nbsp;에디터 관련 설정은 일단 Vim으로 맞춥니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;내가 Vi를 좋아하는 이유&lt;/h3&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;마우스&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;내 책상은 지저분합니다. 나는 노트에 그림을 그리거나 적는 습관이 있어 보통 마우스가 있어야할 오른쪽 자리에 노트가 있습니다. 도대체 마우스 놓을 자리가 없습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:610px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/213DA43A57E4D52B2F&quot; filemime=&quot;image/jpeg&quot; filename=&quot;무제.png&quot; height=&quot;246&quot; width=&quot;610&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;(연출사진 흠흠..)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Vi를 사용하면 마우스로 손이 가는 경우가 현저히 떨어집니다. 그냥 키보드에서 손 뗄 필요가 별로 없습니다. 저 멀리 있는 방향키나 Function 키도 별 쓸일이 없습니다. (운동량이 떨어지니 건강에 좋지 않겠네요 ㅡ.,-;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;에디터(또는 IDE) 변경&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;개발도구 바꿀 때마다 고생을 합니다. 십년넘게 eclipse 쓰다가 IntelliJ 바꾸니 그동안 익숙했던 기능들 버리기도 아깝고 새 환경에 적응하기도 어렵네요. 다른 것보다도 에디팅 기능들은 손에 익었던 것으로 하면 휘리릭~ 인데...&lt;/p&gt;&lt;p&gt;잘 찾아보면 대부분의 유명 도구들은 Vim 플러그인들을 제공합니다. 이것들을 이용하면 에디팅에서는 기존의 생산성과 편리함을 그대로 가지고 갈 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;OS 변경&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;윈도우즈에서 맥으로 본격적으로 옮긴지 1년정도인데 이제는 윈도우가 어색합니다. 그리고 서버를 다룰 때에는 linux 계열을 써야 합니다. 윈도우에는 notepad가, 맥에는 텍스트편집기가, linux에는 nano 정도가 있는데 세 가지 모두 이질적입니다.&lt;/p&gt;&lt;p&gt;그냥 Vim 쓰는게 훨 좋죠. 윈도우를 제외하고는 Vim이야 설치된 경우가 많으니 별 무리없이 사용할 수 있습니다.&lt;/p&gt;&lt;p&gt;(아무 것도 설치되지 않은 윈도우 서버 다룰 때를 위하여 notepad 익힙시다. ㅡ.,ㅡ)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;내 컴퓨터 Vi 관련&amp;nbsp;설정 들&lt;/h3&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;Vim&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Vim을 사용할 때의 기본설정(~/.vimrc)입니다. Python에 맞춘 감이 있네요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;31&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;32&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;33&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;34&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;35&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;36&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&quot;&amp;nbsp;Python&amp;nbsp;파일일&amp;nbsp;경우&amp;nbsp;tab&amp;nbsp;설정,&amp;nbsp;폴딩설정&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;au&amp;nbsp;BufRead,BufNewFile&amp;nbsp;*.py&amp;nbsp;set&amp;nbsp;expandtab&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;au&amp;nbsp;BufRead,BufNewFile&amp;nbsp;*.py&amp;nbsp;setlocal&amp;nbsp;foldmethod=indent&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;expandtab&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;&amp;nbsp;탭을&amp;nbsp;스페이스&amp;nbsp;처리&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;tabstop=4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;&amp;nbsp;탭당&amp;nbsp;4개&amp;nbsp;스페이스&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;softtabstop=4&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;shiftwidth=4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;&amp;nbsp;Auto&amp;nbsp;indent에서&amp;nbsp;스페이스&amp;nbsp;개수&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;autoindent&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;&amp;nbsp;Auto&amp;nbsp;indent&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&quot;&amp;nbsp;백스페이스&amp;nbsp;강화&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;backspace=indent,eol,start&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;ruler&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;&amp;nbsp;show&amp;nbsp;line&amp;nbsp;and&amp;nbsp;column&amp;nbsp;number&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;showcmd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;&amp;nbsp;show&amp;nbsp;(partial)&amp;nbsp;command&amp;nbsp;in&amp;nbsp;status&amp;nbsp;line&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&quot;&amp;nbsp;Syntax&amp;nbsp;Highlighting&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;if&amp;nbsp;has(&quot;syntax&quot;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;syntax&amp;nbsp;on&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;endif&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;nu&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;&amp;nbsp;라이번호&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;hlsearch&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;&amp;nbsp;검색어&amp;nbsp;하이라이팅&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;showmatch&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;&amp;nbsp;일치하는&amp;nbsp;괄호&amp;nbsp;하이라이팅&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&quot;&amp;nbsp;Vim&amp;nbsp;Color&amp;nbsp;schema&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;colorscheme&amp;nbsp;jellybeans&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&quot;&amp;nbsp;마지막&amp;nbsp;편집&amp;nbsp;위치&amp;nbsp;복원&amp;nbsp;기능&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;au&amp;nbsp;BufReadPost&amp;nbsp;*&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;\&amp;nbsp;if&amp;nbsp;line(&quot;'\&quot;&quot;)&amp;nbsp;&amp;gt;&amp;nbsp;0&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;line(&quot;'\&quot;&quot;)&amp;nbsp;&amp;lt;=&amp;nbsp;line(&quot;$&quot;)&amp;nbsp;|&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;\&amp;nbsp;exe&amp;nbsp;&quot;norm&amp;nbsp;g`\&quot;&quot;&amp;nbsp;|&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;\&amp;nbsp;endif&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;laststatus=2&amp;nbsp;&quot;&amp;nbsp;상태바&amp;nbsp;표시를&amp;nbsp;항상한다&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;set&amp;nbsp;statusline=\&amp;nbsp;%&amp;lt;%l:%v\&amp;nbsp;[%P]%=%a\&amp;nbsp;%h%m%r\&amp;nbsp;%F\&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;(참고로 27 라인 colorschema 파일은&amp;nbsp;~/.vim/colors 밑에 넣으시면 됩니다. 저는&amp;nbsp;https://github.com/nanotech/jellybeans.vim 사용합니다.)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;Shell&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Command line 작업할 일이 많은데 command line에서도 vi mode가 훨 사용하기 쉽고 빠릅니다. (~/.bash_profile)&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0px; padding: 0px; border: none; background-color: rgb(39, 39, 39); border-radius: 4px; width: 273px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;273&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding: 6px 0px; width: 76px;&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;set&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;o&amp;nbsp;vi&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align: bottom; padding: 0px 2px 4px 0px; width: 168px;&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;Python Shell&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Python이나 Django 개발하다보면 python shell을 많이 이용하죠. 물론 Django shell에서도 작동합니다.&lt;/p&gt;&lt;p&gt;Mac에서는 ~/.editrc 파일에 아래 부분을 추가합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0px; padding: 0px; border: none; background-color: rgb(39, 39, 39); border-radius: 4px; width: 274px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;274&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding: 6px 0px; width: 60px;&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;bind&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;v&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align: bottom; padding: 0px 2px 4px 0px; width: 185px;&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;iPython Shell&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;ipython은 표준 python shell 보다 더 인터렉티브한 shell입니다.&lt;/p&gt;&lt;p&gt;ipython 5.0 버전이상에서는 ~/.ipython/profile_default 파일(없으면 생성)에 다음을 추가합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;c.TerminalInteractiveShell.editing_mode&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'vi'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그외는&amp;nbsp;&lt;a href=&quot;http://stackoverflow.com/questions/10394302/how-do-i-use-vi-keys-in-ipython-under-nix&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://stackoverflow.com/questions/10394302/how-do-i-use-vi-keys-in-ipython-under-nix&lt;/a&gt; 참조&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;JetBrain IDE (IntelliJ, PyCharm)&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;JetBrain IDE는 플러그인 중 IdeaVim 이 있습니다. Vim emulator이지만&amp;nbsp;쓸만합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;Visual Studio Code&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;역시 플러그인 중 Vim이 있습니다. Vim emulator입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;별 기능 없는 Vi로 뭐 하시게요?&lt;/h3&gt;&lt;p&gt;Vi가 기능이 별로 없다고요? 저도 모르는 기능 엄청 많이 있고 너무 과하게 있습니다. 뭐 자신만의 기능을 위한 스크립팅도 되니 그런 걱정을 할 이유가 없습니다.&lt;/p&gt;&lt;p&gt;그리고 IDE를 버리고 Vi를 쓴다는게 아니라 개발툴에서 쓴다는 이야기이니 개발툴이 지원하는 막강한 리팩토링이나 코드 어시스턴스 기능은 그대로 씁니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;별 것 가지고 유난떠시네...&lt;/h3&gt;&lt;p&gt;그렇지요. 에디터 가지고 유난떨고 있죠. 그렇지만&amp;nbsp;후배들에게는 권유하고는 합니다.&lt;/p&gt;&lt;p&gt;에디터가 좋다고 개발 생산성이 높아지는 것도 아니지요. 그러나 운동선수에게 그들의 운동도구가 가장 중요하듯 항상 사용하는 운동화나 운동복도 중요하겠지요.&lt;/p&gt;&lt;p&gt;뭐 그냥 그렇다는 이야기 입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;웹 에디터도 Vi를 지원했으면 좋겠어요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;yy&lt;/span&gt;&lt;/b&gt; rather than &lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;Ctl&lt;/span&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;-C&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;</description>
<category>잡다한기록</category>
<category>intellij</category>
<category>PyCharm</category>
<category>Python</category>
<category>Shell</category>
<category>VI</category>
<category>VIM</category>
<category>vscode</category>
<author>행복한아빠</author>
<guid isPermaLink="true">https://greatkim91.tistory.com/196</guid>
<comments>https://greatkim91.tistory.com/196#entry196comment</comments>
<pubDate>Mon, 26 Sep 2016 12:06:17 +0900</pubDate>
</item>
<item>
<title>파이썬 Docker 이미지 관리하기</title>
<link>https://greatkim91.tistory.com/195</link>
<description>&lt;p&gt;사실 이 문제&amp;nbsp;때문에 도커 관련 포스트&amp;nbsp;정리하기로 마음 먹었습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;도커로 우리가 만든 파이썬 기반 애플리케이션을 배포하기로 했는데 파이썬 이미지 너무 큽니다. 뭐 파이썬 도커 이미지 중 작은 이미지도 있지만 표준 파이썬&amp;nbsp;이미지에 올리려고 하니 700MB가 넘습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;나의 첫번째 Dockerfile&lt;/h3&gt;&lt;p&gt;&amp;nbsp;&quot;&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;&lt;a href=&quot;http://greatkim91.tistory.com/194&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;Docker로 파이썬 배포 운영하기&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&quot; 하기에서 언급했듯이 우리의 파이썬 애플리케이션 서버는 좀 많은 소프트웨어가 설치됩니다. 다음은 우리의 초기버전&amp;nbsp;Dockerfile입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;FROM&amp;nbsp;python:&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;onbuild&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;MAINTAINER&amp;nbsp;dykim&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;dykim@cityholic.com&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;apt&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;get&amp;nbsp;update&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;apt&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;get&amp;nbsp;install&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;y&amp;nbsp;supervisor&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;ADD&amp;nbsp;.&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;conf&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;supervisord.conf&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;supervisor&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;conf.d&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;supervisord.conf&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Nginx&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;apt&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;get&amp;nbsp;install&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;y&amp;nbsp;nginx&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;ADD&amp;nbsp;.&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;conf&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;web&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;available&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;web&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;ln&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;s&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;available&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;web&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;enabled&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;rm&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;enabled&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;default&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;echo&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;\ndaemon&amp;nbsp;off;&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx.conf&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;chown&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;R&amp;nbsp;www&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;data:www&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;data&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;var&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;uWSGI&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;pip&amp;nbsp;install&amp;nbsp;uwsgi&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;ADD&amp;nbsp;.&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;conf&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello.ini&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;uwsgi&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello.ini&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;CMD&amp;nbsp;[&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;/usr/bin/supervisord&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;EXPOSE&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;80&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;EXPOSE&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;443&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;도커파일을 간단히 라인별로&amp;nbsp;설명하자면&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1 라인:&lt;/p&gt;&lt;p&gt;python:3-onbuild로 이미지를 만듭니다. 이 버전은 빌드 시 자동으로 requirements.txt의 패키지를 설치하고 현재 디렉토리의 모든 소스를 이미지로 복사합니다. (이런 개발을 위해 현재 디렉토리에 만든 venv도 복사하는군...)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;3 ~ 6 라인:&lt;/p&gt;&lt;p&gt;우리는 한 컨테이너에 nginx와 uwsgi 두 개의 프로세스를 띄울 예정이라 supervisord(프로세스 관리)를 설치합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;9 ~ 14 라인:&lt;/p&gt;&lt;p&gt;Nginx 설치와 필요한 설정을 복사합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;17 ~ 18 라인:&lt;/p&gt;&lt;p&gt;uWSGI 설치와 필요한 설정을 복사합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;20 ~ 23 라인:&lt;/p&gt;&lt;p&gt;프로세스를 구동하고 포트를 엽니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Docker 이미지 크기&lt;/h3&gt;&lt;div&gt;이미지 버번관리를 위해 버전 붙인 것 하나과&amp;nbsp;latest 버전를 함께 만듭니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(254, 254, 184); background-color: rgb(254, 254, 184); padding: 10px;&quot;&gt;&lt;div&gt;$ docker build -t 10.3.0.38:5000/hello-web -t 10.3.0.38:5000/hello-web:&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;1&lt;/span&gt;&lt;/b&gt; .&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;이렇게 만들어진 이미지 크기가 700MB가 넘습니다. 첫번째 이미지를 만들고 Repository에 push 합니다.&lt;/div&gt;&lt;div&gt;한참걸립니다. 운영서버에 pull하고 run 합니다. 한참 걸립니다. 첫번째라 이해하지요.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;소스 몇 줄이 변경되어 버전하나 올리고 다시 배포하려고 합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(254, 254, 184); background-color: rgb(254, 254, 184); padding: 10px;&quot;&gt;&lt;div&gt;$ docker build -t 10.3.0.38:5000/hello-web -t 10.3.0.38:5000/hello-web:&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;2&lt;/span&gt;&lt;/b&gt; .&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;아니 이미지에 소스카피하고 소프트웨어 설치하고 ... 저 짓을 또 합니다. 한참 걸립니다. Repository에 push 합니다. 한참걸립니다. 운영서버에 push 합니다. 네... 한참 걸립니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;원인&lt;/h3&gt;&lt;div&gt;매번 저 도커파일로 배포하면 python:3-onbuild 기반 이미지를 제외하고 그 후의 작업들(소프트웨어 설치, 나의 소스파일들)은 새로운 이미지 레이어로 취급합니다. 즉 도커는 새로운 이미지로 판단하기에 Repository에 새로 다 push하고 서버들은 새로 다 pull 합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:610px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2468334057E3A24922&quot; filemime=&quot;image/jpeg&quot; filename=&quot;스크린샷 2016-09-22 오후 6.19.47.png&quot; height=&quot;341&quot; width=&quot;610&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위의 그림에서 보듯 기반 이미지를 제외하고는 이미지 아이디가 다른 새로운 이미지 레이어로 쌓여 두번째 버전은 이미 있는 1번 레이어를 제외한 7~11 버전의 이미지 레이어를 push하거나 pull합니다.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;(좀 간략한 이미지 구조입니다. &quot;docker history 이미지이름&quot;을 이용하면 이미지 레이어 구조를 볼 수 있습니다. 좀 더 자세한 사항은&amp;nbsp;&lt;a href=&quot;https://docs.docker.com/engine/userguide/storagedriver/imagesandcontainers/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;https://docs.docker.com/engine/userguide/storagedriver/imagesandcontainers/&lt;/a&gt;&amp;nbsp;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;해결책&lt;/h3&gt;&lt;div&gt;일반적으로 변경사항은 일부 소스에서 일어납니다. 시스템의 변경사항이 거의 없는 부분과 많이 발생하는 부분으로 나누어 이미지를 관리합니다.&lt;/div&gt;&lt;div&gt;첫번째 빌드는 위와 동일하게 이미지를 만들고 그 이후에는 이미 만들어진 마지막 이미지를 기반으로 변경된 소스 레이어만 추가하는 방법입니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:610px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/25228E3757E3A5B11B&quot; filemime=&quot;image/jpeg&quot; filename=&quot;스크린샷 2016-09-22 오후 6.34.17.png&quot; height=&quot;351&quot; width=&quot;610&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그러면 Repository나 docker 서버들은 마지막 이미지는 이미 있기에 변경된 이미지 레이어만 가지고 와서 이미지를 완성하고 구동합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;우리가 사용할 기반 이미지 도커파일 (Dockerfile)&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;FROM&amp;nbsp;python:&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;MAINTAINER&amp;nbsp;dykim&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;dykim@cityholic.com&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;apt&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;get&amp;nbsp;update&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Application&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;git&amp;nbsp;clone&amp;nbsp;https:&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;username:password@your&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;git&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;host&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;xxx&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;web.git&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;src&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;app&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;pip&amp;nbsp;install&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;r&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;src&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;app&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;requirements.txt&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Nginx&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;apt&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;get&amp;nbsp;install&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;y&amp;nbsp;nginx&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;ADD&amp;nbsp;.&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;conf&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;web&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;available&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;web&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;ln&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;s&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;available&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;web&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;enabled&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;rm&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;enabled&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;default&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;echo&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;\ndaemon&amp;nbsp;off;&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx.conf&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;chown&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;R&amp;nbsp;www&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;data:www&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;data&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;var&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;nginx&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;uWSGI&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;pip&amp;nbsp;install&amp;nbsp;uwsgi&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;ADD&amp;nbsp;.&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;conf&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello.ini&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;uwsgi&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;sites&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello.ini&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Supervisor&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;apt&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;get&amp;nbsp;install&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;y&amp;nbsp;supervisor&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;ADD&amp;nbsp;.&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;conf&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;supervisord.conf&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;supervisor&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;conf.d&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;supervisord.conf&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;CMD&amp;nbsp;[&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;/usr/bin/supervisord&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;EXPOSE&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;80&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;EXPOSE&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;443&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;첫번째 방법과&amp;nbsp;다른 점만 설명한다면&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1 라인:&lt;/p&gt;&lt;p&gt;소스 자동설치 하지 않는 그냥 python docker 이미지를 기반으로 합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;7 ~ 8 라인:&lt;/p&gt;&lt;p&gt;소스를 git에서 가져옵니다. 그리고 필요한 파이썬 패키지도 직접 설치합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;소스만 변경될 때 사용하는 도커파일 (Dockerfile-u)&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;FROM&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;10.&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;3.&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;0.&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;38&lt;/span&gt;:&lt;span style=&quot;color:#c10aff&quot;&gt;5000&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;hello&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;web&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;MAINTAINER&amp;nbsp;dykim&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;dykim@cityholic.com&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;pip&amp;nbsp;install&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;r&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;src&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;app&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;requirements.txt&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;WORKDIR&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;src&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;app&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;RUN&amp;nbsp;git&amp;nbsp;pull&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1 라인:&lt;/p&gt;&lt;p&gt;최종 버전(latest) 이미지를 기반으로 합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;4 ~ 7 라인:&lt;/p&gt;&lt;p&gt;혹 추가된 패키지가 있으면 설치하고 변경된 소스를 pull 받습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;개선 후 이미지 크기&lt;/h3&gt;&lt;p&gt;첫번째 이미지야 기존과 비슷하여 비슷한 빌드, push, pull 시간이 소용됩니다.&lt;/p&gt;&lt;p&gt;그러나 소스만 변경된 경우는 &lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;휘리릭~&lt;/span&gt;&lt;/b&gt; 빌드되고 Repository에 올라가고 서버에 pull 됩니다. 올레~&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;Version 1 --&amp;gt; 좀 걸림&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(254, 254, 184); background-color: rgb(254, 254, 184); padding: 10px;&quot;&gt;&lt;p&gt;$ docker build -t 10.3.0.38:5000/hello-web -t 10.3.0.38:5000/hello-web:&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;1&lt;/span&gt;&lt;/b&gt; .&lt;/p&gt;&lt;p&gt;$ docker push 10.3.0.38:5000/hello-web&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;Version 2 : 소스 업데이트용 도커파일은 이름을 달리 했음 --&amp;gt; 휘리릭~&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(254, 254, 184); background-color: rgb(254, 254, 184); padding: 10px;&quot;&gt;&lt;p&gt;$ docker build -f &lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;Dockerfile-u&lt;/span&gt;&lt;/b&gt; -t 10.3.0.38:5000/hello-web -t 10.3.0.38:5000/hello-web:&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;2&lt;/span&gt;&lt;/b&gt; .&lt;/p&gt;&lt;p&gt;$ docker push 10.3.0.38:5000/hello-web&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;Version 3 -&amp;gt; 휘리릭~&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border-style: solid; border-width: 1px; border-color: rgb(254, 254, 184); background-color: rgb(254, 254, 184); padding: 10px;&quot;&gt;&lt;p&gt;docker build -f &lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;Dockerfile-u&lt;/span&gt;&lt;/b&gt; -t 10.3.0.38:5000/hello-web -t 10.3.0.38:5000/hello-web:&lt;b&gt;&lt;span style=&quot;color: rgb(9, 0, 255);&quot;&gt;3&lt;/span&gt;&lt;/b&gt; .&lt;/p&gt;&lt;p&gt;docker push 10.3.0.38:5000/hello-web&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;...&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;u&gt;실제 이미지 레이어 예)&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:610px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2103483B57E3B4B531&quot; filemime=&quot;image/jpeg&quot; filename=&quot;스크린샷 2016-09-22 오후 7.32.13.png&quot; height=&quot;398&quot; width=&quot;610&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;보는 것과 같이 Version 2, 3는 작은 량의 이미지 레이어만 추가되고 Repository에 push하거나 pull 할 때 이 부분만 전송됩니다.&lt;/p&gt;&lt;p&gt;물론 소스, 패키지외 시스템/소프트웨어 구성에 변경이 생기면&amp;nbsp;기본 이미지 다시 만들어서 하시면 됩니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;삽질 그리고...&lt;/h3&gt;&lt;p&gt;남들 다 쓰는 도커,&amp;nbsp;시작한 지 얼마 안되었는데 이미지 관리하고 구성하려고 하니 구체적으로 어떤 식으로 하는지 자료 찾기가 어렵네요. 그리고 이런 문제에 대한 질문이 Stack Overflow에 간간히 있는데 시원한 답은 못 찾겠고&lt;/p&gt;&lt;p&gt;결국 삽질하고 이렇게 기록해 둡니다.&lt;/p&gt;&lt;p&gt;더 좋은 practice가 있다면 알려주시면 감사하겠습니다~&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;시간 되면 빌드 서버에서 여러 대의 원격&amp;nbsp;도커 컨테이너 죽이고 새로운 이미지 구동하는 파이썬 스크립트 정리해서 공유하겠습니다. (필요한 분 있을려나???)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
<category>Docker</category>
<category>docker</category>
<category>IMAGE</category>
<category>Python</category>
<category>도커</category>
<category>이미지</category>
<category>파이썬</category>
<author>행복한아빠</author>
<guid isPermaLink="true">https://greatkim91.tistory.com/195</guid>
<comments>https://greatkim91.tistory.com/195#entry195comment</comments>
<pubDate>Thu, 22 Sep 2016 19:56:13 +0900</pubDate>
</item>
<item>
<title>Docker로 파이썬 배포 운영하기</title>
<link>https://greatkim91.tistory.com/194</link>
<description>&lt;p&gt;파이썬으로 개발을 하고 보니 운영서버 배포에 대한 고민이 생겼습니다. 물론 Java로 할 경우도 운영서버 구성이 번거롭기는 마찬가지이지만 파이썬을 위한 운영서버는 할 게 더 많네요.&lt;/p&gt;&lt;p&gt;지인의 추천으로 도커를 사용하기로 했습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;운영서버 구성&lt;/h3&gt;&lt;div&gt;우리의&amp;nbsp;운영서버(WAS)는&amp;nbsp;다음과 같은 소프트웨어가 설치 되어야 합니다.&lt;/div&gt;&lt;ul style=&quot;list-style-type: square;&quot;&gt;&lt;li&gt;Python3, PIP&lt;/li&gt;&lt;li&gt;MySQL Lib&lt;/li&gt;&lt;li&gt;파이썬 모듈들...&lt;/li&gt;&lt;li&gt;uWSGI 설치 및 구성&lt;/li&gt;&lt;li&gt;NginX 설치 및 구성&lt;/li&gt;&lt;li&gt;소스 받기 위한 Git&lt;/li&gt;&lt;li&gt;그리고 우리의 애플리케이션&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;이것들 설치 가이드 작성해 보니 꽤 길고 실제 설치하는데 넘 오래 걸립니다. 문제는 WAS를 여러 대 띄울라면 이 재미 없는 작업을 &lt;b&gt;매번!&lt;/b&gt; 해 줘야 하네요.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;간단한 배포/운영&amp;nbsp;방법&lt;/h3&gt;&lt;div&gt;설치 가이드 잘 작성해 놓고 각 서버마다 필요한 소프트웨어 설치하고 Git을 통하여 소스만 pull 하는 방식입니다.&lt;/div&gt;&lt;div&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:610px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2774493F57D7679109&quot; filemime=&quot;image/jpeg&quot; filename=&quot;스크린샷 2016-09-13 오전 11.41.57.png&quot; height=&quot;427&quot; width=&quot;610&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;구성은 쉽지만 앞에 이야기 한 것처럼 &lt;b&gt;서버가 늘어날 때마다 왠 종일 걸리는 설치작업&lt;/b&gt;을 계속 해줘야 합니다. 모듈 추가 같은&amp;nbsp;환경변화라도 있으면 서버마다 또 해야 하고 서버가 동일한 환경을 가지게 유지하기가 쉽지 않을 것 같습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;VM 이미지를 이용?&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;우리는 AWS를 이용합니다. AWS에는 VM의 이미지를 만들고 그 이미지로 인스턴스를 구동하는 방법을 제공합니다.&lt;/div&gt;&lt;div&gt;한 서버에 필요한 소프트웨어와 우리의 애플리케이션을 설치하고 그 이미지를 만들어 인스턴스를 만드는 방법도 가능할 것 같습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:610px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2335A53E57D7695127&quot; filemime=&quot;image/jpeg&quot; filename=&quot;스크린샷 2016-09-13 오전 11.49.31.png&quot; height=&quot;360&quot; width=&quot;610&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;언뜻 보면 훌륭한 방법인 것 같은데 &lt;b&gt;배포할 때마다 저 큰 이미지를 만들고&lt;/b&gt; 인스턴스를 새로 생성한다는 것이 부담입니다.&lt;/p&gt;&lt;p&gt;소스코드 한 줄 바꿨다고 저 짓 하기는 망설여지네요.&lt;/p&gt;&lt;p&gt;그리고 이전 버전의 인스턴스(서버)는 날려야하니 인스턴스 관리도 좀 그렇습니다.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;그리고 배포때마다 이미지가 생겨야 하는데 VM 이미지 용량도 그렇고 엄청난 양의 이미지가 생기겠네요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Docker를 이용한 배포/운영&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;역시 이런 경우 도커를 이용한 방법이 최고입니다.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:610px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2548333357D76B2E17&quot; filemime=&quot;image/jpeg&quot; filename=&quot;스크린샷 2016-09-13 오전 11.57.26.png&quot; height=&quot;349&quot; width=&quot;610&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;ol style=&quot;list-style-type: decimal;&quot;&gt;&lt;li&gt;개발자가 소스를 push 합니다.&lt;/li&gt;&lt;li&gt;빌드서버는 새로운 소스와 환경으로 빌드를 하고 테스트/확인 후 도커 이미지를 빌드합니다.&lt;/li&gt;&lt;li&gt;빌드서버는 도커 이미지를 private docker repositoy에 push 합니다.&lt;/li&gt;&lt;li&gt;빌드서버는 각 운영서버에 새로운 이미지로 다시 가동하라고 합니다.&lt;/li&gt;&lt;li&gt;각 운영서버들은 기존 컨테이너를 지우고 이미지를 다시 받아 새로운 버전을 가동합니다.&lt;/li&gt;&lt;/ol&gt;&lt;ul style=&quot;list-style-type: square;&quot;&gt;&lt;li&gt;소스형상관리: Gitlab&lt;/li&gt;&lt;li&gt;운영서버: CoreOS (도커를 위한&amp;nbsp;경량 OS 정도로 생각하세요)&lt;/li&gt;&lt;li&gt;Private Docker Repository : Docker Repository or Nexus Repository Manager&lt;/li&gt;&lt;li&gt;Build Server : docker-py 모듈로 운영서버 원격 배포 모듈 대충 작성&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;도커로 운영하면 보통&amp;nbsp;이 정도로 관리할 것으로 예상되고 우리 규모에서 이 정도면 충분하다고 판단되어 이렇게 구성합니다만....&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;실제 배포하다보니 또 다른 문제가 발생합니다. 이런 도커 이미지가 너무 커 배포가 넘 느리다는...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;그래서 &quot;&lt;b&gt;&lt;a href=&quot;http://greatkim91.tistory.com/195&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;파이썬 Docker 이미지 관리하기&lt;/a&gt;&lt;/b&gt;&quot; 부분에서 다시 정리합니다.&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
<category>Docker</category>
<category>docker</category>
<category>IMAGE</category>
<category>Python</category>
<category>도커</category>
<category>이미지</category>
<category>파이썬</category>
<author>행복한아빠</author>
<guid isPermaLink="true">https://greatkim91.tistory.com/194</guid>
<comments>https://greatkim91.tistory.com/194#entry194comment</comments>
<pubDate>Thu, 22 Sep 2016 19:54:05 +0900</pubDate>
</item>
<item>
<title>Install kamailio (SIP open source server)</title>
<link>https://greatkim91.tistory.com/187</link>
<description>&lt;p class=&quot;p1&quot; style=&quot;clear: both; float: left;&quot;&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;clear: both; float: left;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:140px;margin-right: 10px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/254A364B57997CE730&quot; filemime=&quot;image/jpeg&quot; filename=&quot;kamailio-logo-2015-140x64.png&quot; height=&quot;64&quot; style=&quot;margin-right: 10px;&quot; width=&quot;140&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot; style=&quot;clear: both; float: left;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;어쩌다가 VoIP에 관심이 생겨 SIP 서버 중 open source 찾아 정리합니다.&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;설치하다 보니 OpenSips와 거의 동일한 것 같아 같은 코드베이스에서 나온 게 아닌가 하는 추측을 합니다.&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Basic infomations&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;p2&quot;&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;/div&gt;&lt;ul class=&quot;ul1&quot;&gt;&lt;li class=&quot;li3&quot;&gt;&lt;span class=&quot;s3&quot;&gt;Homepage: &lt;a href=&quot;https://www.kamailio.org/&quot;&gt;&lt;span class=&quot;s4&quot;&gt;https://www.kamailio.org&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li3&quot;&gt;&lt;span class=&quot;s5&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;Install guide : &lt;a href=&quot;https://www.kamailio.org/wiki/install/stable/debian&quot;&gt;&lt;span class=&quot;s4&quot;&gt;https://www.kamailio.org/wiki/install/stable/debian&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;Version: 4.4&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;OS : Ubuntu 14&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;DB는 MySQL을 사용하는 걸로...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Prerequisite&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;p2&quot;&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;/div&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p5&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;span style=&quot;font-size:10pt;&quot;&gt;&lt;b&gt;&lt;/b&gt;APT로 설치하려고 하기에 apt repository 작업이 선행되어야 합니다.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p5&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p5&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;DEB Packages&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p4&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;First download and add our GPG key to your apt key list:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;prompt &amp;gt; apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xfb40d3e6508ea4c8&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;add to below lines to /etc/apt/sources.list&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;deb http://deb.kamailio.org/kamailio jessie main&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;deb-src http://deb.kamailio.org/kamailio jessie main&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p5&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p5&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;libmysqlclient-dev Package&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;prompt &amp;gt; gpg --keyserver&amp;nbsp; hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;prompt &amp;gt; gpg -a --export CD2EFD2A | apt-key add -&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;prompt &amp;gt; sh -c 'echo &quot;deb http://repo.percona.com/apt precise main&quot; &amp;gt;&amp;gt; /etc/apt/sources.list.d/percona.list'&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Install&lt;/span&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;p2&quot;&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;/div&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;prompt &amp;gt; apt-get update&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;prompt &amp;gt; install mysql-server&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;prompt &amp;gt; apt-get install libmysqlclient-dev&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;prompt &amp;gt; apt-get install kamailio kamailio-mysql-modules&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Configurations&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;p2&quot;&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;/div&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;/etc/kamailio/kamctlrc&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class=&quot;p4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;아래 부분만 수정 or 주석제거&lt;/span&gt;&lt;/p&gt;&lt;ul class=&quot;ul1&quot;&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;SIP_DOMAIN=SIP 주소에서 사용하는 domain. 서버 내부 IP 아님!&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;DBENGINE=MYSQL&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;DBHOST=localhost&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;DBNAME=kamailio&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;DBRWUSER=&quot;kamailio&quot; (계정은 자동으로 생성되어 있음)&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;DBRWPW=&quot;kamailiorw&quot;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;DBROUSER=&quot;kamailioro&quot;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;DBROPW=&quot;kamailioro&quot;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;DBACCESSHOST=localhost&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;DBROOTUSER=&quot;root&quot;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;USERCOL=&quot;username&quot;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p class=&quot;p5&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;/etc/kamailio/kamailio.cfg&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;add below lines at first line&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;#!define WITH_MYSQL&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;#!define WITH_AUTH&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;#!define WITH_USRLOCDB&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;다음 항목 수정&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;listen=udp:&amp;lt;server private ip&amp;gt;:5060 advertise &amp;lt;server public ip&amp;gt;:5060&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;port=5060&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Run&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;p6&quot;&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;/div&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Create DB&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;prompt &amp;gt; kamdbctl create&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Start and Stop&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;prompt &amp;gt; /etc/init.d/kamailio start&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;prompt &amp;gt; /etc/init.d/kamailio stop&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Adding Subscribers&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p5&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p5&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Using kamctl&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p5&quot;&gt;&lt;span style=&quot;font-size:10pt;&quot;&gt;Kamailio 설치후 생기는 관리 명령어입니다.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;prompt &amp;gt; kamctl add userid password&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p5&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p5&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;Using SQL&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;INSERT INTO subscriber (username, domain, password, ha1, ha1b) VALUES&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; ('101', 'test.com', 'test123',&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&amp;nbsp; MD5('101:test.com:test123'), MD5('101@test.com:test.com:test123')&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s1&quot;&gt;);&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;ul class=&quot;ul1&quot;&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;ha1 = md5(username:realm:password)&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;ha1b = md5(username@domain:realm:password)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Open ports&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;





















































&lt;/p&gt;&lt;ul class=&quot;ul1&quot;&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s6&quot;&gt;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;TCP 5060&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;li4&quot;&gt;&lt;span class=&quot;s1&quot;&gt;UDP 5060&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;스택오버플로우에게 감사를...&lt;/p&gt;</description>
<category>잡다한기록</category>
<category>OpenSips</category>
<category>SIP</category>
<category>VoIP</category>
<author>행복한아빠</author>
<guid isPermaLink="true">https://greatkim91.tistory.com/187</guid>
<comments>https://greatkim91.tistory.com/187#entry187comment</comments>
<pubDate>Wed, 07 Sep 2016 10:30:25 +0900</pubDate>
</item>
<item>
<title>Python의 숨은? 특징 2</title>
<link>https://greatkim91.tistory.com/191</link>
<description>&lt;p style=&quot;clear: both; float: left;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:80px;width: 80px; height: 80px; margin-right: 10px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2718F43557C53D7F12&quot; filemime=&quot;image/jpeg&quot; filename=&quot;opengraph-icon-200x200.png&quot; height=&quot;80&quot; style=&quot;width: 80px; height: 80px; margin-right: 10px;&quot; width=&quot;80&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;지난 번에 이어 알아둘 만하거나 재미있는&amp;nbsp;파이썬의 특징을 정리합니다. 지난 번 포스트는 &lt;a href=&quot;http://greatkim91.tistory.com/189&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;여기로&lt;/a&gt;&lt;/p&gt;&lt;p&gt;알아보면 알아볼 수록 재미있고 매력적입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;예외 재발생&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0px; padding: 0px; border: none; border-radius: 4px; width: 281px; background-color: rgb(39, 39, 39);&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;281&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Python&amp;nbsp;2&amp;nbsp;syntax&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;some_operation()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;except&lt;/span&gt;&amp;nbsp;SomeError,&amp;nbsp;e:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;is_fatal(e):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;raise&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;handle_nonfatal(e)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Python&amp;nbsp;3&amp;nbsp;syntax&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;some_operation()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;except&lt;/span&gt;&amp;nbsp;SomeError&amp;nbsp;as&amp;nbsp;e:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;is_fatal(e):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;raise&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;handle_nonfatal(e)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align: bottom; padding: 0px 2px 4px 0px; width: 82px;&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;에러 핸들러 안에서 인자없이 사용한 raise는 원래의 예외를 다시 던지라는 뜻입니다. &quot;미안 난 이 예외를 잡을 수 없어요&quot;라고 말할 수 있게 하죠.&lt;/p&gt;&lt;p&gt;원래의 traceback을 출력, 저장 또는 뭔가 하려면 sys.exc_info()를 사용하여 'traceback' 모듈에서 하는 것처럼 출력할 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;내장객체&amp;nbsp;set 의 연산자 재정의&lt;/h3&gt;&lt;div&gt;다음과 같이 set은 다양한 연산을 지원합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;set([&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;])&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;set([&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;6&lt;/span&gt;])&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Union&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;{&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;6&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Intersection&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;{&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Subset&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;False&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Difference&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;{&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a&amp;nbsp;^&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Symmetric&amp;nbsp;Difference&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;{&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;6&lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;파이썬 2.7 또는 3.0에서는 set을 중괄호로 생성할 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;myset&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;{&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;자세한 내용은 &lt;a href=&quot;https://docs.python.org/3/library/stdtypes.html#set-types-set-frozenset&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;여기&lt;/a&gt;에서&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Negative round&lt;/h3&gt;&lt;div&gt;round() 함수는 주어진 정밀도로 float 수를 반올림합니다. 정밀도는 음수가 될 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;str&lt;/span&gt;(round(&lt;span style=&quot;color:#c10aff&quot;&gt;1234.&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;5678&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;))&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;'1200.0'&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;str&lt;/span&gt;(round(&lt;span style=&quot;color:#c10aff&quot;&gt;1234.&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;5678&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;))&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;'1234.57'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Note) float는 정확한 값을 계산하지 못합니다. 정확한 값을 계산하려면 decimal모듈의&amp;nbsp;Decimal을 사용하세요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;문자열과 boolean 곱셈&lt;/h3&gt;&lt;div&gt;웹개발을 하면서 계속되는 일 중 하나가 HTML 파라메터를 선택적으로 출력하는 일입니다. 다른 언어에서는 다음과 같이 해 왔습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;







&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;'&amp;lt;% isSelected ? &quot;selected&quot; : &quot;&quot; %&amp;gt;'&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s3&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s3&quot;&gt;파이썬에서는 boolean을 곱하여 기대할 수 있는 결과를 얻을 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s3&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s3&quot;&gt;







&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;'&amp;lt;% &quot;selected&quot; * isSelected %&amp;gt;'&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s3&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;boolean을 강제로 곱하면 정수형(False는 0, True는 1)으로 바뀌기 때문인데, 파이썬에서 문자열에 정수 n을 곱하면 정수 n만큼 문자열이 반복됩니다. 다음 코드 실행해 보세요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p&gt;'abc' * 3&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;re는 함수를 호출할 수 있다.&lt;/h3&gt;&lt;p&gt;문자열이 정규식에 매칭될 때마다 함수를 호출하는 기능도 매우 유용하다. 여기에 &quot;Hello&quot;를 &quot;Hi,&quot;로, &quot;there&quot;를 &quot;Fred&quot; 등으로 교체하는 예제를 보자.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;import&lt;/span&gt;&amp;nbsp;re&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;Main(haystack):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;List&amp;nbsp;of&amp;nbsp;from&amp;nbsp;replacements,&amp;nbsp;can&amp;nbsp;be&amp;nbsp;a&amp;nbsp;regex&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;finds&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#ffd500&quot;&gt;'Hello'&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'there'&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'Bob'&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;replaces&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#ffd500&quot;&gt;'Hi,'&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'Fred,'&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'how&amp;nbsp;are&amp;nbsp;you?'&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;ReplaceFunction(matchobj):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;found,&amp;nbsp;rep&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;zip(matchobj.groups(),&amp;nbsp;replaces):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;found&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;None:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;rep&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;log&amp;nbsp;error&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;matchobj.group(&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;named_groups&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;[&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'(%s)'&lt;/span&gt;&amp;nbsp;%&amp;nbsp;find&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;find&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;finds&amp;nbsp;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;ret&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;re.sub(&lt;span style=&quot;color:#ffd500&quot;&gt;'|'&lt;/span&gt;.join(named_groups),&amp;nbsp;ReplaceFunction,&amp;nbsp;haystack)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;ret&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;__name__&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'__main__'&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;str&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'Hello&amp;nbsp;there&amp;nbsp;Bob'&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;Main(&lt;span style=&quot;color:#4be6fa&quot;&gt;str&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;Prints&amp;nbsp;'Hi,&amp;nbsp;Fred,&amp;nbsp;how&amp;nbsp;are&amp;nbsp;you?'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;매칭된 값을 정규식이 아니라 내가 정의한 임의의 함수로 바꿀 수 있습니다. 와우~&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;파이썬 3에서 튜플 unpacking&lt;/h3&gt;&lt;div&gt;파이썬 3에서 함수 선언의 튜플 unpacking과 같은 선택적 아규먼트 구문을 할당문에 사용할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;first,second,&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;rest&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;6&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;7&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;8&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;first&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;second&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;rest&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;[&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;7&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;8&lt;/span&gt;]&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;덜 알려진 기능으로 리스트의 중간에 정해지지&amp;nbsp;않은 개수의 리스트를 할당할 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;first,&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;rest,last&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;6&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;7&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;8&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;first&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;rest&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;[&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;6&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;7&lt;/span&gt;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;last&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;8&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;다중 라인 문자열&lt;/h3&gt;&lt;div&gt;여러 라인의 문자열을 처리하기 위해 한 방법으로 백슬러시를 사용합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;sql&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;select&amp;nbsp;*&amp;nbsp;from&amp;nbsp;some_table&amp;nbsp;\&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;where&amp;nbsp;id&amp;nbsp;&amp;gt;&amp;nbsp;10&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;sql&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;select&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;from&lt;/span&gt;&amp;nbsp;some_table&amp;nbsp;where&amp;nbsp;id&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;10&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;다른 방법으로는 쌍따옴표 3개를 사용하는 방법이 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;sql&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;select&amp;nbsp;*&amp;nbsp;from&amp;nbsp;some_table&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;where&amp;nbsp;id&amp;nbsp;&amp;gt;&amp;nbsp;10&quot;&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;sql&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;select&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;from&lt;/span&gt;&amp;nbsp;some_table&amp;nbsp;where&amp;nbsp;id&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;10&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;위 방법들은 들어쓰기가 안되어 보기 싫은 코드가 되네요. 이 방법으로 들여쓰기 하면 공백이 추가될 것입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;세번째 방법으로 문자열을 나누고 아래와 같이 괄호를 쓰는 방법입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;sql&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;select&amp;nbsp;*&amp;nbsp;from&amp;nbsp;some_table&amp;nbsp;&quot;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;&amp;lt;--&amp;nbsp;no&amp;nbsp;comma,&amp;nbsp;whitespace&amp;nbsp;at&amp;nbsp;end&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;where&amp;nbsp;id&amp;nbsp;&amp;gt;&amp;nbsp;10&amp;nbsp;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;order&amp;nbsp;by&amp;nbsp;name&quot;&lt;/span&gt;)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;sql&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;select&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;from&lt;/span&gt;&amp;nbsp;some_table&amp;nbsp;where&amp;nbsp;id&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;10&lt;/span&gt;&amp;nbsp;order&amp;nbsp;by&amp;nbsp;name&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;여기에서 콤마(,)는 없어야 합니다(튜플이 아닙니다). 이러면 앞뒤로 필요한 공백을 추가할 수 있습니다.&amp;nbsp; 이것은 &quot;my name is %s&quot; % name 과 같은 placeholder에서도 작동합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Interpreter에서 밑줄&lt;/h3&gt;&lt;p&gt;Interpreter에서 밑줄(_)은 최근 출력된 값을 담습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;(a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;xrange(&lt;span style=&quot;color:#c10aff&quot;&gt;10000&lt;/span&gt;))&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;generator&amp;nbsp;object&amp;nbsp;at&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0x81a8fcc&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'blah'&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;_&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;generator&amp;nbsp;object&amp;nbsp;at&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0x81a8fcc&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;편리한 웹브라우저 컨트롤러&lt;/h3&gt;&lt;p&gt;다음과 같이 웹브라우저를 컨트롤할 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;import&lt;/span&gt;&amp;nbsp;webbrowser&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;webbrowser.open_new_tab(&lt;span style=&quot;color:#ffd500&quot;&gt;'http://www.stackoverflow.com'&lt;/span&gt;)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;font face=&quot;BlinkMacSystemFont&quot;&gt;&lt;span style=&quot;font-size: 11px; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;h3&gt;내장된 HTTP 서버&lt;/h3&gt;&lt;div&gt;&lt;p&gt;현재 디렉토리의 파일을 서비스 하려면...&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;







&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;python -m SimpleHTTPServer 8000&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;AtExit&lt;/h3&gt;&lt;p&gt;인터프리터를 종료할 때 호출해야 함수를 등록할 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;exit_handler():&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'bye'&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;import&lt;/span&gt;&amp;nbsp;atexit&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;atexit.register(exit_handler)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;function&amp;nbsp;exit_handler&amp;nbsp;at&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0x106bd2cf8&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;quit()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;bye&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;pow() 함수 세번째 인자&lt;/h3&gt;&lt;p&gt;내장 pow(x, y, z) 함수의 세번째 인자는 x의 y승 값을 z로 나눈 나머지 값을 구하는 역할을 효율적으로 합니다. 즉 (x ** y) % z 와 같은 값을 구합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;x,&amp;nbsp;y,&amp;nbsp;z&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1234567890&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2345678901&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;17&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;pow(x,&amp;nbsp;y,&amp;nbsp;z)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;almost&amp;nbsp;instantaneous&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;6&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div&gt;위의 경우 (x ** y) % z 수식으로 구하면 시간이 오래 걸립니다. pow()로 구하면 바로 결과가 나옵니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;Unzip&lt;/h3&gt;&lt;div&gt;Zip은 동일한 개수의 리스트를 묶어줍니다. 반대로 원래 데이터를 구하기 위해서 다음과 같이 할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;[(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;),&amp;nbsp;(&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;),&amp;nbsp;(&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;6&lt;/span&gt;)]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;zip(&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;a)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;[(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;),&amp;nbsp;(&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;6&lt;/span&gt;)]&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;enumerate에서&amp;nbsp;다른 번호로 index 시작하기&lt;/h3&gt;&lt;div&gt;enumerate를 이용하면 0부터 시작하는 index를 사용할 수 있습니다. 0이 아니라 다른 번호로 index를 시작하려면 두번째 인자를 주어 다음과 같이 할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;my_list&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;[&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;spam&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;ham&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;eggs&quot;&lt;/span&gt;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;list(enumerate(my_list))&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;[(&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;spam&quot;&lt;/span&gt;),&amp;nbsp;(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;ham&quot;&lt;/span&gt;),&amp;nbsp;(&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;eggs&quot;&lt;/span&gt;)]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;list(enumerate(my_list,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;))&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;[(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;spam&quot;&lt;/span&gt;),&amp;nbsp;(&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;ham&quot;&lt;/span&gt;),&amp;nbsp;(&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;eggs&quot;&lt;/span&gt;)]&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;property 클래스&lt;/h3&gt;&lt;div&gt;property 클래스로 여러분의 클래스 인터페이스를 좀 더 엄격히 만들 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;class&lt;/span&gt;&amp;nbsp;C(object):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;__init__(self,&amp;nbsp;foo,&amp;nbsp;bar):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self.foo&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;foo&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;read-write&amp;nbsp;property&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self.bar&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;bar&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;simple&amp;nbsp;attribute&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;_set_foo(self,&amp;nbsp;value):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self._foo&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;value&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;_get_foo(self):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;self._foo&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;_del_foo(self):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;del&lt;/span&gt;&amp;nbsp;self._foo&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;any&amp;nbsp;of&amp;nbsp;fget,&amp;nbsp;fset,&amp;nbsp;fdel&amp;nbsp;and&amp;nbsp;doc&amp;nbsp;are&amp;nbsp;optional,&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;so&amp;nbsp;you&amp;nbsp;can&amp;nbsp;make&amp;nbsp;a&amp;nbsp;write-only&amp;nbsp;and/or&amp;nbsp;delete-only&amp;nbsp;property.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foo&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;property(fget&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;_get_foo,&amp;nbsp;fset&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;_set_foo,&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fdel&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;_del_foo,&amp;nbsp;doc&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'Hello,&amp;nbsp;I&amp;nbsp;am&amp;nbsp;foo!'&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;class&lt;/span&gt;&amp;nbsp;D(C):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;_get_foo(self):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;self._foo&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;_set_foo(self,&amp;nbsp;value):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self._foo&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;value&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foo&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;property(fget&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;_get_foo,&amp;nbsp;fset&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;_set_foo,&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fdel&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;C.foo.fdel,&amp;nbsp;doc&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;C.foo.__doc__)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;파이썬 2.6 이상이나 3.0이상에서는 다음과 같이 사용할 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;class&lt;/span&gt;&amp;nbsp;C(object):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;__init__(self,&amp;nbsp;foo,&amp;nbsp;bar):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self.foo&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;foo&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;read-write&amp;nbsp;property&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self.bar&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;bar&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;simple&amp;nbsp;attribute&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@property&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;foo(self):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;''&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;'Hello,&amp;nbsp;I&amp;nbsp;am&amp;nbsp;foo!'&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;''&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;self._foo&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@foo.setter&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;foo(self,&amp;nbsp;value):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self._foo&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;value&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@foo.deleter&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;foo(self):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;del&lt;/span&gt;&amp;nbsp;self._foo&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;class&lt;/span&gt;&amp;nbsp;D(C):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@C.foo.getter&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;foo(self):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;self._foo&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@foo.setter&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;foo(self,&amp;nbsp;value):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self._foo&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;value&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;내장된 코덱 base64, zlib, rot13&lt;/h3&gt;&lt;div&gt;String은 encode와 decode 메소드를 가지고 있습니다. 보통 u = s.encode('utf8')과 같이 문자코드 변환하는데 사용되지만 여기에 유용한 내장 코덱이 있습니다. import 없이 zlib으로&amp;nbsp;압축, 압축풀기도 할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;s&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'a'&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;100&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;s.encode(&lt;span style=&quot;color:#ffd500&quot;&gt;'zlib'&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;'x\x9cKL\xa4=\x00\x00zG%\xe5'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;유사하게 base64 인코딩, 디코딩도 할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'Hello&amp;nbsp;world'&lt;/span&gt;.encode(&lt;span style=&quot;color:#ffd500&quot;&gt;'base64'&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;'SGVsbG8gd29ybGQ=\n'&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'SGVsbG8gd29ybGQ=\n'&lt;/span&gt;.decode(&lt;span style=&quot;color:#ffd500&quot;&gt;'base64'&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;'Hello&amp;nbsp;world'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;물론 rot13 인코딩, 디코딩도 가능합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'Secret&amp;nbsp;message'&lt;/span&gt;.encode(&lt;span style=&quot;color:#ffd500&quot;&gt;'rot13'&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;'Frperg&amp;nbsp;zrffntr'&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;후~ 뭐 계속 있기는 한데 여기까지만...&lt;/p&gt;&lt;p&gt;재미있는 것은 이런 것들이 유용한가 유용하지 않을가를 떠나서 하나 하나 정확히 알아보면 파이썬에 대한 이해가 깊어지는 것 같습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;뭐 그렇다는...&lt;/p&gt;</description>
<category>Python</category>
<author>행복한아빠</author>
<guid isPermaLink="true">https://greatkim91.tistory.com/191</guid>
<comments>https://greatkim91.tistory.com/191#entry191comment</comments>
<pubDate>Tue, 30 Aug 2016 14:29:34 +0900</pubDate>
</item>
<item>
<title>Python의 숨은? 특징 (어머 이건 사야 돼)</title>
<link>https://greatkim91.tistory.com/189</link>
<description>&lt;h2&gt;어머 이건 사야 돼&lt;/h2&gt;&lt;p&gt;&lt;/p&gt;&lt;hr&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;clear: both; float: left;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:80px;width: 80px; height: 80px; margin-right: 10px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2303C84057C50A2A0A&quot; filemime=&quot;image/jpeg&quot; filename=&quot;opengraph-icon-200x200.png&quot; height=&quot;80&quot; style=&quot;width: 80px; height: 80px; margin-right: 10px;&quot; width=&quot;80&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;스택오버플로우에 덜 알려진 python의 유용한 특징을 여러 사람이 소개한 글이 있어 기록합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Python 이라는 백화점에서&amp;nbsp;쇼핑하다가 특이하고 멋진 물건들만 모아 놓은 느낌입니다.&lt;/p&gt;&lt;p&gt;몇가지는 별 필요 없지만 대부분 상당히 유용하다는 생각이 들어 맘에 드는 것만 정리해 놓습니다.&lt;/p&gt;&lt;p&gt;(&lt;a href=&quot;http://stackoverflow.com/questions/101268/hidden-features-of-python&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://stackoverflow.com/questions/101268/hidden-features-of-python&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Argument Unpacking&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;리스트나 딕션너리 값을 * 또는 **을 이용하여 함수 아규먼트에 자동으로 풀어주는 기능입니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;draw_point(x,&amp;nbsp;y):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;do&amp;nbsp;some&amp;nbsp;magic&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;point_foo&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;point_bar&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;{&lt;span style=&quot;color:#ffd500&quot;&gt;'y'&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'x'&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;draw_point(&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;point_foo)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;draw_point(&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;point_bar)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;매우 유용한 shortcut 이라 자주 사용할 거라는 예감&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Chaining Comparison Operators&lt;/h3&gt;&lt;div&gt;많이 아는 기능일 겁니다.&amp;nbsp;if x &amp;gt; 0 and x &amp;lt; 10: &amp;nbsp;이런 식의 장황한 식을 if 0 &amp;lt; x &amp;lt; 10: 이런 식으로 간결하게 해 줍니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0px; padding: 0px; border: none; border-radius: 4px; width: 219px; background-color: rgb(39, 39, 39);&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;219&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;10&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;True&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;20&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;False&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;x&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;100&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;True&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;9&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;True&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;True&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align: bottom; padding: 0px 2px 4px 0px; width: 13px;&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Decorators&lt;/h3&gt;&lt;div&gt;함수나 메소드를 감싸 원본 함수나 메소드에 추가적인 기능을 제공하는 기능입니다. Django 같은 프레임워크를 사용하다보면 자주 사용합니다. 데코레이터가 작동하는 방식은 단순하며 자신의 데코레이터도 쉽게 만들 수 있습니다.&lt;/div&gt;&lt;div&gt;AOP(Aspect Oriented Programming)에 많이 적용합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;print_args(function):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;wrapper(&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;args,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;kwargs):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'Arguments:'&lt;/span&gt;,&amp;nbsp;args,&amp;nbsp;kwargs&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;function(&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;args,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;kwargs)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;wrapper&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;@print_args&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;write(text):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;text&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;write(&lt;span style=&quot;color:#ffd500&quot;&gt;'foo'&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;Arguments:&amp;nbsp;(&lt;span style=&quot;color:#ffd500&quot;&gt;'foo'&lt;/span&gt;,)&amp;nbsp;{}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;foo&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;@print_agrs로 시작하는 7,8 라인은 사실 다음과 같습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin: 0px; padding: 0px; border: none; border-radius: 4px; width: 368px; background-color: rgb(39, 39, 39);&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;368&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;write(text):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;text&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;write&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;print_args(write)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align: bottom; padding: 0px 2px 4px 0px; width: 155px;&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;보통 데코레이터는 함수보다 클래스로 많이 구현합니다. 데코레이터에 대해 간략히 잘 소개된 페이지는 다음을 참조하세요. (http://agiliq.com/blog/2009/06/understanding-decorators/)&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Be careful with mutable default arguments&lt;/h3&gt;&lt;p&gt;아주 중요한 부분인데 아래 예제와 같이 기본 아규먼트 값 사용에 주의하라는 내용입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;foo(x&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;[]):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x.append(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;x&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;foo()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;[&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;foo()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;[&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;foo()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;[&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;의도치 않게 함수 호출할 때마다 기본값이 변경됩니다. 기본적으로 아규먼트로 전달되는 값은 변경하지 않는 것이 좋은 API 작성방법입니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Descriptors&lt;/h3&gt;&lt;div&gt;점(.)으로 객체의 멤버를 x.y와 같이 접근할 때, 파이썬은 먼저 인스턴스 딕션너리(__dict__)에서 멤버를 찾습니다. 없을 경우 클래스 딕션너리에서 찾습니다. 클래스에서 멤버를 찾고 객체가 descriptor 프로토콜을 구현했다면 이런 경우 멤버를 바로 리턴하지 않고 descriptor 메소드(__get__, __set__, __delete__)를 호출합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;아래는 descriptor를 이용하여 read-only 프로퍼티를 구현한 예입니다.&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;class&lt;/span&gt;&amp;nbsp;Property(object):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;__init__(self,&amp;nbsp;fget):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self.fget&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;fget&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;__get__(self,&amp;nbsp;obj,&amp;nbsp;type):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;obj&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;is&lt;/span&gt;&amp;nbsp;None:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;self&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;self.fget(obj)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Descriptor에 대한 상세한 내용은&amp;nbsp;&lt;a href=&quot;http://users.rcn.com/python/download/Descriptor.htm&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://users.rcn.com/python/download/Descriptor.htm&lt;/a&gt; 에서 찾아보면 됩니다.&lt;/p&gt;&lt;p&gt;파이썬 언어에서 Java의 private 같은 접근제어가 없다는 점에서 이 기능은 유용합니다. 또한&amp;nbsp;점(.) 접근을 제어함으로써 고급기능들을 간단하게 사용할 수 있는 유용한 방법으로 다소 이해가 어렵더라도 알아두면 유용합니다. python에서 기본으로 제공하는 property descriptor를 알아보세요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Dictionary default .get value&lt;/h3&gt;&lt;div&gt;딕션너리는 보통 d['k']와 같은 형식으로 다루는데 이 경우 딕션너리에 'k' 키가 없을 경우 에러가 발생합니다. 'k'키가 없을 경우 None을 받고 싶을 경우 예외처리하거나 다음과 같이 접근합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;y&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#ffd500&quot;&gt;'k'&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'k'&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;d.keys()&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;None&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;딕션너리에 get() 메소드를 사용하면 일이 쉬워집니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;y&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;d.get(&lt;span style=&quot;color:#ffd500&quot;&gt;'k'&lt;/span&gt;,&amp;nbsp;None)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Docstring Tests&lt;/h3&gt;&lt;div&gt;Python의 documentation을 읽어 테스트로 활용하는 방법입니다. 예제 보는게 이해가 빠를 겁니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;31&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;32&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;33&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;34&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;35&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;36&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;factorial(n):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;Return&amp;nbsp;the&amp;nbsp;factorial&amp;nbsp;of&amp;nbsp;n,&amp;nbsp;an&amp;nbsp;exact&amp;nbsp;integer&amp;nbsp;&amp;gt;=&amp;nbsp;0.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&amp;nbsp;the&amp;nbsp;result&amp;nbsp;is&amp;nbsp;small&amp;nbsp;enough&amp;nbsp;to&amp;nbsp;fit&amp;nbsp;in&amp;nbsp;an&amp;nbsp;int,&amp;nbsp;return&amp;nbsp;an&amp;nbsp;int.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&amp;nbsp;return&amp;nbsp;a&amp;nbsp;long.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;[factorial(n)&amp;nbsp;for&amp;nbsp;n&amp;nbsp;in&amp;nbsp;range(6)]&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[1,&amp;nbsp;1,&amp;nbsp;2,&amp;nbsp;6,&amp;nbsp;24,&amp;nbsp;120]&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;factorial(-1)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Traceback&amp;nbsp;(most&amp;nbsp;recent&amp;nbsp;call&amp;nbsp;last):&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ValueError:&amp;nbsp;n&amp;nbsp;must&amp;nbsp;be&amp;nbsp;&amp;gt;=&amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Factorials&amp;nbsp;of&amp;nbsp;floats&amp;nbsp;are&amp;nbsp;OK,&amp;nbsp;but&amp;nbsp;the&amp;nbsp;float&amp;nbsp;must&amp;nbsp;be&amp;nbsp;an&amp;nbsp;exact&amp;nbsp;integer:&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;import&lt;/span&gt;&amp;nbsp;math&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;not&lt;/span&gt;&amp;nbsp;n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;raise&lt;/span&gt;&amp;nbsp;ValueError(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;n&amp;nbsp;must&amp;nbsp;be&amp;nbsp;&amp;gt;=&amp;nbsp;0&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;math.floor(n)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;n:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;raise&lt;/span&gt;&amp;nbsp;ValueError(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;n&amp;nbsp;must&amp;nbsp;be&amp;nbsp;exact&amp;nbsp;integer&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;n&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;n:&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;catch&amp;nbsp;a&amp;nbsp;value&amp;nbsp;like&amp;nbsp;1e300&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;raise&lt;/span&gt;&amp;nbsp;OverflowError(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;n&amp;nbsp;too&amp;nbsp;large&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;factor&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;factor&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;n:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;factor&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;factor&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;result&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;_test():&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;import&lt;/span&gt;&amp;nbsp;doctest&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;doctest.testmod()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;__name__&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;__main__&quot;&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_test()&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;문서 주석에서 &amp;gt;&amp;gt;&amp;gt; 부분(7행)을 읽고 실행하여 그 아래내용과 실행한 출력과 비교하는 테스트를 수행합니다. 출력과 문자열 비교를 함으로 띄어쓰기가 하나라도 다르면 테스트 실패 합니다.&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;재미있는 기능이긴 한데 주로 단위테스트 프레임워크를 사용하므로 패쓰...&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Ellipsis Slicing Syntax&lt;/h3&gt;&lt;div&gt;파이썬은 잘 알려져 있지 않는 ellipsis 라는 slicing 연산자를 제공합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;class&lt;/span&gt;&amp;nbsp;C(object):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;__getitem__(self,&amp;nbsp;item):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;item&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;C()[&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;:&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&amp;nbsp;...,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;(slice(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&amp;nbsp;None),&amp;nbsp;Ellipsis,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;위와 같이 slice할 때 쩜쩜쩜(...) 연산자를 제공하며 Ellipsis라는 타입으로 나타납니다. 대괄호 [ ] 연산을 통해 직접 slice를 하는 클래스 만들때 쩜쩜쩜 문법도 쓸 수 있다는... 얼마나 쓸 지는 모르겠네요.&lt;/p&gt;&lt;p&gt;더 자세히 알고 싶을 경우 -&amp;gt;&amp;nbsp;&lt;a href=&quot;http://stackoverflow.com/questions/118370/how-do-you-use-the-ellipsis-slicing-syntax-in-python&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;http://stackoverflow.com/questions/118370/how-do-you-use-the-ellipsis-slicing-syntax-in-python&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Enumeration&lt;/h3&gt;&lt;div&gt;for 문에 index가 필요할 때 iterable 객체를 enumerate로 감싼(wrap)다. 그러면 루프 돌면서 index를 돌려줍니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;[&lt;span style=&quot;color:#ffd500&quot;&gt;'a'&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'b'&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'c'&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'d'&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'e'&lt;/span&gt;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;index,&amp;nbsp;item&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;enumerate(a):&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;index,&amp;nbsp;item&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;&amp;nbsp;a&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&amp;nbsp;b&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;&amp;nbsp;c&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;&amp;nbsp;d&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;&amp;nbsp;e&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;많이 쓰는 것이라 숨은(?) feature라 하긴 뭐합니다.&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;For/else&lt;/h3&gt;
&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;foo:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;i&amp;nbsp;was&amp;nbsp;never&amp;nbsp;0&quot;&lt;/span&gt;)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;else 블럭은 break가 호출되지 않을 경우 루프의 맨 나중에 실행됩니다.&lt;/div&gt;&lt;p&gt;위 코드는 아래와 같이 작동합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;found&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;False&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;foo:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;found&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;True&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;not&lt;/span&gt;&amp;nbsp;found:&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;i&amp;nbsp;was&amp;nbsp;never&amp;nbsp;0&quot;&lt;/span&gt;)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;for else 구문은 마치 for가 돌지 않았을 때 else 구문을 실행하라는 뜻 같아서 (오히려 반대인데) 쓰지 말아야 할 구문으로 이야기하기도 합니다. 되도록 사용하지 마세요.&lt;/p&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;Function as iter() argument&lt;/h3&gt;&lt;div&gt;iter()에 함수나 lambda같은 callable 아규먼트를 넘길 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;seek_next_line(f):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;c&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;iter(lambda:&amp;nbsp;f.read(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;),&lt;span style=&quot;color:#ffd500&quot;&gt;'\n'&lt;/span&gt;):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;pass&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;iter(callable, until_value) 함수는 until_value를 만날때 까지 반복적으로 callable을 호출하여 루프를 돌립니다.&lt;/div&gt;&lt;p&gt;즉 위 코드는 '\n'를 만날 때까지 file 포인터를 옮깁니다. 즉 다음 라인으로 이동&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Generator expressions&lt;/h3&gt;&lt;div&gt;다음과 같은 코드를 작성했다면&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;x&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;foo&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;bar(n))&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;p&gt;&lt;span style=&quot;color: white; font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;cs&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;x에 generator를 할당한 것을 얻을 수 있고, 다음과 같이 루프를 돌릴 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;x:&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;이것의 장점은 다음과 같이 했을 경우 발생되는 중간 저장소가 필요 없다는 것입니다. 다음과 같이 하면 x에 list 값이 메모리에 할당 되겠지요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;x&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;[n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;foo&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;bar(n)]&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;경우에 따라 generator를 사용하면 눈에 띄게 성능이 올라갑니다.&lt;/div&gt;&lt;p&gt;보통 중첩되는 for 루프가 들어가는 generator 끝에 if 문을 여러 개 넣을 수 있습니다.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;((a,b)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;6&lt;/span&gt;))&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;n:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;import this&lt;/h3&gt;&lt;div&gt;그냥&amp;nbsp;&lt;span class=&quot;s1&quot;&gt;&lt;b&gt;import&lt;/b&gt;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&lt;b&gt; this&lt;/b&gt; 해 보세요. 뭔가 하고 싶은 말이 있나봅니다.&lt;/span&gt;&lt;/div&gt;







&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;In Place Value Swapping&lt;/h3&gt;&lt;div&gt;튜플을 이용하여 다음과 같이 값을 swap하는 코드를 작성할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;10&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a,&amp;nbsp;b&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;10&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a,&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;b,&amp;nbsp;a&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a,&amp;nbsp;b&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;10&lt;/span&gt;)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;p&gt;&lt;span style=&quot;color: white; font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;cs&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;할당문 오른쪽에서&amp;nbsp;새로운 튜플(b, a)를 생성하여 왼쪽 튜플을 unpack해서 각 변수에 할당합니다. 직관적이네요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;List stepping&lt;/h3&gt;&lt;div&gt;slice 연산자에서 step 아규먼트를 넣을 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;[&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a[::&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;]&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;iterate&amp;nbsp;over&amp;nbsp;the&amp;nbsp;whole&amp;nbsp;list&amp;nbsp;in&amp;nbsp;2-increments&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;[&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;]&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;거꾸로 돌리기 위해 다음과 같이 특별한 표현도 사용합니다.&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a[::&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;[&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;p&gt;&lt;span style=&quot;color: white; font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;cs&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;__missing__ items&lt;/h3&gt;&lt;div&gt;파이썬 2.5 부터 디션너리에 __missing__ 메소드를 제공하는데 이것은 아이템이 없을 경우 호출됩니다. 아래 경우 키에 대한 아이템이 없을 경우 빈 list를 주네요.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;class&lt;/span&gt;&amp;nbsp;MyDict(dict):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;__missing__(self,&amp;nbsp;key):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;self[key]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;rv&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;[]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;rv&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;m&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;MyDict()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;m[&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;foo&quot;&lt;/span&gt;].append(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;m[&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;foo&quot;&lt;/span&gt;].append(&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;dict(m)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;{&lt;span style=&quot;color:#ffd500&quot;&gt;'foo'&lt;/span&gt;:&amp;nbsp;[&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;]}&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;collections 패키지에 dict을 상속하는 defaultdict 클래스가 있는데 위와 동일한 일을 할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;from&lt;/span&gt;&amp;nbsp;collections&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;import&lt;/span&gt;&amp;nbsp;defaultdict&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;m&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;defaultdict(list)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;m[&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;foo&quot;&lt;/span&gt;].append(&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;m[&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;foo&quot;&lt;/span&gt;].append(&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;dict(m)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;{&lt;span style=&quot;color:#ffd500&quot;&gt;'foo'&lt;/span&gt;:&amp;nbsp;[&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;]}&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;특별한 경우가 아니면 dict을 쓰시기 바랍니다. 대부분 함수들은 dict에 키가 없을 경우 KeyErrors를 잡고 key가 없을 경우에 대한 특별한 처리를 하는 것이 보통입니다.&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Multi-line Regex&lt;/h3&gt;&lt;div&gt;파이썬에서 정규식을 여러 줄로 나눌 수 있으며&amp;nbsp;주석도 넣을 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;pattern&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;...&amp;nbsp;^&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;beginning&amp;nbsp;of&amp;nbsp;string&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;...&amp;nbsp;M{0,4}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;thousands&amp;nbsp;-&amp;nbsp;0&amp;nbsp;to&amp;nbsp;4&amp;nbsp;M's&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;...&amp;nbsp;(CM|CD|D?C{0,3})&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;hundreds&amp;nbsp;-&amp;nbsp;900&amp;nbsp;(CM),&amp;nbsp;400&amp;nbsp;(CD),&amp;nbsp;0-300&amp;nbsp;(0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;C's),&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;or&amp;nbsp;500-800&amp;nbsp;(D,&amp;nbsp;followed&amp;nbsp;by&amp;nbsp;0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;C's)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;...&amp;nbsp;(XC|XL|L?X{0,3})&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;tens&amp;nbsp;-&amp;nbsp;90&amp;nbsp;(XC),&amp;nbsp;40&amp;nbsp;(XL),&amp;nbsp;0-30&amp;nbsp;(0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;X's),&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;or&amp;nbsp;50-80&amp;nbsp;(L,&amp;nbsp;followed&amp;nbsp;by&amp;nbsp;0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;X's)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;...&amp;nbsp;(IX|IV|V?I{0,3})&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;ones&amp;nbsp;-&amp;nbsp;9&amp;nbsp;(IX),&amp;nbsp;4&amp;nbsp;(IV),&amp;nbsp;0-3&amp;nbsp;(0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;I's),&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;or&amp;nbsp;5-8&amp;nbsp;(V,&amp;nbsp;followed&amp;nbsp;by&amp;nbsp;0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;I's)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;...&amp;nbsp;$&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;end&amp;nbsp;of&amp;nbsp;string&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;...&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;re.search(pattern,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'M'&lt;/span&gt;,&amp;nbsp;re.VERBOSE)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;다음과 같은 문자열 연결 방법으로 re.VERVOBSE 옵션 없이 정규식을 여러 줄로 쓸 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;pattern&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;^&quot;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;beginning&amp;nbsp;of&amp;nbsp;string&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;M{0,4}&quot;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;thousands&amp;nbsp;-&amp;nbsp;0&amp;nbsp;to&amp;nbsp;4&amp;nbsp;M's&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;(CM|CD|D?C{0,3})&quot;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;hundreds&amp;nbsp;-&amp;nbsp;900&amp;nbsp;(CM),&amp;nbsp;400&amp;nbsp;(CD),&amp;nbsp;0-300&amp;nbsp;(0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;C's),&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;or&amp;nbsp;500-800&amp;nbsp;(D,&amp;nbsp;followed&amp;nbsp;by&amp;nbsp;0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;C's)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;(XC|XL|L?X{0,3})&quot;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;tens&amp;nbsp;-&amp;nbsp;90&amp;nbsp;(XC),&amp;nbsp;40&amp;nbsp;(XL),&amp;nbsp;0-30&amp;nbsp;(0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;X's),&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;or&amp;nbsp;50-80&amp;nbsp;(L,&amp;nbsp;followed&amp;nbsp;by&amp;nbsp;0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;X's)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;(IX|IV|V?I{0,3})&quot;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;ones&amp;nbsp;-&amp;nbsp;9&amp;nbsp;(IX),&amp;nbsp;4&amp;nbsp;(IV),&amp;nbsp;0-3&amp;nbsp;(0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;I's),&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;or&amp;nbsp;5-8&amp;nbsp;(V,&amp;nbsp;followed&amp;nbsp;by&amp;nbsp;0&amp;nbsp;to&amp;nbsp;3&amp;nbsp;I's)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;$&quot;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;end&amp;nbsp;of&amp;nbsp;string&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;pattern&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;re.search(pattern,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'M'&lt;/span&gt;,&amp;nbsp;re.VERBOSE)&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Named string formatting&lt;/h3&gt;&lt;div&gt;% 포맷팅을 디션너리를 받습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;The&amp;nbsp;%(foo)s&amp;nbsp;is&amp;nbsp;%(bar)i.&quot;&lt;/span&gt;&amp;nbsp;%&amp;nbsp;{&lt;span style=&quot;color:#ffd500&quot;&gt;'foo'&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'answer'&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'bar'&lt;/span&gt;:&lt;span style=&quot;color:#c10aff&quot;&gt;42&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;The&amp;nbsp;answer&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;is&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;42.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;foo,&amp;nbsp;bar&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'question'&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;123&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;The&amp;nbsp;%(foo)s&amp;nbsp;is&amp;nbsp;%(bar)i.&quot;&lt;/span&gt;&amp;nbsp;%&amp;nbsp;locals()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;The&amp;nbsp;question&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;is&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;123.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;locals() 역시 dict입니다. 로컬 변수를 이걸 이용해서 간단히 넘깁니다. (개인적으로 추천하고 싶지 않음)&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;아래 새로운 포맷팅 방법이 더 낫겠네요.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;The&amp;nbsp;{foo}&amp;nbsp;is&amp;nbsp;{bar}&quot;&lt;/span&gt;.&lt;span style=&quot;color:#4be6fa&quot;&gt;format&lt;/span&gt;(foo&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;'answer'&lt;/span&gt;,&amp;nbsp;bar&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;42&lt;/span&gt;))&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;Nested list/generator comprehensions&lt;/h3&gt;&lt;div&gt;중첩된 리스트나 generator 포함된 표현식을 다음과 같이 쓸 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;[(i,j)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;range&lt;/span&gt;(i)&amp;nbsp;]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;((i,j)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;4&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;range&lt;/span&gt;(i)&amp;nbsp;)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;1행의 내용을 중첩된 for 문으로 작성하려면 다음과 같이 해야 합니다.&lt;/div&gt;&lt;p&gt;이 기능은 지저분한 중첩 루프 코드를 간단히 바꿀 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;l&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;[]&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;range&lt;/span&gt;(&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;range&lt;/span&gt;(i):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;l.append((i,&amp;nbsp;j))&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;New types at runtime&lt;/h3&gt;&lt;div&gt;동적으로 새로운 타입을 생성할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;NewType&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;type(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;NewType&quot;&lt;/span&gt;,&amp;nbsp;(object,),&amp;nbsp;{&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;x&quot;&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;hello&quot;&lt;/span&gt;})&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;NewType()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;n.x&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;hello&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;이 코드는 아래와 완전히 같습니다.&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;class&lt;/span&gt;&amp;nbsp;NewType(object):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;hello&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;NewType()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;n.x&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;hello&quot;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;뭐 얼마나 유용한지는 모르겠지만 알아둬서 손해는 없겠죠.&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;.pth files&lt;/h3&gt;&lt;div&gt;파이썬 모듈(특히 3rd party 것)을 추가하기 위해서 대부분 사람들은 PYTHONPATH 환경변수를 사용하거나 site-packages 디렉토리에 심볼릭링크나 디렉토리를 추가하는 것 같습니다. 다른 방법으로는 *.pth 파을을 사용하는 것입니다. 여기 공식 파이썬 문서의 설명이 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p&gt;파이썬의 검색 패쓰를 수정하기 위한 가장 편한 방법은 기존 파이썬 패쓰 디렉토리에 패쓰 설정파일을 추가하는 것입니다. 보통 ../site-packages/ 디렉토리겠지요. 패쓰 설정파일은 .pth 확장자를 가지며 각 줄은 sys.path에 추가할 단일 패쓰를 갖습니다. (새 패쓰가 sys.path에 추가되기 때문에 추가되는 디렉토리는 표준 모듈을 재정의하지 않습니다. 이는 표준 모듈 버전의 수정된(fixed) 버전을 설치하기 위해 이 메커니즘을 사용할 수 없다는 뜻입니다.)&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;ROT13 Encoding&lt;/h3&gt;&lt;div&gt;ROT13 인코딩은 영문자를 13자리 시프트하는 간단한 방법입니다. 예를 들어 'a'는 'n', 'b'는 'o' 이런 식이죠.&lt;/div&gt;&lt;div&gt;ROT13은 유효한 소스코드 인코딩입니다. 소스코드 최상단에 코딩 인코딩을 rot13으로 선언하고 아래와 같은 식으로 소스코드를 작성해도 됩니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#!/usr/bin/env&amp;nbsp;python&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;-*-&amp;nbsp;coding:&amp;nbsp;rot13&amp;nbsp;-*-&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;cevag&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;Uryyb&amp;nbsp;fgnpxbiresybj!&quot;&lt;/span&gt;.rapbqr(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;rot13&quot;&lt;/span&gt;)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;듣보잡의 위 코드가 뭔소리인지 알고 싶다면 아래와 같이 위 문자열을 rot13으로 decode해 보세요.&lt;/div&gt;&lt;p&gt;소스코드 읽기 어렵게 만드는 것 같은데... 도대체 왜??&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;'cevag&amp;nbsp;&quot;Uryyb&amp;nbsp;fgnpxbiresybj!&quot;.rapbqr(&quot;rot13&quot;)'&lt;/span&gt;.decode(&lt;span style=&quot;color:#ffd500&quot;&gt;'rot13'&lt;/span&gt;)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Regex Debugging&lt;/h3&gt;&lt;div&gt;정규식은 파이썬의 멋진 기능 입니다만 디버깅은 고통스럽고 잘못된 정규식을 만들기 쉽습니다.&lt;/div&gt;&lt;div&gt;다행이도 파이썬은 re.DEBUG 플래그를 넘기는 걸로 정규식 파스 트리를 출력할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;re.compile(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;^\[font(?:=(?P&amp;lt;size&amp;gt;[-+][0-9]{1,2}))?\](.*?)[/font]&quot;&lt;/span&gt;,&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;re.DEBUG)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;at&amp;nbsp;at_beginning&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;91&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;102&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;111&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;110&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;116&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;max_repeat&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;subpattern&amp;nbsp;None&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;61&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;subpattern&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;45&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;43&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;max_repeat&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;range&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#c10aff&quot;&gt;48&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;57&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;93&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;subpattern&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;min_repeat&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;65535&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;any&amp;nbsp;None&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;in&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;47&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;102&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;111&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;110&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;literal&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;116&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;저 문법을 이해했다면 에러를 잡을 수 있겠죠. 여기에서는 [/font]의 []에 escape 문자가 빠진 걸 볼 수 있네요.&lt;/div&gt;&lt;p&gt;물론 주석붙은 정규식 같이 다른&amp;nbsp;플래그와도 같이 쓸 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;re.compile(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;^&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;start&amp;nbsp;of&amp;nbsp;a&amp;nbsp;line&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;\[font&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;the&amp;nbsp;font&amp;nbsp;tag&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;(?:=(?P&amp;lt;size&amp;gt;&amp;nbsp;&amp;nbsp;#&amp;nbsp;optional&amp;nbsp;[font=+size]&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;[-+][0-9]{1,2}&amp;nbsp;#&amp;nbsp;size&amp;nbsp;specification&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;))?&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;\]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;end&amp;nbsp;of&amp;nbsp;tag&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;(.*?)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;text&amp;nbsp;between&amp;nbsp;the&amp;nbsp;tags&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;\[/font\]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;end&amp;nbsp;of&amp;nbsp;the&amp;nbsp;tag&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;,&amp;nbsp;re.DEBUG&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;re.VERBOSE&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;re.DOTALL)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3&gt;Sending to Generators&lt;/h3&gt;&lt;div&gt;Generator 함수에 값을 전달할 수 있습니다. 다음 예제를 보시죠.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;mygen():&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;Yield&amp;nbsp;5&amp;nbsp;until&amp;nbsp;something&amp;nbsp;else&amp;nbsp;is&amp;nbsp;passed&amp;nbsp;back&amp;nbsp;via&amp;nbsp;send()&quot;&lt;/span&gt;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;True:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;f&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(yield&amp;nbsp;a)&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#yield&amp;nbsp;a&amp;nbsp;and&amp;nbsp;possibly&amp;nbsp;get&amp;nbsp;f&amp;nbsp;in&amp;nbsp;return&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;f&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;is&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;not&lt;/span&gt;&amp;nbsp;None:&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;f&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#store&amp;nbsp;the&amp;nbsp;new&amp;nbsp;value&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;다음과 같이 실행됩니다. 즉 send(7) 하면 위 코드의 yield a의 반환값으로 전달됩니다.&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;g&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;mygen()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;g.&lt;span style=&quot;color:#ff3399&quot;&gt;next&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;g.&lt;span style=&quot;color:#ff3399&quot;&gt;next&lt;/span&gt;()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;5&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;g.send(&lt;span style=&quot;color:#c10aff&quot;&gt;7&lt;/span&gt;)&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#we&amp;nbsp;send&amp;nbsp;this&amp;nbsp;back&amp;nbsp;to&amp;nbsp;the&amp;nbsp;generator&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;7&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;g.&lt;span style=&quot;color:#ff3399&quot;&gt;next&lt;/span&gt;()&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;#now&amp;nbsp;it&amp;nbsp;will&amp;nbsp;yield&amp;nbsp;7&amp;nbsp;until&amp;nbsp;we&amp;nbsp;send&amp;nbsp;something&amp;nbsp;else&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;7&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;Tab Completion in Interactive Interpreter&lt;/h3&gt;&lt;div&gt;파이썬 셀(인터렉티브 인터프리터)에서 탭 자동완성을 지원합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;import&lt;/span&gt;&amp;nbsp;readline&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;import&lt;/span&gt;&amp;nbsp;rlcompleter&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;readline.parse_and_bind(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;tab:&amp;nbsp;complete&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;class&lt;/span&gt;&amp;nbsp;myclass:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;def&lt;/span&gt;&amp;nbsp;function(self):&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;my&amp;nbsp;function&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;class_instance&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;myclass()&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;class_instance.&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;TAB&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;class_instance.__class__&amp;nbsp;&amp;nbsp;&amp;nbsp;class_instance.__module__&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;class_instance.__doc__&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class_instance.function&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;class_instance.f&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;TAB&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;unction()&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;.pythonrc에 다음 파일을 넣고 PYTHONSTARTUP 환경변수 설정을 하면 tab completion을 사용할 수 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;~/.pythonrc&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;#&amp;nbsp;enable&amp;nbsp;syntax&amp;nbsp;completion&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;import&lt;/span&gt;&amp;nbsp;readline&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;except&lt;/span&gt;&amp;nbsp;ImportError:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;Module&amp;nbsp;readline&amp;nbsp;not&amp;nbsp;available.&quot;&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;import&lt;/span&gt;&amp;nbsp;rlcompleter&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;readline.parse_and_bind(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;tab:&amp;nbsp;complete&quot;&lt;/span&gt;)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;







&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; PYTHONSTARTUP=~/.pythonrc&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;이것 보다는 ipython을 쓰거나 막강한 jupyter notebook을 사용하는 편이 훨씬 편리합니다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;h3&gt;&lt;span class=&quot;s2&quot;&gt;Ternary Expression&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;조건부 할당을 할 수 있습니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;







&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;x = &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; (y == &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;2&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;이 식은 명확히 &quot;y 가 1이면 x에 3을 아니면 2를 할당&quot; 하라는 것 같습니다. 여기서 괄호가 필수는 아니지만 이것이 더 읽기 쉽습니다. 여기에 좀 더 복잡한 조건을 연결할 수 있습니다.&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;







&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;x = &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; (y == &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; (y == -&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;1&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;어떤 표현에도 if ... else 를 사용할 수 있습니다. 다음 예를 보죠.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;







&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;(func1 &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; y == &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; func2)(arg1, arg2)&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;y가 1일 경우 func1이 아니면 func2가 실행됩니다. 두 경우 모두 관련함수는 arg1과 arg2를 인자로 호출됩니다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;비슷하게 다음 코드도 가능합니다.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;







&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;x = (class1 &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; y == &lt;/span&gt;&lt;span class=&quot;s3&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; class2)(arg1, arg2)&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;또 다른 예제. C, Java 스타일로는 return y == 1 ? 3 : 2;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(254, 254, 184); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p class=&quot;p1&quot;&gt;return 3 if (y == 1) else 2&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;p1&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class=&quot;p1&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;try/except/else&lt;/h3&gt;&lt;div&gt;예외에서 else 구문: &amp;nbsp;try 블럭에서 예외가 발생하면 except 블럭이 발생하지 않으면 else 블럭이 실행됩니다.&lt;/div&gt;&lt;div&gt;예외가 발생하던 하지 않던 finally 블럭은 무조건 실행됩니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;put_4000000000_volts_through_it(parrot)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;except&lt;/span&gt;&amp;nbsp;Voom:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;'E's&amp;nbsp;pining!&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;print&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;This&amp;nbsp;parrot&amp;nbsp;is&amp;nbsp;no&amp;nbsp;more!&quot;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;finally:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;end_sketch()&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;h3&gt;with statement&lt;/h3&gt;&lt;div&gt;PEP 343에 소개되었고 한 벌의 문장들에 대해 실시간 컨텍스트를 관리하는 context manager 객체를 지원합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;이 기능이 새로운 키워드를 사용하여 이 기능은 점진적으로 지원합니다. 파이썬 2.5에서는 __future__ 지시자를 통해 사용할 수 있습니다. 파이썬 2.6 이상에서는 기본으로 사용 가능합니다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;이 기능은 유용한 구성을 가능하게 하여 많이 사용합니다. 다음은 간단한 데모를 보시죠.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;from&lt;/span&gt;&amp;nbsp;__future__&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;import&lt;/span&gt;&amp;nbsp;with_statement&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;with&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;open&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;'foo.txt'&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ffd500&quot;&gt;'w'&lt;/span&gt;)&amp;nbsp;as&amp;nbsp;f:&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;f.write(&lt;span style=&quot;color:#ffd500&quot;&gt;'hello!'&lt;/span&gt;)&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;이 뒤에서 일어나는 일을 보면 &quot;with&quot; 문장은 file 객체의 __enter__ 그리고 __exit__ 메소드를 호출합니다. (with 블럭 들어가기전 __enter__ 예외 또는 나올 때 __exit__)&lt;/p&gt;&lt;p&gt;with 문장 블럭에서 예외가 발생했을 때 예외상황의 자세한 부분은 __exit__ 메소드에 맡깁니다.&lt;/p&gt;&lt;p&gt;이 경우 정상적으로 수행되거나 예외가 발생하거나 상관없이 with 블럭을 벗어나면 파일을 닫는 것을 보증합니다.&lt;/p&gt;&lt;p&gt;이 기능은 일반적인 마무리(?) 작업을 암시적으로 수행하는 방법을 제공합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;with절은 쓰레드 잠금이나 데이터베이스 트랜잭션에 일반적으로 사용됩니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
<category>Python</category>
<category>Python</category>
<category>파이썬</category>
<author>행복한아빠</author>
<guid isPermaLink="true">https://greatkim91.tistory.com/189</guid>
<comments>https://greatkim91.tistory.com/189#entry189comment</comments>
<pubDate>Thu, 25 Aug 2016 11:50:13 +0900</pubDate>
</item>
<item>
<title>Log4J 로깅 레벨 실시간에 바꾸기</title>
<link>https://greatkim91.tistory.com/186</link>
<description>&lt;p&gt;운영 중 장애를 접할 때 개발자가 남긴&amp;nbsp;로그는 참 유용합니다. 하지만 실 운영환경에서는 로그를 debug 레벨로 남기지 않아 장애 원인을 찾기가 어려울 때가 있습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;왜 만들었나?&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;이번에 참여한 프로젝트에서는 iBatis를 사용하고 있습니다. 운영팀은 장애가 나면 실제 실행된 SQL 과 파라메터, 반환값을 보고 원인을 찾는다고 합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;그런데 실 운영환경에서는 로깅 부하 및 로그파일의 증가 때문에 보통 debug 레벨의 상세로그를 남기지 않습니다. 그래서 필요할 때만 iBatis의 SQL 로그를 남기는 장치를 넣으려다 아예 실시간에 모든 로그를 조정하는 장치를 만들어 공개합니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;해결해야할 문제&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;보통 Log4J 로깅방법 및 로깅레벨은 log4j.properties나 log4j.xml 파일에 설정하고 로깅레벨을 새로 적용하기 위해서는 위 파일을 변경하고 재가동합니다. 그러나 운영 중인 서버를 재가동하기는 부담스럽습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;다행히 Log4J는 아래와 같은 API를 제공하여 아래의 API를 이용하면 실시간에 로깅레벨은 쉽게 조정할 수 있습니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:0; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;모든&amp;nbsp;로거&amp;nbsp;카테고리를&amp;nbsp;추출&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;Logger&amp;nbsp;root&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;Logger.getRootLogger();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;Enumeration&amp;nbsp;categories&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;root.getLoggerRepository().getCurrentCategories();&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;...&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;로거의&amp;nbsp;레벨&amp;nbsp;설정&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;Category&amp;nbsp;category&amp;nbsp;&lt;span style=&quot;color:#0086b3&quot;&gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;...;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;category.setLevel(Level.DEBUG);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;뭐&amp;nbsp;이런&amp;nbsp;식으로..&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; border-radius: 10px; padding: 1px; background-color: rgb(79, 79, 79);&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;설치하기&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;/div&gt;&lt;p&gt;이런 식으로 해서 web application의 Log4J 로그레벨을 런타임에 변경할 수 있는 기능을 만들었습니다. 이 모듈을 설치하기 위해서는 Spring framework 3.0 이상&amp;nbsp;SpringMVC와 JSTL 1.2 그리고&amp;nbsp;jquery-1.11 이상이 설치되어 있어야 하면... &lt;b&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;귀찮기에 그냥 JSP 한 페이지에 아무 것도 쓰지 않고 넣었습니다&lt;/span&gt;&lt;/b&gt;.&lt;/p&gt;&lt;p&gt;그냥 아래 파일을 web application에 JSP 접근가능한 경로에 넣으시면 됩니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/262EF43553C6234832&quot; filename=&quot;log4jLevel.jsp&quot; filemime=&quot;text/html&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;사용하기&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;JSP을 브라우저로 접근하면 아래와 같은 화면이 나옵니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;http://userhost:port/log4jLevel.jsp&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display:inline-block;width:610px;;height:auto;max-width:100%&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/2228A63D53C624A12E&quot; filemime=&quot;image/jpeg&quot; filename=&quot;log4jLevel1.png&quot; height=&quot;368&quot; width=&quot;610&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;컴포박스에서 로그레벨을 선택하고 조정을 원하는 로거 category를 선택하고 &quot;Change all selected logger level&quot; 버튼을 클릭하면 됩니다.&amp;nbsp;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;iBatis SQL log ON, iBatis SQL log OFF 링크는 iBatis SQL 관련 로거레벨을 DEBUG 또는 OFF로 설정하는 편의 기능입니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;iBatis SQL 로깅 관련&lt;/p&gt;&lt;p&gt;iBatis SQL 로거이름은 아래와 같이 4개의 로거인데 이게 log4j.properties나 log4j.xml에 지정되지 않으면 생기지 않습니다. 따라서 iBatis SQL 로깅을 실시간에 조정하려면 서버 실행 전&amp;nbsp;log4j 설정에 다음을 추가해야 합니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;log4j.properties 예)&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p&gt;...&lt;/p&gt;&lt;p&gt;log4j.logger.java.sql.Connection=OFF, stdout&lt;br /&gt;&lt;/p&gt;&lt;p&gt;log4j.logger.java.sql.Statement=OFF, stdout&lt;/p&gt;&lt;p&gt;log4j.logger.java.sql.PreparedStatement=OFF, stdout&lt;/p&gt;&lt;p&gt;log4j.logger.java.sql.ResultSet=OFF, stdout&lt;/p&gt;&lt;p&gt;...&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;table class=&quot;txc-table&quot; width=&quot;574&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; style=&quot;border:none;border-collapse:collapse;;font-family:돋움;font-size:12px&quot;&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;log4j.xml 예)&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;txc-textbox&quot; style=&quot;border: 1px solid rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);&quot;&gt;&lt;p&gt;...&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;logger name=&quot;java.sql.Connection&quot; additivity=&quot;false&quot;&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;level value=&quot;OFF&quot; /&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;appender-ref ref=&quot;console&quot; /&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/logger&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;lt;logger name=&quot;java.sql.Statement&quot; additivity=&quot;false&quot;&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;level value=&quot;OFF&quot; /&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;appender-ref ref=&quot;console&quot; /&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/logger&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;lt;logger name=&quot;java.sql.PreparedStatement&quot; additivity=&quot;false&quot;&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;level value=&quot;OFF&quot; /&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;appender-ref ref=&quot;console&quot; /&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/logger&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;lt;logger name=&quot;java.sql.ResultSet&quot; additivity=&quot;false&quot;&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;level value=&quot;OFF&quot; /&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;appender-ref ref=&quot;console&quot; /&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/logger&amp;gt;&lt;/p&gt;&lt;p&gt;...&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;주의할 점&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;hr style=&quot;display:block; border: black 0 none; border-top: black 1px solid; height: 1px&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;Log4J 로깅을 조절할 수 있는 페이지이므로 시스템에 심각한 영향을 줄 수 있습니다. 따라서 악의를 가진 사용자가 이 페이지에 접근할 수 없도록 조치하기를 바랍니다.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: 9pt; line-height: 1.5; background-color: transparent;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;참고로 log4j 버전은 1.2.13 에서 테스트하였습니다.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
<category>문제발생시</category>
<category>Level</category>
<category>Log4J</category>
<category>Runtime</category>
<category>레벨</category>
<category>로깅</category>
<category>실시간</category>
<author>행복한아빠</author>
<guid isPermaLink="true">https://greatkim91.tistory.com/186</guid>
<comments>https://greatkim91.tistory.com/186#entry186comment</comments>
<pubDate>Fri, 25 Jul 2014 11:00:54 +0900</pubDate>
</item>
</channel>
</rss>