On Feb 22, 1:16 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote:
> On Fri, 22 Feb 2008 08:19:07 -0800, Carl Banks wrote: > > (The perl example wasn't using an assignment operator.) > > Hmmm... I see. Obviously I didn't pretend to understand Perl well enough. > > (I assume you're ignoring the assignments $name = chop(\1) etc. Fair > enough.) > > [...] > > > I can't help but to think that a lot of people's distaste for this > > natural way to write certain logic is simply defensiveness about one > > minor little thing that Python doesn't support (without workarounds). > > But Python certainly does support set-and-test. You just have > to separate the set from the test with a newline: A single "set-and-test" operation is not equivalent to two consecutive operations, "set" and "test". > m = re.match(r"name=(.*)",line) # set > if m: # test > name = m.group(1).strip() For a single set-and-test the inconvenience is minimal, but stack a bunch of them together (even more if there are 'else' clauses in the mix) and the syntactic inefficiency becomes quite visible. George -- http://mail.python.org/mailman/listinfo/python-list