1 Star 0 Fork 238

buxie/python-learn

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()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/cjb/python-learn.git
git@gitee.com:cjb/python-learn.git
cjb
python-learn
python-learn
master

搜索帮助