while (a=b()) ...

Tim Peters tim_one at email.msn.com
Wed May 12 03:02:09 EDT 1999


[/F, disguising what he really thinks <wink>]

> ...
> but I still claim that this whole issue is just a big
> time sink.  just READING a single post on this topic
> (including this one) takes more time than you'll
> ever spend typing:
>
>     while 1:
>         c = curs.fetchone()
>         if not c:
>             break
>         # process c
>
> instead of any sugared version of this idiom.
>
> ...and don't tell me that anyone smart enough to operate
> a contemporary computer cannot train her/his brain to
> quickly identify the above as an instance of a commonly
> used pattern, rather than a number of individual state-
> ments whose purpose needs to be carefully analyzed one
> by one...

You write it the right way, though!  Most everyone setting this up as a
strawman to knock down does their best to hide the important part, writing

    while 1:
        c = curs.fetchone()
        if not c: break
        # process c

instead.  That really is much harder to take in at a glance; but perhaps
they're trying to do Python a favor by demonstrating it only needs 3x as
many lines as C  <wink>.

> ...
> I've been reading this group since 1995, and I think I've seen them
> all.

Indeed, I've been reading it since its pre-Usenet mailing list incarnation,
and the debate was old before 1995 began.  You'd almost think that if Guido
really cared, he would have changed it by now ...

> still, despite all those powerful arguments ("it's ugly", "it's in-
> efficient", "it abuses the while construct", "it's not like C", "it's
> soo verbose"), nobody has bothered to implement it.

Ka-Ping Yee did, several years ago.  The patch can still be fetched from

    http://www.lfw.org/python/

This is the

    while c from curs.fetchone():
        # process c

flavor, applying to "if" conditions too.  The debate hasn't really
progressed since then, but it has gotten ever more delightfully polarized.

and-what's-up-with-that-whitespace-business?!-ly y'rs  - tim






More information about the Python-list mailing list