Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python-if类eventListener语法树_Python_Sublimetext - Fatal编程技术网

Python-if类eventListener语法树

Python-if类eventListener语法树,python,sublimetext,Python,Sublimetext,我是Python3.3新手,目前正在开发SublimiteText3插件 我希望我的插件只适用于特定的文件类型;说*.txt 到目前为止,我有如下代码: import sublime, sublime_plugin, socket class MarkdownLiveCommand(sublime_plugin.TextCommand): def run(self,view): do-things class MyEventListener1(sublime_pl

我是Python3.3新手,目前正在开发SublimiteText3插件

我希望我的插件只适用于特定的文件类型;说*.txt

到目前为止,我有如下代码:

import sublime, sublime_plugin, socket

class MarkdownLiveCommand(sublime_plugin.TextCommand):
    def run(self,view):  
        do-things

class MyEventListener1(sublime_plugin.EventListener):
    def on_modified_async(self,view):
        do-things

class MyEventListener2(sublime_plugin.EventListener):
    def on_load_async(self,view):
        do-things
所以,我试过了

import sublime, sublime_plugin, socket

if False:

    class MarkdownLiveCommand(sublime_plugin.TextCommand):
        def run(self,view):  
            do-things

    class MyEventListener1(sublime_plugin.EventListener):
        def on_modified_async(self,view):
            do-things

    class MyEventListener2(sublime_plugin.EventListener):
        def on_load_async(self,view):
            do-things
即使错误,eventlisner也会继续工作

实际上,我不知道类在语法树中的行为,所以请告诉我 哪种方式才能达到我的目的


谢谢。

如果将if False改为while False,会发生什么?Nothing@MattDmo,while False会触发以下事件类