Op 2006-02-23, Roy Smith schreef <[EMAIL PROTECTED]>: > Bob Greschke <[EMAIL PROTECTED]> wrote: >>I miss being able to do something like this in Python >> >>1f (I = a.find("3")) != -1: >> print "It's here: ", I >>else: >> print "No 3's here" >> >>where I gets assigned the index returned by find() AND the if statement gets >>to do its job in the same line. Then you don't have to have another like >>that specifically gets the index of the "3". Is there a way to do this in >>Python? > > It is a deliberate and fundamental design decision in Python that > assignment is a statement, not an expression with side effects.
The only motivation I have heard for this decision is to easily find typo related bugs. I can hardly find that a fundamental design decision. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list