2/26/2017

[PYTHON] pudb(console base debugger)를 이용하여 python script 디버깅하기

파이썬 코드때문에 웹을 돌아다니던 중 stackoveflow에서 쓸만한 python debugger를 하나 찾았습니다.
http://stackoverflow.com/questions/1623039/python-debugging-tips

바로 pudb라는 python 모듈입니다. 이 모듈은 파이썬 코드를 쉽게 디버깅하기 위해 만들어진 모듈입니다. 오늘은 이 모듈을 사용하여 python 코드에 대해 디버깅하는 방법을 공유드리겠습니다.


What is pudb

pudb는 console 기반의 python 디버거입니다. 전체적인 느낌은 DOS를 많이 따라가고 코드단을 보면서 디버깅이 가능합니다. 단순해보이지만 많은 기능을 담고 있습니다.

https://pypi.python.org/pypi/pudb
(원격 디버깅도 지원하죠)

Its goal is to provide all the niceties of modern GUI-based debuggers in a more lightweight and keyboard-friendly package. PuDB allows you to debug code right where you write and test it–in a terminal. If you’ve worked with the excellent (but nowadays ancient) DOS-based Turbo Pascal or C tools, PuDB’s UI might look familiar.

아래 링크 참고해주세요~

https://pypi.python.org/pypi/pudb

Install pudb

설치는 아주 간단합니다. pip 로 설치해줍니다.
#> pip install pudb

또는.. github에서 받으셔도 됩니다.

#> git clone http://git.tiker.net/trees/pudb.git

Python script debugging with pudb module


pudb는 콘솔라인 디버거로 gui 사용이 어려울 때 좋은 효율을 낼 수 있습니다.
실행하는 법 또한 간단합니다. python 의 -m 옵션으로 설치도니 pudb를 로드하고. 대상 파이썬 파일을 지정해주면.. 디버깅 모드로 열리며 python 코드를 보면서 메모리 값과 변수값을 추적할 수 있습니다.

#> python -m pudb.run test.py

or

#> pudb my-script.py

코드상에서 pudb를 불러오기 위해서는 다른 라이브러리와 같이 import 를 사용하여 로드한 후


Reference




HAHWUL

Security engineer, Gopher and H4cker!

Share: | Coffee Me:

1 comment: