当前位置: 首页>>代码示例>>Python>>正文


Python __builtin__.__dict__方法代码示例

本文整理汇总了Python中__builtin__.__dict__方法的典型用法代码示例。如果您正苦于以下问题:Python __builtin__.__dict__方法的具体用法?Python __builtin__.__dict__怎么用?Python __builtin__.__dict__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在__builtin__的用法示例。


在下文中一共展示了__builtin__.__dict__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: complete

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def complete(self, text, state):
        """Return the next possible completion for 'text'.

        This is called successively with state == 0, 1, 2, ... until it
        returns None.  The completion should begin with 'text'.

        """
        if self.use_main_ns:
            self.namespace = __main__.__dict__

        if state == 0:
            if "." in text:
                self.matches = self.attr_matches(text)
            else:
                self.matches = self.global_matches(text)
        try:
            return self.matches[state]
        except IndexError:
            return None 
开发者ID:glmcdona,项目名称:meddle,代码行数:21,代码来源:rlcompleter.py

示例2: global_matches

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def global_matches(self, text):
        """Compute matches when text is a simple name.

        Return a list of all keywords, built-in functions and names currently
        defined in self.namespace that match.

        """
        import keyword
        matches = []
        n = len(text)
        for word in keyword.kwlist:
            if word[:n] == text:
                matches.append(word)
        for nspace in [__builtin__.__dict__, self.namespace]:
            for word, val in nspace.items():
                if word[:n] == text and word != "__builtins__":
                    matches.append(self._callable_postfix(val, word))
        return matches 
开发者ID:glmcdona,项目名称:meddle,代码行数:20,代码来源:rlcompleter.py

示例3: test_forever

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def test_forever(self):
        # test --forever
        code = textwrap.dedent("""
            import __builtin__
            import unittest
            from test import support

            class ForeverTester(unittest.TestCase):
                def test_run(self):
                    # Store the state in the __builtin__ module, because the test
                    # module is reload at each run
                    if 'RUN' in __builtin__.__dict__:
                        __builtin__.__dict__['RUN'] += 1
                        if __builtin__.__dict__['RUN'] >= 3:
                            self.fail("fail at the 3rd runs")
                    else:
                        __builtin__.__dict__['RUN'] = 1

            def test_main():
                support.run_unittest(ForeverTester)
        """)
        test = self.create_test('forever', code=code)
        output = self.run_tests('--forever', test, exitcode=2)
        self.check_executed_tests(output, [test]*3, failed=test) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:test_regrtest.py

示例4: global_matches

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def global_matches(self, text):
        """Compute matches when text is a simple name.

        Return a list of all keywords, built-in functions and names currently
        defined in self.namespace that match.

        """
        import keyword
        matches = []
        seen = {"__builtins__"}
        n = len(text)
        for word in keyword.kwlist:
            if word[:n] == text:
                seen.add(word)
                matches.append(word)
        for nspace in [self.namespace, __builtin__.__dict__]:
            for word, val in nspace.items():
                if word[:n] == text and word not in seen:
                    seen.add(word)
                    matches.append(self._callable_postfix(val, word))
        return matches 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:rlcompleter.py

示例5: init_builtins

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def init_builtins(self):
        # A single, static flag that we set to True.  Its presence indicates
        # that an IPython shell has been created, and we make no attempts at
        # removing on exit or representing the existence of more than one
        # IPython at a time.
        builtin_mod.__dict__['__IPYTHON__'] = True

        # In 0.11 we introduced '__IPYTHON__active' as an integer we'd try to
        # manage on enter/exit, but with all our shells it's virtually
        # impossible to get all the cases right.  We're leaving the name in for
        # those who adapted their codes to check for this flag, but will
        # eventually remove it after a few more releases.
        builtin_mod.__dict__['__IPYTHON__active'] = \
                                          'Deprecated, check for __IPYTHON__'

        self.builtin_trap = BuiltinTrap(shell=self) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:18,代码来源:interactiveshell.py

示例6: init_sys_modules

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def init_sys_modules(self):
        # We need to insert into sys.modules something that looks like a
        # module but which accesses the IPython namespace, for shelve and
        # pickle to work interactively. Normally they rely on getting
        # everything out of __main__, but for embedding purposes each IPython
        # instance has its own private namespace, so we can't go shoving
        # everything into __main__.

        # note, however, that we should only do this for non-embedded
        # ipythons, which really mimic the __main__.__dict__ with their own
        # namespace.  Embedded instances, on the other hand, should not do
        # this because they need to manage the user local/global namespaces
        # only, but they live within a 'normal' __main__ (meaning, they
        # shouldn't overtake the execution environment of the script they're
        # embedded in).

        # This is overridden in the InteractiveShellEmbed subclass to a no-op.
        main_name = self.user_module.__name__
        sys.modules[main_name] = self.user_module 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:interactiveshell.py

示例7: global_info

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def global_info(self,var_num):
        # This is the name value is known by
        var_name = self.codeobject.co_names[var_num]

        # First, figure out who owns this global
        myHash = id(self.function.func_globals)
        for module_name in sys.modules:
            module = sys.modules[module_name]
            if module and id(module.__dict__) == myHash:
                break
        else:
            raise ValueError('Cannot locate module owning %s' % var_name)
        return module_name,var_name

    ##################################################################
    #                         MEMBER CODEUP                          #
    ################################################################## 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:bytecodecompiler.py

示例8: replace_builtin_property

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def replace_builtin_property(new_property=None):
    if new_property is None:
        new_property = DebugProperty
    original = property
    if IS_PY2:
        try:
            import __builtin__
            __builtin__.__dict__['property'] = new_property
        except:
            pydev_log.exception()  # @Reimport
    else:
        try:
            import builtins  # Python 3.0 does not have the __builtin__ module @UnresolvedImport
            builtins.__dict__['property'] = new_property
        except:
            pydev_log.exception()  # @Reimport
    return original


#=======================================================================================================================
# DebugProperty
#======================================================================================================================= 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:24,代码来源:pydevd_traceproperty.py

示例9: complete

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def complete(self, text):
        """Return the next possible completion for 'text'.

        This is called successively with state == 0, 1, 2, ... until it
        returns None.  The completion should begin with 'text'.

        """
        if self.use_main_ns:
            # In pydev this option should never be used
            raise RuntimeError('Namespace must be provided!')
            self.namespace = __main__.__dict__  # @UndefinedVariable

        if "." in text:
            return self.attr_matches(text)
        else:
            return self.global_matches(text) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:18,代码来源:_pydev_completer.py

示例10: global_matches

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def global_matches(self, text):
        """Compute matches when text is a simple name.

        Return a list of all keywords, built-in functions and names currently
        defined in self.namespace or self.global_namespace that match.

        """

        def get_item(obj, attr):
            return obj[attr]

        a = {}

        for dict_with_comps in [__builtin__.__dict__, self.namespace, self.global_namespace]:  # @UndefinedVariable
            a.update(dict_with_comps)

        filter = _StartsWithFilter(text)

        return dir2(a, a.keys(), get_item, filter) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:21,代码来源:_pydev_completer.py

示例11: _create_interactive_locals

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def _create_interactive_locals(self):
        # Create and return a *new* locals dictionary based on self.locals,
        # and set any new entries in it. (InteractiveConsole does not
        # copy its locals value)
        _locals = self.locals.copy()
        # __builtins__ may either be the __builtin__ module or
        # __builtin__.__dict__; in the latter case typing
        # locals() at the backdoor prompt spews out lots of
        # useless stuff
        try:
            import __builtin__
            _locals["__builtins__"] = __builtin__
        except ImportError:
            import builtins
            _locals["builtins"] = builtins
            _locals['__builtins__'] = builtins
        return _locals 
开发者ID:leancloud,项目名称:satori,代码行数:19,代码来源:backdoor.py

示例12: activate_profiler

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def activate_profiler():
    if sys.version_info[0] == 3:  # PY3
        import builtins
    else:
        import __builtin__ as builtins
    if Options()['misc'].get('profile', False):
        # if profiler is activated, associate line_profiler
        Logger()('Activating line_profiler...')
        try:
            import line_profiler
        except ModuleNotFoundError:
            Logger()('Failed to import line_profiler.', log_level=Logger.ERROR, raise_error=False)
            Logger()('Please install it from https://github.com/rkern/line_profiler', log_level=Logger.ERROR, raise_error=False)
            return
        prof = line_profiler.LineProfiler()
        builtins.__dict__['profile'] = prof
    else:
        # otherwise, create a blank profiler, to disable profiling code
        builtins.__dict__['profile'] = lambda func: func
        prof = None
    return prof 
开发者ID:Cadene,项目名称:bootstrap.pytorch,代码行数:23,代码来源:run.py

示例13: setup_environment

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def setup_environment():
    """Ensures that the environmental variable RAFCON_LIB_PATH is existent
    """
    # The RAFCON_LIB_PATH points to a path with common RAFCON libraries
    # If the env variable is not set, we have to determine it.
    if not os.environ.get('RAFCON_LIB_PATH', None):
        rafcon_library_path = resources.get_data_file_path("rafcon", "libraries")
        if rafcon_library_path:
            os.environ['RAFCON_LIB_PATH'] = rafcon_library_path
        else:
            logger.warning("Could not find root directory of RAFCON libraries. Please specify manually using the "
                           "env var RAFCON_LIB_PATH")

    # Install dummy _ builtin function in case i18.setup_l10n() is not called
    if sys.version_info >= (3,):
        import builtins as builtins23
    else:
        import __builtin__ as builtins23
    if "_" not in builtins23.__dict__:
        builtins23.__dict__["_"] = lambda s: s 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:22,代码来源:start.py

示例14: _find_non_builtin_globals

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def _find_non_builtin_globals(source, codeobj):
    import ast

    try:
        import __builtin__
    except ImportError:
        import builtins as __builtin__

    vars = dict.fromkeys(codeobj.co_varnames)
    return [
        node.id
        for node in ast.walk(ast.parse(source))
        if isinstance(node, ast.Name)
        and node.id not in vars
        and node.id not in __builtin__.__dict__
    ] 
开发者ID:pytest-dev,项目名称:execnet,代码行数:18,代码来源:gateway.py

示例15: install_dummy

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import __dict__ [as 别名]
def install_dummy(self):
        # For when translation is not desired or not available
        self.translations = { None: {} }
        __builtin__.__dict__['_'] = lambda x: unicode(x).replace(ur'\"', u'"').replace(u'{CR}', u'\n')	# Promote strings to Unicode for consistency 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:6,代码来源:l10n.py


注:本文中的__builtin__.__dict__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。