Skip to content

Instantly share code, notes, and snippets.

@rupython
Created March 8, 2019 12:36
Show Gist options
  • Save rupython/6b52872cb85afe81139e77b0be5f7f07 to your computer and use it in GitHub Desktop.
Save rupython/6b52872cb85afe81139e77b0be5f7f07 to your computer and use it in GitHub Desktop.
From: Alexey
try:
##var
config.plugins.NewYear.delay
except NameError:
#var_exists = False
config.plugins.NewYear.delay.value_exists = False
weather_city = 1123200
open('/media/hdd/ClockToText_log.txt', 'a').write(str(weather_city)+'\n')
else:
#var_exists = True
config.plugins.NewYear.delay.value_exists = True
weather_city = config.plugins.NewYear.delay.value
open('/media/hdd/ClockToText_log.txt', 'a').write(str(weather_city)+'\n')
Итого не работает
Суть простая - если существует пеерменная config.plugins.NewYear.delay , то выполняется
#var_exists = True
config.plugins.NewYear.delay.value_exists = True
weather_city = config.plugins.NewYear.delay.value
open('/media/hdd/ClockToText_log.txt', 'a').write(str(weather_city)+'\n')
Если не существует переменная config.plugins.NewYear.delay, то выполняется
#var_exists = False
config.plugins.NewYear.delay.value_exists = False
weather_city = 1123200
open('/media/hdd/ClockToText_log.txt', 'a').write(str(weather_city)+'\n')
Однако не работает
Почему не работает - файл /media/hdd/ClockToText_log.txt не создается ни при каком раскладе, в файл /media/hdd/ClockToText_log.txt' ничего не пишется
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment