inline assignments in conditionals

Laura Creighton lac at strakt.com
Sat Apr 27 16:37:00 EDT 2002


Jeremy:
[snip]
> Writing things that way is really unnatural, at least for English
> speakers.  It makes the intent of the code harder to understand (at
> least for me).  For example, if you were talking to a friend, you
> wouldn't say:
> 
>    "If today is Sunday, I'm going to go shopping"
> 
> but rather:
> 
>    "If Sunday is today, I'm going to go shopping"

Interesting.  I would never use the second construct, and I use the
first one all the time.  I wonder if this is a difference between
people whose first language is English, and some for whom it was not.
I don't think that anybody has had any trouble understanding me when I
say 'If today is Saturday, then we are going to the concert house,
otherwise we are going to hack.'  But then I have been writing
if 0 == x for a long time as well.  (It was great -- Borodin Quartet
playing Sjostakovitj and Beethoven, by the way.)

Laura Creighton





More information about the Python-list mailing list