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


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

Re: [Python-de] War die Idee mit Iteratoren/Generatoren wirklich so super?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Stefan Behnel <python-de@behnel.de>
Newsgroups de.comp.lang.python
Subject Re: [Python-de] War die Idee mit Iteratoren/Generatoren wirklich so super?
Date Tue, 25 Jul 2017 12:23:36 +0200
Lines 16
Message-ID <mailman.23.1500978225.3037.python-de@python.org> (permalink)
References <392f5a95-defa-0f3d-0f1a-d0b554c2fa34@thomas-guettler.de> <453333fe-6382-427e-8837-94d3ece32bcc@procoders.net> <cd8e260e-eaf9-133c-49e0-c5d240ef7d28@behnel.de>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de GmAJk7laehQX94S1jVni8wMXIJtFeQPx/TZPlOgH0MOw==
Return-Path <python-de@behnel.de>
X-Original-To python-de@python.org
Delivered-To python-de@mail.python.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; t=1500978218; l=405; s=domk; d=behnel.de; h=Content-Transfer-Encoding:Content-Language:Content-Type:In-Reply-To: MIME-Version:Date:References:To:Subject:From; bh=T3qyLBuxE5nUkeKUN9qaA8rMZHLKaDbbmANXGsMwr70=; b=olGqhIVJZsWyvi1q52HAtH41Jn6x92a0Qs816DfFCDc2ZRGbwtpKEoUpL9CdLQ7WsO rw+KAIW+n1TipQrNvTCf6dknouGaWTW3gdgWRlT0hYBLpAHXZsyUFkU/KR1UfmBEfHzM /SP1nP3gXer7BbES1xBS0ffa2eAziOu5FyrFg=
X-RZG-AUTH :E1MMdFW4b++AXZOTwA41DOYM0Dv9LNWvavC/fJZqSuoXq8/b35jbpozFABqPas32JtEoDqV0c6foMkqRyrY+/G6bnnMKO7wYZ1El
X-RZG-CLASS-ID mo00
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1
In-Reply-To <453333fe-6382-427e-8837-94d3ece32bcc@procoders.net>
Content-Language de-DE
X-BeenThere python-de@python.org
X-Mailman-Version 2.1.24
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 <cd8e260e-eaf9-133c-49e0-c5d240ef7d28@behnel.de>
X-Mailman-Original-References <392f5a95-defa-0f3d-0f1a-d0b554c2fa34@thomas-guettler.de> <453333fe-6382-427e-8837-94d3ece32bcc@procoders.net>
Xref csiph.com de.comp.lang.python:4853

Show key headers only | View raw


Achim Domma schrieb am 25.07.2017 um 11:35:
> def worker_factory():
>     # hier steht der setup code
>     con = open_connection()
> 
>     def worker(doc):
>         return mache_etwas(doc, con)
>     yield worker
> 
>     # teardown code
>     con.close()

Und wenn du daran jetzt noch einen Dekorator "@contextlib.contextmanager"
setzt, dann wird das Ganze auch noch so richtig sauber in with-Blöcken nutzbar.

Stefan

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


Thread

Re: [Python-de] War die Idee mit Iteratoren/Generatoren wirklich so super? Stefan Behnel <python-de@behnel.de> - 2017-07-25 12:23 +0200

csiph-web