Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Joaquin Alzola Newsgroups: comp.lang.python Subject: RE: empty clause of for loops Date: Wed, 16 Mar 2016 10:28:28 +0000 Lines: 38 Message-ID: References: <56E93413.6090108@mail.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de yIxXopTaNo7F/J/Ta5zeEgog5WJqRusg24VZ+faMHFWA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'else:': 0.03; 'clause': 0.07; 'issue:': 0.09; 'python': 0.10; 'message-----': 0.15; '2016': 0.16; 'list)': 0.16; 'loops': 0.16; 'privilege.': 0.16; 'pythonic': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:[ 60': 0.16; 'to:name:python list': 0.16; 'to:2**1': 0.21; 'header:In-Reply-To:1': 0.24; 'this.': 0.28; 'url:mailman': 0.30; 'code': 0.30; 'url:python': 0.33; 'skip:- 10': 0.34; 'url:listinfo': 0.34; 'this?': 0.34; 'list': 0.34; 'best,': 0.35; 'sent:': 0.35; 'could': 0.35; 'mine': 0.35; 'something': 0.35; 'subject:': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'charset:us-ascii': 0.37; 'doing': 0.38; 'hi,': 0.38; 'from:': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'more': 0.63; 'march': 0.64; 'contact': 0.66; 'python-list': 0.66; 'subject': 0.70; 'disclose': 0.71; 'colleague': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lebara.onmicrosoft.com; s=selector1-lebara-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=MXYqcWhyM0TC8/CoicFxOEi7YCWYaHsNVgVJJ/P7Kq4=; b=bsS8h6XXQpIBPSWplF4aoFUlh3yc0SF39JI7rXmthpA31IVZs2i3I/3pDscnZzkV5nxFmuv1wHLEg39haFPrUJvoUo4fKpo3QBJrvHz0N2XDyJ8TYh6QFnGx1YWTbY4EXNStwAxkc+OM0fpogQg04FFtLY/UtunjJmutFQ0rYk4= Thread-Topic: empty clause of for loops Thread-Index: AQHRf24RoWjQInuuMkWi96HH5hmmf59b3X+g In-Reply-To: <56E93413.6090108@mail.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: mail.de; dkim=none (message not signed) header.d=none;mail.de; dmarc=none action=none header.from=lebara.com; x-originating-ip: [165.225.80.111] x-ms-office365-filtering-correlation-id: c22c4cbf-13e0-4cfa-336f-08d34d85b72c x-microsoft-exchange-diagnostics: 1; DB5PR07MB1494; 5:MbHmbZ6Fy2RNSDdTxNth+c4i9AOnOTQ2r33bmmO65oXWJXX5D599Xjo9e8frdc8PY78RlCpjnJNVwaXuOln2L8KeAJgphK6TilHXKt1gQCfywNU91WJuvF0X2kwOqlm7MTDlukmerE4FvVUvZV46Aw==; 24:HRDVCO9V6hhQa32apCMdhHHW4J151lqXOjBLmKkH6LYrEBYxZmcHd51NE7ZeWIEHjugLlIs29zoIWVCE5jW+MfIfNMch7uCr2RZnOEtcGBc= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR07MB1494; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:DB5PR07MB1494; BCL:0; PCL:0; RULEID:; SRVR:DB5PR07MB1494; x-forefront-prvs: 08831F51DC x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(13464003)(74316001)(102836003)(10400500002)(1096002)(5001770100001)(5003600100002)(3846002)(33656002)(6116002)(107886002)(19580405001)(5004730100002)(92566002)(19580395003)(1220700001)(586003)(54356999)(81166005)(2950100001)(2906002)(5002640100001)(3280700002)(76576001)(2900100001)(5008740100001)(87936001)(122556002)(15975445007)(77096005)(76176999)(66066001)(86362001)(11100500001)(106116001)(189998001)(3660700001)(50986999); DIR:OUT; SFP:1102; SCL:1; SRVR:DB5PR07MB1494; H:DB5PR07MB1496.eurprd07.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM X-OriginatorOrg: lebara.com X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Mar 2016 10:28:28.8019 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d7093539-83cd-4991-b1b3-aacef74cf097 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR07MB1494 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104999 You could do something like ... If len(my_iterable) is not 0: for x in my_iterable: # do else: # do something else There should be a more code efficient way to do this. -----Original Message----- From: Python-list [mailto:python-list-bounces+joaquin.alzola=3Dlebara.com@p= ython.org] On Behalf Of Sven R. Kunze Sent: 16 March 2016 10:23 To: Python List Subject: empty clause of for loops Hi, a colleague of mine (I write this mail because I am on the list) has the fo= llowing issue: for x in my_iterable: # do empty: # do something else What's the most Pythonic way of doing this? Best, Sven -- https://mail.python.org/mailman/listinfo/python-list This email is confidential and may be subject to privilege. If you are not = the intended recipient, please do not copy or disclose its content but cont= act the sender immediately upon receipt.