One idea which might be worth of considering is to use 'x' (create) mode while opening the file. This will raise FileExistsError if file is already existing.
Beware of .isnumeric expected behaviour as well:
try: with open(filename, 'xt') as f: # t for text mode, b for binary mode # do stuff except FileExistsError: # do other stuffAlso you may consider pepify/prettify the code using variable naming convetions and f-strings (
address_file = f'{date_prefix}-torlist.txt'
)Beware of .isnumeric expected behaviour as well:
>>> digits = '123' >>> numerics = '一二三' # '123'in Kanji >>> decimals = '1²' >>> digits.isnumeric() True >>> numerics.isnumeric() True >>> decimals.isnumeric() True
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.