if <assignment>:

John Roth johnroth at ameritech.net
Wed Nov 27 14:43:21 EST 2002


"Dave Brueck" <dave at pythonapocrypha.com> wrote in message
news:mailman.1038407739.29313.python-list at python.org...
> On Wed, 27 Nov 2002 maney at pobox.com wrote:
>
> > Dave Brueck <dave at pythonapocrypha.com> wrote:
> > > proof that the language is broken in that area. We don't say, "Is
Tuesday
> > > today?" or "Is 5 your age?", either. :)
> >
> > Is it Tuesday today?
>
> Definitely not equivalent (hint: the 'today' in your version is
optional).
>
> > The other one is not the most common form, but I don't have any
trouble
> > at all imagining using it
>
> Perhaps, but that's not the point - an aspect of a language that the
> programmer has to think twice about, or be especially careful about,
or is
> encouraged to think about in an unnatural way ought to have
significant
> benefit to make it worthwhile. IMO the desire for if-assignment in C
is
> driven in part by a desire to fit more on the screen; Python code is
more
> vertically compact so I don't miss that feature as much.

The occasion for assignment in expressions occurs much more in C because
of the way the standard library is designed: error and exception cases
are
scattered among the valid data related returns from many functions, and
it
is quite common to want to capture the result of a function in case it
is
valid, and test it in case it's an error, in the same function call.

This happens much less in Python. IMNSHO, it shouldn't happen at all
in any well designed language.

John Roth






More information about the Python-list mailing list