當前位置: 首頁>>代碼示例>>Python>>正文


Python IPShellEmbed.set_dummy_mode方法代碼示例

本文整理匯總了Python中IPython.Shell.IPShellEmbed.set_dummy_mode方法的典型用法代碼示例。如果您正苦於以下問題:Python IPShellEmbed.set_dummy_mode方法的具體用法?Python IPShellEmbed.set_dummy_mode怎麽用?Python IPShellEmbed.set_dummy_mode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在IPython.Shell.IPShellEmbed的用法示例。


在下文中一共展示了IPShellEmbed.set_dummy_mode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ipshell

# 需要導入模塊: from IPython.Shell import IPShellEmbed [as 別名]
# 或者: from IPython.Shell.IPShellEmbed import set_dummy_mode [as 別名]
    ipshell('***In foo(). Try @whos, or print s or m:')
    print 'foo says m = ',m

def bar(n):
    s = 'eggs'
    ipshell('***In bar(). Try @whos, or print s or n:')
    print 'bar says n = ',n
    
# Some calls to the above functions which will trigger IPython:
print 'Main program calling foo("eggs")\n'
foo('eggs')

# The shell can be put in 'dummy' mode where calls to it silently return. This
# allows you, for example, to globally turn off debugging for a program with a
# single call.
ipshell.set_dummy_mode(1)
print '\nTrying to call IPython which is now "dummy":'
ipshell()
print 'Nothing happened...'
# The global 'dummy' mode can still be overridden for a single call
print '\nOverriding dummy mode manually:'
ipshell(dummy=0)

# Reactivate the IPython shell
ipshell.set_dummy_mode(0)

print 'You can even have multiple embedded instances:'
ipshell2()

print '\nMain program calling bar("spam")\n'
bar('spam')
開發者ID:acaballero6270,項目名稱:py4science,代碼行數:33,代碼來源:ip_embed.py


注:本文中的IPython.Shell.IPShellEmbed.set_dummy_mode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。