Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104999 > unrolled thread
| Started by | Joaquin Alzola <Joaquin.Alzola@lebara.com> |
|---|---|
| First post | 2016-03-16 10:28 +0000 |
| Last post | 2016-03-16 10:28 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
RE: empty clause of for loops Joaquin Alzola <Joaquin.Alzola@lebara.com> - 2016-03-16 10:28 +0000
| From | Joaquin Alzola <Joaquin.Alzola@lebara.com> |
|---|---|
| Date | 2016-03-16 10:28 +0000 |
| Subject | RE: empty clause of for loops |
| Message-ID | <mailman.187.1458124117.12893.python-list@python.org> |
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=lebara.com@python.org] On Behalf Of Sven R. Kunze
Sent: 16 March 2016 10:23
To: Python List <python-list@python.org>
Subject: empty clause of for loops
Hi,
a colleague of mine (I write this mail because I am on the list) has the following 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 contact the sender immediately upon receipt.
Back to top | Article view | comp.lang.python
csiph-web