Sujet : Re: FileNotFoundError thrown due to file name in file, rather than file itself
De : rob.cliffe (at) *nospam* btinternet.com (Rob Cliffe)
Groupes : comp.lang.pythonDate : 12. Nov 2024, 22:04:02
Autres entêtes
Message-ID : <mailman.103.1731445532.4695.python-list@python.org>
References : 1 2 3 4 5
User-Agent : Mozilla Thunderbird
On 12/11/2024 08:52, Loris Bennett via Python-list wrote:
Cameron Simpson<cs@cskk.id.au> writes:
>
Generally you should put a try/except around the smallest possible
piece of code.
That is excellent advice.
Best wishes
Rob Cliffe
So:
>
config = configparser.ConfigParser()
try:
config.read(args.config_file)
except FileNotFoundError as e:
print(f"Error: configuration file {args.config_file} not found: {e}")
>
>