Javascript style dot notation for dictionary keys unpythonic?

前端 未结 12 1047
刺人心
刺人心 2020-12-23 10:44

I\'ve started to use constructs like these:

class DictObj(object):
    def __init__(self):
        self.d = {}
    def __getattr__(self, m):
        return s         


        
12条回答
  •  清酒与你
    2020-12-23 11:01

    It's not bad if it serves your purpose. "Practicality beats purity".

    I saw such approach elserwhere (eg. in Paver), so this can be considered common need (or desire).

提交回复
热议问题