ITeye博客

代码笔记

华天下 · 2011-10-16 09:41 · Python基础 · 编程语言 · Markdown

def _resolve(name):
    """将字符串转为对象"""
    """Resolve a dotted name to a global object."""
    name = name.split('.')
    used = name.pop(0)
    found = __import__(used)
    for n in name:
        used = used + '.' + n
        try:
            found = getattr(found, n)
        except AttributeError:
            __import__(used)
            found = getattr(found, n)
    return found
def _strip_spaces(alist):
    """去除列表里的字符串的空格"""
    return map(lambda x: x.strip(), alist)

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。