$ echo "Your code is bad and you should feel bad" > "<stdin>"
$ python
Python 3.6.0 (default, Dec 28 2016, 19:53:26)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 2 + '2'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Your code is bad and you should feel bad
TypeError: unsupported operand type(s) for +: 'int' and 'str'
なぜPythonは文字列"<stdin>"
をそのファイル名と一致するファイルと混同しますか?私は、処理されない例外が発生した場合、Pythonがディスクからファイルを読み込もうとしませんでした。トレースバックを印刷するときに、現在のディレクトリからPythonが読み込まれるのはなぜですか?
また"<string>"
ファイル名でそれを得ることができます。
$ echo "pining for the fjords" > "<string>"
$ python -c 'wat'
Traceback (most recent call last):
File "<string>", line 1, in <module>
pining for the fjords
NameError: name 'wat' is not defined
は、その動作を防ぐ方法はありますか、REPLにハードコードされましたか?
ああ、かわいいバグです。あなたはそれを報告すべきです。 – kindall