rlcompleter2.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:pyshell 作者: oglops 项目源码 文件源码
def __init__(self, config, text = '', attr = None):
        """ evaluate last possible expression part in text.

            attr can be a string or a filter-function
            which accepts/rejects (name,obj)-bindings.
        """
        self.config = config
        debug("got text %s, attr %s" % (repr(text),repr(attr)))
        self.text = text

        if attr and type(attr) is str:
            self.attrname = attr
            self.func = lambda x: x[0].startswith(attr)
        else:
            self.attrname = ''
            self.func = attr or config.viewfilter

        # try finding code and evaluting it...
        self.code = TryParser.find_code(text)
        if inspect.iscode(self.code):
            try: 
                self.obj = eval(self.code, vars(config.mainmodule))
            except: 
                raise Error(sys.exc_info()[1])
        else:
            self.text = ''
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号