摘要:
http://www.tutorialspoint.com/python/python_modules.htmA module allows you to logically organize your Python code. Grouping related code into a module makes the code easier to understand and use.A module is a Python object with arbitrarily named attributes that you can bind and reference.Simply, a m 阅读全文
摘要:
http://www.readmespot.com/question/o/2724260/why-does-python-s-__import__-require-fromlist-In Python, if you want to programmatically import a module, you can do:module = __import__('module_name')If you want to import a submodule, you would think it would be a simple matter of:module = __imp 阅读全文
摘要:
http://www.4pang.com/2010/08/20/4%E8%83%96%E5%AD%A6python-%EF%BC%8D-__getattr__-%E5%92%8C-__getattribute__-%E6%96%B9%E6%B3%95%E7%9A%84%E5%8C%BA%E5%88%AB.htmlpython 再访问属性的方法上定义了__getattr__() 和 __getattribute__() 2种方法,其区别非常细微,但非常重要。如果某个类定义了__getattribute__()方法,在每次引用属性或方法名称时Python 都调用它(特殊方法名称除外,因为那样将会导 阅读全文
摘要:
http://blog.csdn.net/navygong/archive/2009/08/20/4467471.aspx1. __call__、__getattr__ 1 class B(): 2 def __call__(self, name): 3 return getattr(self, name) 4 5 def a(self, text): 6 print 'a' + text 7 8 def b(self, text): 9 print 'b' + text 10 11 class A(): 12 def __getattr__(self, nam 阅读全文
摘要:
原文地址:http://hi.baidu.com/python23python模块之ConfigParser: 用python解析配置文件 在程序中使用配置文件来灵活的配置一些参数是一件很常见的事情,配置文件的解析并不复杂,在python里更是如此,在官方发布的库中就包含有做这件事情的库,那就是ConfigParser,这里简单的做一些介绍。ConfigParser解析的配置文件的格式比较象ini的配置文件格式,就是文件中由多个section构成,每个section下又有多个配置项,比如:[db]db_host=127.0.0.1db_port=3306db_user=rootdb_pass= 阅读全文