Python re 模块,_compile() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用re._compile()

项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_pickling(self):
        import pickle
        self.pickle_test(pickle)
        import cPickle
        self.pickle_test(cPickle)
        # old pickles expect the _compile() reconstructor in sre module
        import_module("sre", deprecated=True)
        from sre import _compile
        # current pickle expects the _compile() reconstructor in re module
        from re import _compile
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_pickling(self):
        import pickle
        self.pickle_test(pickle)
        import cPickle
        self.pickle_test(cPickle)
        # old pickles expect the _compile() reconstructor in sre module
        import_module("sre", deprecated=True)
        from sre import _compile
        # current pickle expects the _compile() reconstructor in re module
        from re import _compile
项目:lang2program    作者:kelvinguu    | 项目源码 | 文件源码
def install():
    """Install the hooks for measuring import and regex compile time."""
    __builtins__['__import__'] = timed_import
    re._compile = timed_compile
项目:lang2program    作者:kelvinguu    | 项目源码 | 文件源码
def uninstall():
    """Remove the import and regex compile timing hooks."""
    __builtins__['__import__'] = _real_import
    re._compile = _real_compile
项目:lang2program    作者:kelvinguu    | 项目源码 | 文件源码
def install():
    """Install the hooks for measuring import and regex compile time."""
    __builtins__['__import__'] = timed_import
    re._compile = timed_compile
项目:lang2program    作者:kelvinguu    | 项目源码 | 文件源码
def uninstall():
    """Remove the import and regex compile timing hooks."""
    __builtins__['__import__'] = _real_import
    re._compile = _real_compile
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_pickling(self):
        import pickle
        self.pickle_test(pickle)
        import cPickle
        self.pickle_test(cPickle)
        # old pickles expect the _compile() reconstructor in sre module
        import_module("sre", deprecated=True)
        from sre import _compile
        # current pickle expects the _compile() reconstructor in re module
        from re import _compile
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_pickling(self):
        import pickle
        oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)', re.UNICODE)
        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
            pickled = pickle.dumps(oldpat, proto)
            newpat = pickle.loads(pickled)
            self.assertEqual(newpat, oldpat)
        # current pickle expects the _compile() reconstructor in re module
        from re import _compile
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_pickling(self):
        import pickle
        oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)', re.UNICODE)
        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
            pickled = pickle.dumps(oldpat, proto)
            newpat = pickle.loads(pickled)
            self.assertEqual(newpat, oldpat)
        # current pickle expects the _compile() reconstructor in re module
        from re import _compile