Queer European MD passionate about IT
Explorar o código

Append to `secrets` file instead of overwriting

Davte %!s(int64=5) %!d(string=hai) anos
pai
achega
24482aecbc
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      examples/a_simple_bot.py

+ 2 - 2
examples/a_simple_bot.py

@@ -166,9 +166,9 @@ def _main():
         simple_bot_token = input("Enter bot token:\t\t")
         with open(
             f'{path}/secrets.py',
-            'w'
+            'a'  # Append to file, create if it does not exist
         ) as secrets_file:
-            secrets_file.write(f'simple_bot_token = "{simple_bot_token}"')
+            secrets_file.write(f'simple_bot_token = "{simple_bot_token}"\n')
 
     # Set logging preferences
     log_formatter = logging.Formatter(