Program efficiency vs user experience. Python Ancestor app Bit of a basic question but I was creating a ancestor/family tree app thingy (haven't really worked out the details) and I wrote a small start-up program (seen below) which checks the AppData directory exists and the config file exist (consisting of the number of tree and their respective names).
I was wondering if it's better to include the code that updates the config file at the beginning of runtime EVERY TIME or not since its only there in case the user accidently changes something:
import json
import os

AncestoryDir = os.getenv(&quot;APPDATA&quot;) + &quot;\Ancestry&quot;
ConfigFile = AncestoryDir + &quot;\CONFIG.ini&quot;

# Make Ancestory Directory
if not os.path.exists(AncestoryDir):
    os.makedirs(AncestoryDir)

# Update Config.ini File
CONFIGTree = {&quot;Tree Count&quot;: None, &quot;Tree's&quot;: []}
for File in os.scandir(AncestoryDir):
    if File.is_file():
        Tree, Suffix = File.name.split(&quot;.&quot;)
        if Suffix == &quot;json&quot;:
            CONFIGTree[&quot;Tree's&quot;].append(Tree)
CONFIGTree[&quot;Tree Count&quot;] = len(CONFIGTree[&quot;Tree's&quot;])
with open(ConfigFile, &quot;w&quot;) as JSON:
    json.dump(CONFIGTree, JSON, indent = 4)

Main File:
import os

os.system(&quot;python Ancestory.py&quot;)
#Other Stuff

As you can see it updates the config file EVERY TIME and im not sure if its worth it. Any thoughts or suggestions are appreciated.
Note:
Please don't tell me about PEP-8, I'm well aware of it and I choose to ignore it out of pure idiocy (my choice)
Pathlib
AncestoryDir = os.getenv(&quot;APPDATA&quot;) + &quot;\Ancestry&quot;
ConfigFile = AncestoryDir + &quot;\CONFIG.ini&quot;

# Make Ancestory Directory
if not os.path.exists(AncestoryDir):
    os.makedirs(AncestoryDir)

can reduce to
ancestry_dir = Path(os.getenv('APPDATA')) / 'Ancestry'
config_file = ancestry_dir / 'CONFIG.ini'

ancestry_dir.mkdir(exist_ok=True)

Note:

pathlib grants you a cleaner, object-oriented method for path manipulation
it's spelled &quot;ancestry&quot;
with pathlib there's no need for a separate existence check
even if you kept your approach, you have an invalid escape \A that either needs to be double-escaped or exist in a raw string

pathlib applies to your other code, too. Also it's spelled &quot;Trees&quot;, not &quot;Tree's&quot;.
PEP8
Protest thou may, but this actually matters. Coding is a form of communication, and the less we successfully communicate with other coders, the less they're able to help and work with us.