1 Star 0 Fork 229

hello-tom/project_25500701

forked from mktime/python-learn 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
learn-class.py 681 Bytes
一键复制 编辑 原始数据 按行查看 历史
mr.github 提交于 2015-01-07 17:42 . archlinux install steps
#!/bin/env python
import os, sys, time, logging
class Base(object):
def __init__(self, name):
self.name = name
def __repr__(self):
_repr = "{klass}({name})".format(klass=self.__class__.__name__, name=self.name)
return _repr
class ObjectDict(dict):
def __getattr__(self, key):
if key in self:
return self[key]
return None
def __setattr__(self, key, value):
self[key] = value
class MyObject(ObjectDict):
def __init__(self):
pass
def main():
o = MyObject()
o.aa= 'bb'
o.cc = 'dd'
print o
#base = Base("hello")
#print base
if __name__ == '__main__':
main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/hello-tom/python-learn.git
git@gitee.com:hello-tom/python-learn.git
hello-tom
python-learn
project_25500701
master

搜索帮助