Ifs and assignments

Roy Smith roy at panix.com
Thu Jan 2 23:00:49 EST 2014


In article <mailman.4824.1388721334.18130.python-list at python.org>,
 Chris Angelico <rosuav at gmail.com> wrote:

> On Fri, Jan 3, 2014 at 2:33 PM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
> > Personally, I find it hard to care about assignment as an expression. I find
> > the obvious C-inspired syntax terrible, as it is too easy to mistakenly use
> > == instead of = or visa versa:
> 
> Python has similar problems, though. It's inherent to the nature of
> symbolic languages.
> 
> a = (1, 2, 3)
> b = {1, 2, 3}
> 
> In many fonts, it's hard to tell one from the other without peering.
> Do people decry set literal notation in favour of explicitly writing
> the word "set"? No; and I think most of us agree that it's better to
> have the symbols. At least with == vs = there's a length difference. I
> don't think it's C's fault or problem that equality and assignment
> look similar and can be used in the same places, any more than it's a
> problem to have assignment and subtraction differ by only one stroke:
> 
> a - (1, 2, 3)
> 
> Is that confusingly similar to assignment?
> 
> ChrisA

I do this all the time:

t0 = time.time()
[some code]
t1 = time.time()
dt = t1 = t0   # <-- spot the typo?



More information about the Python-list mailing list