Skip to content

Instantly share code, notes, and snippets.

@tomoh1r
Created December 15, 2012 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoh1r/4295338 to your computer and use it in GitHub Desktop.
Save tomoh1r/4295338 to your computer and use it in GitHub Desktop.
インスタンスについて、親クラスの変数の値を変えたらどうなるか、インスタンス自身の値を変えたらどうなるかテスト
# coding: utf-8
class Hoge(object):
x = 100
hoge = Hoge()
print(hoge.x)
# => 100
Hoge.x = 200
print(hoge.x)
# => 200
hoge.x = 300
print(hoge.x)
# => 300
Hoge.x = 400
print(hoge.x)
# => 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment