Pythonのお勉強 Part62 (453レス)
Pythonのお勉強 Part62 http://mevius.5ch.net/test/read.cgi/tech/1568616071/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
249: デフォルトの名無しさん [] 2020/06/19(金) 00:00:07.20 ID:NJwW7ejS python 使い始めて数年だけども、今日初めて知ったことがあるので質問させてください。 python のクラスって、インスタンスを生成した後に、勝手にメンバー変数を定義できちゃうものなんですか? もし、それがよく知られている機構なのであれば、一般的に何と呼ばれているのか教えてください。 例) >>> class myClass(): ... pass ... >>> c1 = myClass() >>> dir(c1) ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__'] >>> c1.hoge = 'hogehoge' >>> c1.hoge 'hogehoge' >>> dir(c1) ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'hoge'] また、こう言ったことをさせないためには、どうすれば良いのでしょうか? http://mevius.5ch.net/test/read.cgi/tech/1568616071/249
253: デフォルトの名無しさん [] 2020/06/19(金) 13:24:58.24 ID:NJwW7ejS >>250,251,252 ありがとうございます!! この機構、個人的には大変気持ち悪い… http://mevius.5ch.net/test/read.cgi/tech/1568616071/253
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.858s*