當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。