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


Python __main__.__dict__方法代码示例

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


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

示例1: complete

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ 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 __main__ [as 别名]
# 或者: from __main__ 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: runeval

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ import __dict__ [as 别名]
def runeval(self, expr, globals=None, locals=None):
        if globals is None:
            import __main__
            globals = __main__.__dict__
        if locals is None:
            locals = globals
        self.reset()
        sys.settrace(self.trace_dispatch)
        if not isinstance(expr, types.CodeType):
            expr = expr+'\n'
        try:
            return eval(expr, globals, locals)
        except BdbQuit:
            pass
        finally:
            self.quitting = 1
            sys.settrace(None) 
开发者ID:glmcdona,项目名称:meddle,代码行数:19,代码来源:bdb.py

示例4: RespondDebuggerState

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ import __dict__ [as 别名]
def RespondDebuggerState(self, state):
		globs = locs = None
		if state==DBGSTATE_BREAK:
			if self.debugger.curframe:
				globs = self.debugger.curframe.f_globals
				locs = self.debugger.curframe.f_locals
		elif state==DBGSTATE_NOT_DEBUGGING:
			import __main__
			globs = locs = __main__.__dict__
		for i in range(self.GetItemCount()-1):
			text = self.GetItemText(i, 0)
			if globs is None:
				val = ""
			else:
				try:
					val = repr( eval( text, globs, locs) )
				except SyntaxError:
					val = "Syntax Error"
				except:
					t, v, tb = sys.exc_info()
					val = traceback.format_exception_only(t, v)[0].strip()
					tb = None # prevent a cycle.
			self.SetItemText(i, 1, val) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:debugger.py

示例5: OnViewBrowse

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ import __dict__ [as 别名]
def OnViewBrowse( self, id, code ):
		" Called when ViewBrowse message is received "
		from pywin.mfc import dialog
		from pywin.tools import browser
		obName = dialog.GetSimpleInput('Object', '__builtins__', 'Browse Python Object')
		if obName is None:
			return
		try:
			browser.Browse(eval(obName, __main__.__dict__, __main__.__dict__))
		except NameError:
			win32ui.MessageBox('This is no object with this name')
		except AttributeError:
			win32ui.MessageBox('The object has no attribute of that name')
		except:
			traceback.print_exc()
			win32ui.MessageBox('This object can not be browsed') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:intpyapp.py

示例6: global_matches

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ 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

示例7: run

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ import __dict__ [as 别名]
def run(self, cmd, globals=None, locals=None):
        if globals is None:
            import __main__
            globals = __main__.__dict__
        if locals is None:
            locals = globals
        self.reset()
        sys.settrace(self.trace_dispatch)
        if not isinstance(cmd, types.CodeType):
            cmd = cmd+'\n'
        try:
            exec cmd in globals, locals
        except BdbQuit:
            pass
        finally:
            self.quitting = 1
            sys.settrace(None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:bdb.py

示例8: global_matches

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ 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, builtins.__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:awemulya,项目名称:kobo-predict,代码行数:23,代码来源:rlcompleter.py

示例9: global_matches

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ 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.

        """
        #print 'Completer->global_matches, txt=%r' % text # dbg
        matches = []
        match_append = matches.append
        n = len(text)
        for lst in [keyword.kwlist,
                    __builtin__.__dict__.keys(),
                    self.namespace.keys(),
                    self.global_namespace.keys()]:
            for word in lst:
                if word[:n] == text and word != "__builtins__":
                    match_append(word)
        return matches 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:completer.py

示例10: _get_globals

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ import __dict__ [as 别名]
def _get_globals():
    """Return current Python interpreter globals namespace"""
    if _get_globals_callback is not None:
        return _get_globals_callback()
    else:
        try:
            from __main__ import __dict__ as namespace
        except ImportError:
            try:
                # The import fails on IronPython
                import __main__
                namespace = __main__.__dict__
            except:
                namespace
        shell = namespace.get('__ipythonshell__')
        if shell is not None and hasattr(shell, 'user_ns'):
            # IPython 0.12+ kernel
            return shell.user_ns
        else:
            # Python interpreter
            return namespace
        return namespace 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:24,代码来源:pydev_umd.py

示例11: __setattr2

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ import __dict__ [as 别名]
def __setattr2( self, name, value ):     # "running" getattr
    # to allow assignments to ROOT globals such as ROOT.gDebug
      if not name in self.__dict__:
         try:
          # assignment to an existing ROOT global (establishes proxy)
            setattr( self.__class__, name, _root.GetCppGlobal( name ) )
         except LookupError:
          # allow a few limited cases where new globals can be set
            if sys.hexversion >= 0x3000000:
               pylong = int
            else:
               pylong = long
            tcnv = { bool        : 'bool %s = %d;',
                     int         : 'int %s = %d;',
                     pylong      : 'long %s = %d;',
                     float       : 'double %s = %f;',
                     str         : 'string %s = "%s";' }
            try:
               _root.gROOT.ProcessLine( tcnv[ type(value) ] % (name,value) );
               setattr( self.__class__, name, _root.GetCppGlobal( name ) )
            except KeyError:
               pass           # can still assign normally, to the module

    # actual assignment through descriptor, or normal python way
      return super( self.__class__, self ).__setattr__( name, value ) 
开发者ID:dnanexus,项目名称:parliament2,代码行数:27,代码来源:ROOT.py

示例12: complete

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ 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 not text.strip():
            if state == 0:
                return '\t'
            else:
                return None

        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:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:rlcompleter.py

示例13: run

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ import __dict__ [as 别名]
def run(self, cmd, globals=None, locals=None):
        if globals is None:
            import __main__
            globals = __main__.__dict__
        if locals is None:
            locals = globals
        self.reset()
        if isinstance(cmd, str):
            cmd = compile(cmd, "<string>", "exec")
        sys.settrace(self.trace_dispatch)
        try:
            exec(cmd, globals, locals)
        except BdbQuit:
            pass
        finally:
            self.quitting = True
            sys.settrace(None) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:bdb.py

示例14: run

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ import __dict__ [as 别名]
def run(self, cmd, globalsDict=None, localsDict=None, debug=True):
        """Starts a given command under debugger control"""
        if globalsDict is None:
            import __main__
            globalsDict = __main__.__dict__

        if localsDict is None:
            localsDict = globalsDict

        if not isinstance(cmd, types.CodeType):
            cmd = compile(cmd, "<string>", "exec")

        if debug:
            # First time the trace_dispatch function is called, a "base debug"
            # function has to be returned, which is called at every user code
            # function call. This is ensured by setting stop_everywhere.
            self.stop_everywhere = True
            sys.settrace(self.trace_dispatch)

        try:
            exec(cmd, globalsDict, localsDict)
            atexit._run_exitfuncs()
            self._dbgClient.progTerminated(0)
        except SystemExit:
            atexit._run_exitfuncs()
            excinfo = sys.exc_info()
            exitcode, message = self.__extractSystemExitMessage(excinfo)
            self._dbgClient.progTerminated(exitcode, message)
        except Exception:
            excinfo = sys.exc_info()
            self.user_exception(excinfo, True)
        finally:
            self.quitting = True
            sys.settrace(None) 
开发者ID:SergeySatskiy,项目名称:codimension,代码行数:36,代码来源:base_cdm_dbg.py

示例15: run

# 需要导入模块: import __main__ [as 别名]
# 或者: from __main__ import __dict__ [as 别名]
def run(self, cmd):
        import __main__
        dict = __main__.__dict__
        return self.runctx(cmd, dict, dict) 
开发者ID:glmcdona,项目名称:meddle,代码行数:6,代码来源:profile.py


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