Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.python > #4652

Re: [Python-de] Frage zum configparser

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From "Sven R. Kunze" <srkunze@mail.de>
Newsgroups de.comp.lang.python
Subject Re: [Python-de] Frage zum configparser
Date Wed, 18 Jan 2017 18:39:33 +0100
Lines 56
Message-ID <mailman.7.1484761182.9761.python-de@python.org> (permalink)
References <o5o87h$q2s$1@tota-refugium.de> <51b2b379-bd06-6e01-68f6-ac7480f35e1d@mail.de>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de RmfL3DAlvgbCVhzDMZpaXw+l1qVXETwNRSuFrDPbIvmA==
Return-Path <srkunze@mail.de>
X-Original-To python-de@python.org
Delivered-To python-de@mail.python.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde201610; t=1484761174; bh=jnErTceSPRblklc2lnvBN9ozBoY9bEJzm3NkQAKFabQ=; h=Subject:To:References:From:Date:In-Reply-To:From; b=jYLWuWRgPMgzARUAJJlfd2t7E0rPV6t28pCSWcmO3TjZiUs2kvafh5dJ+tY0zoZ7V 0BAcnlBLNiw/MUvRKN6RgxjL+N1jiDWX/PpEhEng3MhzKSesl6LjuF+LE8IjNEmK2T To92Y6thzm1xciZylR2QMTt+zSLsp/HPDJtY88B8=
In-Reply-To <o5o87h$q2s$1@tota-refugium.de>
X-purgate clean
X-purgate This mail is considered clean (visit http://www.eleven.de for further information)
X-purgate-type clean
X-purgate-Ad Categorized by eleven eXpurgate (R) http://www.eleven.de
X-purgate This mail is considered clean (visit http://www.eleven.de for further information)
X-purgate clean
X-purgate-size 1111
X-purgate-ID 154282::1484761173-0000088C-288C5CBD/0/0
X-Spam-Status No, score=-2.9 required=10.0 tests=ALL_TRUSTED,BAYES_00, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.1
X-Spam-Checker-Version SpamAssassin 3.4.1 (2015-04-28) on spamassassin01.mail.de
X-BeenThere python-de@python.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Die Deutsche Python Mailingliste <python-de.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-de/>
List-Post <mailto:python-de@python.org>
List-Help <mailto:python-de-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <51b2b379-bd06-6e01-68f6-ac7480f35e1d@mail.de>
X-Mailman-Original-References <o5o87h$q2s$1@tota-refugium.de>
Xref csiph.com de.comp.lang.python:4652

Show key headers only | View raw


Hi Manfred,

dies ist die Implementierungvon ConfigParser.read:

<code>
         if isinstance(filenames, str):
             filenames = [filenames]
         read_ok = []
         for filename in filenames:
             try:
                 with open(filename, encoding=encoding) as fp:
                     self._read(fp, filename)
             except OSError:
                 continue
             read_ok.append(filename)
         return read_ok
</code>


Wie du siehst, wird dort mit einem ContextManager "with" gearbeitet und 
dieser schließt die Datei am Ende der Verarbeitung.


Sven

On 18.01.2017 18:21, Manfred Gil wrote:
> Hallo Liste,
>
> kleine Frage zum configparser,
>
> <code>
> conpar = configparser.ConfigParser()
>
> conpar.read('config.ini')
>
> # Einlesen der Daten
>
> </code>
>
> muß ich die Datei "config.ini" nicht irgendwie wieder schließen?
> in der Doku habe ich nix dazu gefunden.
> Oder geschieht diese nach dem Einlesen automatisch durch
> den configparser?
>
>
> Danke für eine kurze Info
>
> Gruß
> Manfred
>
>
>
>
>
>

Back to de.comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Frage zum configparser Manfred Gil <manfred-gil@t-online.de> - 2017-01-18 17:21 +0000
  Re: [Python-de] Frage zum configparser "Sven R. Kunze" <srkunze@mail.de> - 2017-01-18 18:39 +0100
    Re: [Python-de] Frage zum configparser Manfred Gil <manfred-gil@t-online.de> - 2017-01-18 17:56 +0000
  Re: [Python-de] Frage zum configparser "Diez B. Roggisch" <deets@web.de> - 2017-01-18 18:35 +0100
    Re: [Python-de] Frage zum configparser Manfred Gil <manfred-gil@t-online.de> - 2017-01-18 17:55 +0000
  Re: [Python-de] Frage zum configparser Arnold Krille <arnold@arnoldarts.de> - 2017-01-18 22:45 +0100
    Re: [Python-de] Frage zum configparser Manfred Gil <manfred-gil@t-online.de> - 2017-01-19 17:53 +0000
      Re: [Python-de] Frage zum configparser Arnold Krille <arnold@arnoldarts.de> - 2017-01-19 22:02 +0100
        Re: [Python-de] Frage zum configparser Manfred Gil <manfred-gil@t-online.de> - 2017-01-20 18:57 +0000
          Re: [Python-de] Frage zum configparser "Sven R. Kunze" <srkunze@mail.de> - 2017-01-20 20:32 +0100
            Re: [Python-de] Frage zum configparser Manfred Gil <manfred-gil@t-online.de> - 2017-01-21 15:44 +0000
  Re: [Python-de] Frage zum configparser "Sven R. Kunze" <srkunze@mail.de> - 2017-01-19 15:33 +0100

csiph-web