私の目的は、Python ファイル内のコード行の正確なインデントを特定することです。私はある場所でステートメントをインストルメント化するので、行の必要なインデントを決定することは私の目標を達成するために重要です。この問題は、次の例で説明できます。
First Scenario
#A.py
a=0 <----------- indentation '0' spaces or '0' \t
while a<5: <----------- indentation '0' spaces or '0' \t
print a <----------- indentation '4' spaces or '1' \t
a=a+1 <----------- indentation '4' spaces or '1' \t
Second scenario
#A.py
a=0 <----------- indentation '0' spaces or '0' \t
while a<5: <----------- indentation '0' spaces or '0' \t
print a <----------- indentation '8' spaces or '2' \t
a=a+1 <----------- indentation '8' spaces or '2' \t
多くのファイルで構成されるアプリケーションを検査しているため、上記のシナリオのファイルに出くわしました。Python ファイル内の任意の行のインデントを確認する方法を知りたいですか?