Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Pythonのデバッガーを使おう
Search
Shinya Okano
June 10, 2023
Technology
1
870
Pythonのデバッガーを使おう
Shinya Okano
June 10, 2023
Tweet
Share
More Decks by Shinya Okano
See All by Shinya Okano
プロファイラを使ってPythonアプリをチューニングしよう
tokibito
2
1.2k
Djangoテンプレートエンジンを使いこなそう!
tokibito
0
2.5k
Djangoフレームワークの紹介_OSC北海道2019
tokibito
1
1k
DjangoCongressJP開催レポート
tokibito
0
79
Djangoフレームワークの紹介 OSC2018do
tokibito
0
2.7k
Other Decks in Technology
See All in Technology
private spaceについてあれこれ調べてみた
operando
1
160
DevSecOps入門:Security Development Lifecycleによる開発プロセスのセキュリティ強化
yuriemori
0
230
[TechNight #86] Oracle GoldenGate - 23ai 最新情報&プロジェクトからの学び
oracle4engineer
PRO
1
170
Mocking your codebase without cursing it
gaqzi
0
160
エラーバジェット枯渇の原因 - 偽陽性との戦い -
phaya72
1
100
SIEMによるセキュリティログの可視化と分析を通じた信頼性向上プロセスと実践
coconala_engineer
1
2.9k
アクセシブルなマークアップの上に成り立つユーザーファーストなドロップダウンメニューの実装 / 20250127_cloudsign_User1st_FE
bengo4com
2
1.2k
Amazon Location Serviceを使ってラーメンマップを作る
ryder472
2
150
Grafanaのvariables機能について
tiina
0
180
Server Side Swift 実践レポート: 2024年に案件で採用して見えた課題と可能性
yusuga
1
410
BLEAでAWSアカウントのセキュリティレベルを向上させよう
koheiyoshikawa
0
120
バクラクの組織とアーキテクチャ(要約)2025/01版
shkomine
13
2.9k
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
The Pragmatic Product Professional
lauravandoore
32
6.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Raft: Consensus for Rubyists
vanstee
137
6.7k
How STYLIGHT went responsive
nonsquared
96
5.3k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
We Have a Design System, Now What?
morganepeng
51
7.4k
Documentation Writing (for coders)
carmenintech
67
4.6k
Transcript
Pythonのデバッガーを 使おう @tokibito
Pythonのプログラムをデバッグする • デバッグ方法は色々 • print関数を入れる? • ロギングlogging.debug関数を使う? • 組み込みのデバッガーpdbモジュール
pdbモジュール • https://docs.python.org/ja/3/library/pdb.html • 標準で入っている • CUIで使える • Pythonがあれば通常どこでも使えるので覚えておくとよい
ブレークポイントをコード内に指定 • 組み込みのbreakpoint()関数 • import pdb; pdb.set_trace()
pdbから起動する • python -m pdb my-script.py
pdbのコマンド • b: ブレークポイント指定 • ファイル名:行番号 • c: ブレークポイントまで継続 •
s: ステップ実行 • l: 現在の実行位置を表示 • n: 次の呼び出しまで進む • q: 終了
pdb以外のデバッガ • ipdb • IPythonのインターフェースなので使いやすい • pudb • CUIだがリッチなデバッガー
他のデバッグ方法 • VSCodeでデバッグする • こちらのほうが手軽