Skip to content

Instantly share code, notes, and snippets.

@masasuzu
Last active January 13, 2016 05:44
Show Gist options
  • Save masasuzu/c7082b003170155d829e to your computer and use it in GitHub Desktop.
Save masasuzu/c7082b003170155d829e to your computer and use it in GitHub Desktop.
文字列表現として、インスタンス変数をダンプしたい
class Hoge(object):
def __init__(self, foo=[], bar={ 'name': 'piyo' }):
self.foo = foo
self.bar = bar
def __repr__(self):
return '%s: %s' % (self.__class__, self.__dict__)
hoge = Hoge()
print(hoge)
<class '__main__.Hoge'>: {'foo': [], 'bar': {'name': 'piyo'}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment