How does the plug-in class access the variable and modules of the main program? For example, the main file:
# <main.py> PYTHON_VERSION = 3 if PYTHON_VERSION == 3: from urllib.parse import urlencode, quote # python 3 else: from urllib import urlencode, quote # python 2.7 import mymodule The class in the mymodule module does not see the global variable PYTHON_VERSION:
# <mymodule.py> class works: global PYTHON_VERSION def get_html(self): print (PYTHON_VERSION) # ошибка: name 'PYTHON_VERSION' is not defined neither quote from urllib :
# <mymodule.py> class works: PYTHON_VERSION = 3 # ... def get_html(self): if self.PYTHON_VERSION == 3: url = self.URLhtml + quote(self.title) # python 3 else: url = self.URLhtml + self.title.encode('utf-8') # python 2.7 # ошибка: name 'quote' is not defined In one file, without putting it into the module and classes, just functions, everything worked.