![見出し画像](https://assets.st-note.com/production/uploads/images/42745484/rectangle_large_type_2_da3ac489ba91b55873a3d079fda14703.jpg?width=1200)
≮Python≯ 同名のインスタンス変数 = クラス変数 + 数値 になるよ💦
これやっちゃうと、、、
同名のインスタンス変数 = クラス変数 + 数値
になっちゃうから気をつけてね💦
クラス変数に self. は危険でふ。。。
# indent ⇒ ____
class C:
____cv = 5
____def __init__(self):
________self.cv += 3 #クラス変数をプラス3したつもりがぁ・・・
________print(C.cv, self.cv)
print(C.cv)
a = C()
b = C()
ヤバい実行結果。。。
5
5 8
5 8
#Python #Python3 #プログラミング を #Android スマホで勉強中 !
#クラス変数
#インスタンス変数