Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4801 > unrolled thread
| Started by | Chris Rebert <clp2@rebertia.com> |
|---|---|
| First post | 2011-05-06 00:08 -0700 |
| Last post | 2011-05-06 00:08 -0700 |
| 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: checking if a list is empty Chris Rebert <clp2@rebertia.com> - 2011-05-06 00:08 -0700
| From | Chris Rebert <clp2@rebertia.com> |
|---|---|
| Date | 2011-05-06 00:08 -0700 |
| Subject | Re: checking if a list is empty |
| Message-ID | <mailman.1228.1304665707.9059.python-list@python.org> |
On Thu, May 5, 2011 at 11:36 PM, Jabba Laci <jabba.laci@gmail.com> wrote:
> Hi,
>
> If I want to check if a list is empty, which is the more pythonic way?
Option (2), IMO.
> li = []
>
> (1) if len(li) == 0:
> ...
FYI, also equivalent:
if not len(li):
...
> or
> (2) if not li:
Cheers,
Chris
Back to top | Article view | comp.lang.python
csiph-web