「Python試用録(9)」

%9:「Python試用録(9)」
「WILDの処理系」作成のための断片的備忘録です.
/*背景色は(茶: 編集・確認中; 灰色: 確認済; 緑: 非慣用記法; 白色: 初期化済)*/

%91:[@IT_26]/*「オブジェクトの同一性」*/
`▼
--------------------------------------------------------------------------------
(0)「In[2]:」
   mylist = [1, 2, 3]
   yourlist = mylist
   otherlist = list([1, 2, 3])
   print('mylist == yourlist?', mylist == yourlist)
   print('mylist == otherlist?', mylist == otherlist)
(1)参考資料
 ①https://www.atmarkit.co.jp/ait/articles/1907/16/news023.html
 ②https://docs.python.org/ja/3/reference/compound_stmts.html#class-definitions
  ・クラス定義は実行可能な文です。継承リストは通常、基底クラスリストを与えます
    classdef    ::=  [decorators] "class" classname [inheritance] ":" suite
    inheritance ::=  "(" [argument_list] ")"
    classname   ::=  identifier
(2)「Out[2]:」
   mylist == yourlist? True
   mylist == otherlist? False
(3)「(2)」よりも【[%81](1)②】の
    --------------------------------
    >>> x = [1, 2, 3]
    >>> y = [4, 5, 6]
    >>> zipped = zip(x, y)
    >>> list(zipped)
    [(1, 4), (2, 5), (3, 6)]
    --------------------------------
  「(1, 4)」,「(2, 5)」を複素数と考えると,同一性の意味が分かり易い
(4)
--------------------------------------------------------------------------------
`▲

コメント

このブログの人気の投稿

「日記帳(2023 冬)」

ブログの教材で学ぶMATH(1)