3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[python] あなたは本当に python(cpython)を理解しているのか

Last updated at Posted at 2018-07-17

以下のコードの実行結果に「当たり前でしょう」と思う方にはすみません。:bow:
スキップしてください。

class WTF:
  pass

WTF() == WTF()
# False
WTF() is WTF() 
# False

id(WTF()) == id(WTF())
# True

どうして」と思う方は、下記のデバッグコード入りのソースを見て頂ければわかるようになると思います。

class WTF(object):
  def __init__(self): print("I ")
  def __del__(self): print("D ")

WTF() is WTF()
# I I D D

id(WTF()) == id(WTF())
# I D I D    

理由の詳細な説明は こちら をご参照ください。

参考

3
2
2

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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?