Path: csiph.com!goblin3!goblin.stu.neva.ru!news.tu-darmstadt.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Christopher Arndt Newsgroups: de.comp.lang.python Subject: Re: [Python-de] =?utf-8?q?Schleifen_die_ohne_Durchlaufen_des_Schleif?= =?utf-8?q?enk=C3=B6rpers_beendet_wurden?= Date: Fri, 25 Mar 2016 00:40:01 +0100 Lines: 82 Message-ID: References: <56F445C9.3000200@mail.de> <533CBF60-D919-4211-8155-ACC90B848839@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xd1siuNjPAFkq3m28q4HQeXj7EcTWSTK8" X-Trace: news.uni-berlin.de XKBXnGjIqUSstMSk+yOG1gXG+HnD8evoT0g/A9bUcXTA== Return-Path: 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: <533CBF60-D919-4211-8155-ACC90B848839@web.de> X-BeenThere: python-de@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Die Deutsche Python Mailingliste List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com de.comp.lang.python:4328 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --xd1siuNjPAFkq3m28q4HQeXj7EcTWSTK8 Content-Type: multipart/mixed; boundary="I9OgkC0EDd7cAdSCwAvbU0VkuKbVGWvIi" From: Christopher Arndt To: Die Deutsche Python Mailingliste Message-ID: <56F47AD1.5040008@chrisarndt.de> Subject: =?UTF-8?Q?Re:_[Python-de]_Schleifen_die_ohne_Durchlaufen_des_Schlei?= =?UTF-8?Q?fenk=c3=b6rpers_beendet_wurden?= References: <56F445C9.3000200@mail.de> <533CBF60-D919-4211-8155-ACC90B848839@web.de> In-Reply-To: <533CBF60-D919-4211-8155-ACC90B848839@web.de> --I9OgkC0EDd7cAdSCwAvbU0VkuKbVGWvIi Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Am 24.03.2016 um 23:46 schrieb Diez B. Roggisch: > Huh, im Zeitalter von ternary if=92s noch den OR-Trick ;) Der "OR-Trick" ist auch in Zeiten von "expr if expr else expr" noch des =F6fteren hilfreich weil oft k=FCrzer. Er ist ja eigentlich nur eine ande= re Form von "expr1 if expr1 else expr2" (wobei expr1 nur einmal evaluiert wird). Was man nicht mehr verwenden sollte, ist "expr and non-false-expr or expr= ". > Ich denke wenn wuerde ich das eher kapseln in ein >=20 > def loop_or_else(iterable, sideeffect): > looped =3D False > for item in iterable: > looped =3D True > yield item > if not looped: > sideeffect() Wenn man wei=DF, dass ein bestimmter Wert niemals ein Element des Iterables sein wird, kann man das auch so verk=FCrzen: i =3D SENTINEL for i in collection: do_item(i) if i =3D=3D SENTINEL: and_now_for_something_completely_different() Ist immerhin nur eine Zeile mehr als die usprl. geforderte L=F6sung. --I9OgkC0EDd7cAdSCwAvbU0VkuKbVGWvIi-- --xd1siuNjPAFkq3m28q4HQeXj7EcTWSTK8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Puzzled by the all these strange characters? Comment: See http://tinyurl.com/cehoa7 for an introduction Comment: to public key encryption and signing. iQIcBAEBCAAGBQJW9HrYAAoJEB4Nl7M6Th8xvKQP/0R7o17zdByoTYuYxG43T/cH OvV6JK94E2iYIsdGsHMuzxcp9HBawS9OjTJTdGV9HcdCBNBSRaeGTSU3UMWsp6nj 1xaZKMSjdRBYvKbOcDaGueUAndt99nXzSiOCU0aVEfbOFruKNOmYjPy/VWgxj3CJ id+YAvQCzsza211bOUuXXbN19y96Y4OW1oZkAc2A+G5FOqk61SyK0E3/3/wcg1bC bng1GGg03AGVDoJJbFmaEhLTJxpE6MLeBPS2/HGxe2b4gfig0f+K0rsoMDtuhddk DFlAZdErYsaWGfeag4Spj3NMqPN/DFV0Ssj17WkT0aFRptZ8evLLmAcrhLTeSTs0 GEsoCAFAqodYkccDLW9h0SRQCROZr1NikWW8Yp8EZjhXewZLNOtdkZeCuPapHpi8 SYiMFe0l+kX4X/k8UNE+Wvh0HGz4CLw7C3F89ktdwWrnlgPr2obGNp4O9W+eJJx0 R2jIXTVnasnF7KWn6aER/Kw3OThgPBl4MsSET5bd7UnD0T5PAIjXMeYDhw/2rqMm 9fz/MXl1T+ZtErWgUZEq4nBVfP09mfqkbMO2X73WFy9LlrHvRFFE/fT9TIS0Cc2m Su9xvHUrbwQ8LB7ilHXYIccd/JplRId8RGL9RN33+mI0P30QSRjL29p9qpCbHIgD 4uecExbr8SKkRCDnTrcx =CSM3 -----END PGP SIGNATURE----- --xd1siuNjPAFkq3m28q4HQeXj7EcTWSTK8--