by shigemk2

当面は技術的なことしか書かない

dict と get

# -*- coding: utf-8 -*-

class Hoge:
    @property
    def hoge(self):
        return 'hoge'
    @property
    def homu(self):
        return 'homu'

HOGE_DICT = {
    'hoge' : u'ワーチョマーチョマーチョナチョノーン',
    'homu' : u'オンドゥルルラギッタンディスカ',
    }

hoge = Hoge()
print hoge.hoge # hoge

hoged = HOGE_DICT
print hoged.get(hoge.homu) # オンドゥルルラギッタンディスカ