SyntaxError
ではなく、次のプログラムでIndentationError
が呼び出されるのはなぜですか?なぜ、SyntaxErrorではなく、ここでIndentationErrorが発生していますか?
>>> if True:
... print "just right!"
File "<stdin>", line 2
print "just right!"
^
IndentationError: Missing parentheses in call to 'print'
IDLEが面白いだけではないことを確認するために、このコードを通常のソースファイルから実行してテストしました。同じ例外タイプが引き続き発生しています。これをテストするために使用したPythonのバージョンは、Python 3.5.2とPython 3.6.1でした。
print
を使用しているときに括弧がないと、SyntaxError
と見なされましたが、IndentationError
ではありません。
“SyntaxError: Missing parentheses in call to 'print'” is a new error message that was added in Python 3.4.2 primarily to help users that are trying to follow a Python 2 tutorial while running Python 3.
が、これはバグです:ポストWhat does “SyntaxError: Missing parentheses in call to 'print'” mean in Python?のトップの答えも、これをサポートするように見えますか?もしそうなら、それは何の原因ですか?
これは意図された動作だと言っていますか? –
@ChristianDean:これはまだバグとして提出されているかどうかはわかりません。 –
_ここに2つのエラーがあります。_ _しかし、ここで2つのエラーが発生した場合、Pythonは通常、「上記の例外の処理中に別の例外が発生しました」というようなことを言っていませんか? –