answered 14 hours ago
Eric Duminil
Pythonコードにて=
の書換えをしているようだ。
試してみた。
class A:
def __is__(self, who_cares):
return True
lie = A()
txt = """no matter how white, how small,
how incorporating of a smidgeon
of truth there be in it."""
if lie is lie is lie:
print(txt)
run
no matter how white, how small,
how incorporating of a smidgeon
of truth there be in it.
関連: 技術英語 > There is a little truth in what she says. / A lie is a lie is a lie.
備考
演算子の書換えは、コードの意図が分からなくなるから、自分は使わないことにしている。
What are the basic rules and idioms for operator overloading?
参考
トリプルクオーテーション @ PythonWeb
検索用キーワード: 三重引用符
is演算子は書換えできない
@LouiS0616 さんのコメント
によってis演算子は書換えできないことが分かりました。
情報感謝です。
link
Stackoverflow
での質問で得られた回答について有用な言葉とリンクを整理しておきます。
- operator chaining
- 6.10 Comparisons
- 10. Full Grammar specification¶