DRYな備忘録

Don't Repeat Yourself.

Pythonのhasattrで詰まったメモ

% python
>>> class Foo():
...     hoge = 1
...     _fuga = 2
...     __piyo = 3
...     def __init__(self):
...             pass
...
>>> f = Foo()
>>> hasattr(f, 'hoge')
True
>>> hasattr(f, '_fuga')
True
>>> hasattr(f, '__piyo')
False
>>>

__bar で宣言したprivateなプロパティにはアクセスできないのか?

TODO : 調査