LoginSignup
1
2

More than 5 years have passed since last update.

Python > if lie is lie is lie: > is 演算子の書き換え(書換えできない) | 三重引用符 | operator chaining | link: Comparisons

Last updated at Posted at 2018-01-18

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
での質問で得られた回答について有用な言葉とリンクを整理しておきます。

1
2
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2