Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Stefan Behnel 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: References: <392f5a95-defa-0f3d-0f1a-d0b554c2fa34@thomas-guettler.de> <453333fe-6382-427e-8837-94d3ece32bcc@procoders.net> 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: 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 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