Я получаю сообщение об ошибке: «Ошибка типа: приведение к Unicode: нужна строка или буфер, свойство найдено». Я не уверен, что не так с этим способом предоставления информации через свойство
Соответствующий код MainApp.py
from constantsconfig import _Const
if not os.path.exists(_Const.CONFIG_DIRECTORY): //error happens on this line
os.makedirs(_Const.CONFIG_DIRECTORY)
Соответствующий код constantsconfig.py
import os
def constant(f):
def fset(self, value):
raise TypeError
def fget(self):
return f()
return property(fget, fset)
class _Const(object):
@constant
def MAIN_CRON_JOB_ID(self):
return "MAIN_CRON_JOB_ID"
@constant
def DOWNLOAD_PHOTOS_INTERVAL_IN_MINUTES(self):
return 15
@constant
def BASE_API_URL(self):
return "http://example.com/file.php"
@constant
def API_KEY_RASPBERRIES(self):
return "fasd79f97fsfa80f809f809fasd890fsda76fds5f54ds465fdas456"
Сообщение об ошибке
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2018.1\helpers\pydev\pydevd.py", line 1664, in <module>
main()
File "C:\Program Files\JetBrains\PyCharm 2018.1\helpers\pydev\pydevd.py", line 1658, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm 2018.1\helpers\pydev\pydevd.py", line 1068, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:/_Data_/MainApp/RaspberriPi/_App/mainapp.py", line 192, in <module>
if not os.path.exists(_Const.CONFIG_DIRECTORY):
File "C:\_Data_\MainApp\RaspberriPi\_App\venv\lib\genericpath.py", line 26, in exists
os.stat(path)
TypeError: coercing to Unicode: need string or buffer, property found