| Deutsch English Français Italiano |
|
<mailman.99.1731433661.4695.python-list@python.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!fu-berlin.de!uni-berlin.de!not-for-mail
From: Karsten Hilbert <Karsten.Hilbert@gmx.net>
Newsgroups: comp.lang.python
Subject: Re: FileNotFoundError thrown due to file name in file, rather than
file itself
Date: Tue, 12 Nov 2024 18:47:37 +0100
Lines: 46
Sender: <karsten.hilbert@gmx.net>
Message-ID: <mailman.99.1731433661.4695.python-list@python.org>
References: <26418.15836.335097.984240@ixdm.fritz.box>
<ZzJ0eoWZds3xSKWn@cskk.homeip.net>
<mailman.94.1731359879.4695.python-list@python.org>
<87o72kygts.fsf@zedat.fu-berlin.de>
<ZzOUuVy6s0Ao3ZKq@hermes.hilbert.loc>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de mqu3KSmafezqV4T9fE8+RArCKkBLAMTpNb2lNTiwAEqQ==
Cancel-Lock: sha1:49hFnvqDb9CsQZMbb/NuCuWCj6Q= sha256:bPbR+HoDU/KvhhKO9+xDabs5sMWtJ+do2433Zc3CmXs=
Return-Path: <karsten.hilbert@gmx.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmx.net header.i=karsten.hilbert@gmx.net
header.b=WQn7gFqq; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(e.g.': 0.05;
'received:212.227': 0.07; 'subject:name': 0.07; 'gpg': 0.09;
'karsten': 0.09; 'parse': 0.09; 'schrieb': 0.09; 'well:': 0.09;
'import': 0.15; '1713': 0.16; 'bennett': 0.16; 'directory,': 0.16;
'filename': 0.16; 'found:': 0.16; 'given.': 0.16; 'instance':
0.16; 'iterable': 0.16; 'python3': 0.16; 'specify': 0.16; 'to:addr
:python-list': 0.20; 'returns': 0.22; 'subject:file': 0.22;
'cannot': 0.25; '>>>': 0.28; 'fact': 0.28; 'output': 0.28;
'error': 0.29; 'seem': 0.31; 'module': 0.31; 'tue,': 0.31;
'empty': 0.32; 'header:In-Reply-To:1': 0.34; 'handling': 0.35;
'following': 0.35; 'files': 0.36; "skip:' 10": 0.37; 'example':
0.37; 'file': 0.38; 'way': 0.38; 'read': 0.38; 'list': 0.39;
'single': 0.39; 'files.': 0.40; 'potential': 0.60; 'method': 0.61;
'skip:h 10': 0.61; 'your': 0.64; 'produce': 0.65; 'above,': 0.70;
'knowing': 0.71; 'reliable': 0.74; 'subject: \n ': 0.84;
'subject:than': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net;
s=s31663417; t=1731433658; x=1732038458; i=karsten.hilbert@gmx.net;
bh=NpXcUG9GVOihKcgcQbYyjVSY5SVaZk3AMsMhlYXIgS0=;
h=X-UI-Sender-Class:Date:From:To:Subject:Message-ID:References:
MIME-Version:Content-Type:In-Reply-To:Content-Transfer-Encoding:
cc:content-transfer-encoding:content-type:date:from:message-id:
mime-version:reply-to:subject:to;
b=WQn7gFqqHqvijM5XmRc9Afij1RWGSsevJW1ACM6o7zupahqvFx3qpzF4AXY/VAoj
QzZdOFMAu27muqUfaRBMyXuQuouB8C+of34GwLjHjwtdTQwkieWbS7BexqaOyK6Vq
CXlR62ojn+s/UeKn+xQfxxKkx31MmyGoQErMeXp123k3gNjW7SI72atnD9RMqbtjR
qQ0w/hS5PzRqZEmaIxKC0o7lbyE9OYsvav+TXMa2Odt9mZ9eRqjzRKzisgMs0OjI2
H5VTTeZsoNIFzPU1wZDnIIHUhTgHH+SgEnYG9x9Ipjw5jnfUV7cLzxldw40geghl0
6u1ne0zQR7IBNheeSg==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Content-Disposition: inline
In-Reply-To: <87o72kygts.fsf@zedat.fu-berlin.de>
Ma_X_il-Followup-to: d
Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net
Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net
X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net
X-Pri_X_ority: 2 (High)
X-Provags-ID: V03:K1:Q/beD+w1V11oQ9dK9ovu4yrjY+ZFdaGlHeq57SE57ZpMOd3TNP2
jM6VEtFx2JyCLChXfKc4flIisHoT/g3DBOlu2uly8K6ShDRXOLn8lfrageogjG4QUT6/WXj
sfCgeAPOyKdlSB17KwS9g2DwunsgIPfw/0L2Ph+kmpxKBFcHgTvZhXBO8KHG7ebpECFrxh2
Lu0XwlDPBrbvxEDOclaUQ==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:Ia1h/dF5uTI=;U88P3QD9hLeR2kiyDxNUHIJZl8W
DJxw7Zz0RW00kwA+AQKoMA7KK5wyK3g4QjNu+9MhIm3hpBcDmObOi4kAuqzS31Tj/Qin3hzJH
tZMuBQyLPAX7Nwlu5M+78eLUPMtkC1fc1IO68QYhKF3icyIx/+fUKot3tHSZ5QUgu+ADifPy4
1rdISaRjxtS24ezp/XXuucwV9IVLwe1iE2yxfVA/wIvYLZVPC2JSwJGAi9l2xRUA1RD1op/ou
kCS++q5WCZtxGuVUeW/4d9xuz/m1Yj2h4By2BEd7+YzqOrryFU4K9/AdCUNJD257xFv5LPCqy
GOY7St/Vks0+ZTxuCaN9yaoGTKLm7taXk7rEl7pprmjsrzo8BNlwuxTGRy3a+1i3JGhbR8WZF
fLMueAZ/+8ETM+KfbankfDKvF0BAmsl4XeYwHnpyo0r4LOiKk58Yy1nCl/4EpsF4yqTJooIsa
4532JMVIRRl95cXUXstjfBHBBiQNSixp3hrWXYhqEJRi6mIn5xZHpOBflkXSlrKDrAniFrAiA
S2opS9dXBSlQ89I81VgzyR5uRSO9sOcbkK1FgrDxdIy3ClzMoNy8T7D58ZAP0tJ1f3/fTzBl9
Bton5Ve5dMr6S7IAVwV4MNaeit/PlylX/yNS/l6JqxgSiN9SAQ7uvlHfaWCRiEkNwY+kirjTG
7th3Uek3YwdaZdXEea1+E6zLMcsRtlgkDr5X/z+m5rz1U0sE/FzE74BMOgWoknSdIlfZfpFES
BchhCAPYMwnl7BqFxH/i2g3M/onBQBEkPrKScVkVDH5kubdrryGU1iznJ3iTZeeFJqNRe1+cq
cHqdUfvyxd/6MzH/KTOf+cKQ==
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <ZzOUuVy6s0Ao3ZKq@hermes.hilbert.loc>
X-Mailman-Original-References: <26418.15836.335097.984240@ixdm.fritz.box>
<ZzJ0eoWZds3xSKWn@cskk.homeip.net>
<mailman.94.1731359879.4695.python-list@python.org>
<87o72kygts.fsf@zedat.fu-berlin.de>
Bytes: 6912
Am Tue, Nov 12, 2024 at 09:52:31AM +0100 schrieb Loris Bennett via Python-=
list:
> Regarding your example above, if 'missingfile.py' contains the following
>
> import configparser
>
> config =3D configparser.ConfigParser()
>
> try:
> config.read('/foo/bar')
> except FileNotFoundError as e:
> print(f"Error: configuration file {config_file} not found: {e}")
>
> them
>
> python3 missingfile.py
>
> does not produce an any output for me and so does not seem to be a
> reliable way of handling the case where the config file does not exist.
Well:
>>> help(config.read)
Help on method read in module configparser:
read(filenames, encoding=3DNone) method of configparser.ConfigParser inst=
ance
Read and parse a filename or an iterable of filenames.
Files that cannot be opened are silently ignored; this is
designed so that you can specify an iterable of potential
configuration file locations (e.g. current directory, user's
home directory, systemwide directory), and all existing
configuration files in the iterable will be read. A single
filename may also be given.
Return list of successfully read files.
So, the very fact that it does not return any output AND
returns an empty list is the (intended) way of knowing the
error state.
Karsten
=2D-
GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B