two ideoms at one blow: line-reading and regexp-matching

logistix logstx at bellatlantic.net
Wed Feb 20 13:29:22 EST 2002


Your ideoms are only clearer if you've been poisoned by C.  Don't worry,
we've all been guilty of that at one point or another.  Too many languages
have been screwed up by trying to maintain some sort of C ideom status quo.

Someone who's never programmed before won't find your proposed syntax clear
at all.

--
-

"Russell Nelson" <nelson at crynwr.com> wrote in message
news:m2vgcs5hgf.fsf at desk.crynwr.com...
> There are two Python ideoms that bother me:
>
>     while 1:
>         line = file.readline()
>         if not line: break
>
> and:
>
>     matched = re.match(r'egexp(.*)', line)
>     if matched:
>         print matched.group(1)
>
> I'd really, really like it if you could do one(1) assignment within
> the boolean expression in a while and an if.  Like this:
>
>
>     while line = file.readline():
>
> and:
>
>     if matched = re.match(r'egexp(.*)', line):
>         print matched.group(1)
>
> I just think it would be easier to read programs if they could be
> written like this.  Should I write up a PEP or has this already been
> discussed and dismissed?
>
> --
> -russ nelson              http://russnelson.com | Crypto without a threat
> Crynwr sells support for free software  | PGPok | model is like cookies
> 521 Pleasant Valley Rd. | +1 315 268 1925 voice | without milk.
> Potsdam, NY 13676-3213  | +1 315 268 9201 FAX   |





More information about the Python-list mailing list