昨日は記事をもう一つ書くと言っておきながらできなくてすみません...
#3はこちら
copyright
コピーライトを表示します。
本来対話型のターミナルで使う用なのですが、コード内でも普通に呼び出せます。
printや実行をすることで以下の文章が表示されます。
(__repr__と__call__が定義されているため)
ちなみにこれを調べたら_sitebuiltinsの_Printerという
オブジェクトらしいです。
Copyright (c) 2001-2024 Python Software Foundation.
All Rights Reserved.
Copyright (c) 2000 BeOpen.com.
All Rights Reserved.
Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.
Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved.
credits
さっきとほぼ同様ですが、表示されるのがクレジットです。
Thanks to CWI, CNRI, BeOpen, Zope Corporation, the Python Software
Foundation, and a cast of thousands for supporting Python
development. See www.python.org for more information.
debug
大体の場合はTrueになっていますが、
python -O
という感じでOptimizationオプションを使用すると
コードの最適化が行われて__debug__がFalseに切り替わります。
ちなみにこれがFalseだとassert文が実行されません。
組み込みのオブジェクトを調べるとPythonの
あまり知られていない機能がわかることもあります。
最後まで読んでいただきありがとうございます!