Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #4335
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Christopher Arndt <chris@chrisarndt.de> |
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] Schleifen die ohne Durchlaufen des Schleifenkörpers beendet wurden |
| Date | Tue, 29 Mar 2016 14:48:47 +0200 |
| Lines | 75 |
| Message-ID | <mailman.148.1459255751.28225.python-de@python.org> (permalink) |
| References | <56F445C9.3000200@mail.de> <56F939CE.8050601@admin-box.com> |
| Mime-Version | 1.0 |
| Content-Type | multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4JmwBT70cJWrSDO30JnvGG9DOT2vB8Gt5" |
| X-Trace | news.uni-berlin.de ZXO9zZ47A33if0UPlNgsnQcMHEXRKI8wSqu8GrUosQNg== |
| Return-Path | <chris@chrisarndt.de> |
| X-Original-To | python-de@python.org |
| Delivered-To | python-de@mail.python.org |
| X-Virus-Scanned | Debian amavisd-new at mx1.0x20.eu |
| Openpgp | id=F0BA1EAE86651989C0A1C9901E0D97B33A4E1F31 |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 |
| In-Reply-To | <56F939CE.8050601@admin-box.com> |
| X-BeenThere | python-de@python.org |
| X-Mailman-Version | 2.1.21 |
| 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> |
| Xref | csiph.com de.comp.lang.python:4335 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Am 28.03.2016 um 16:03 schrieb Daniel Troeder:
> for item in list():
> print item
> if "item" not in locals():
> print "empty"
>
> Voraussetzung ist, dass der Variablenname ("item") nicht schon vorher im
> gleichen oder übergeordneten scope verwendet wird.
Dies ist aber in der Praxis m.E. schwer sicher zu stellen. Die sichere
Variante wäre also:
locals().pop('item', None)
for item in items:
...
if item in locals():
...
Wobei mir weiterhin dies besser gefällt, weil m.E. klarer:
item = object
for item in items:
...
if item is object:
...
Chris
Back to de.comp.lang.python | Previous | Next | Find similar
Re: [Python-de] Schleifen die ohne Durchlaufen des Schleifenkörpers beendet wurden Christopher Arndt <chris@chrisarndt.de> - 2016-03-29 14:48 +0200
csiph-web