Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #197005
| From | dieter.maurer@online.de |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: FileNotFoundError thrown due to file name in file, rather than file itself |
| Date | 2024-11-12 17:18 +0100 |
| Message-ID | <mailman.98.1731428667.4695.python-list@python.org> (permalink) |
| References | <26418.15836.335097.984240@ixdm.fritz.box> <ZzJ0eoWZds3xSKWn@cskk.homeip.net> <26419.32753.211549.746227@ixdm.fritz.box> |
Cameron Simpson wrote at 2024-11-12 08:17 +1100:
>On 11Nov2024 18:24, dieter.maurer@online.de <dieter.maurer@online.de> wrote:
>>Loris Bennett wrote at 2024-11-11 15:05 +0100:
>>>I have the following in my program:
>>> try:
>>> logging.config.fileConfig(args.config_file)
>>> config = configparser.ConfigParser()
>>> config.read(args.config_file)
>>> if args.verbose:
>>> print(f"Configuration file: {args.config_file}")
>>> except FileNotFoundError:
>>> print(f"Error: configuration file {args.config_file} not found. Exiting.")
>>
>>Do not replace full error information (including a traceback)
>>with your own reduced error message.
>>If you omit your "try ... except FileNotFoundError`
>>(or start the `except` clause with a `raise`), you
>>will learn where in the code the exception has been raised
>>and likely as well what was not found (Python is quite good
>>with such error details).
>
>Actually, file-not-found is pretty well defined - the except action
>itself is fine in that regard.
The original exception likely tells us which file was not found.
Back to comp.lang.python | Previous | Next | Find similar
Re: FileNotFoundError thrown due to file name in file, rather than file itself dieter.maurer@online.de - 2024-11-12 17:18 +0100
csiph-web