Hello All,

I expect it is far to late for this, and I still wanted to make the issue known.

The assert statement is one of the few remaining Python statements
where it (1) does not use parenthesis and (2) takes multiple
arguments.  This leads to the common, hard to detect, programming
error:
      assert(rarelyHappens  > 0 , "Hyperdrive component needs replacement!")
which is equivalent to:
      assert True
because the programmer forgot to remove parenthesis for assert statements.

It would be great to change assert from:
     assert_stmt        ::=     "assert" expression ["," expression]
To:
     assert_stmt        ::=     "assert" expression ["as" expression]

Which would make only one way to make an assert statement.

+ One less exception to remember
+ Fewer "fail silently" errors
+ One less place where commas outside parenthesis are used.
(try/except and print just got fixed).
- Way too late:  I wish I had noticed months ago.
- Need to patch 2to3, documentation, etc.

There may be a problem in tuples evaluating as expressions with this
naive fix; it's unclear to
my little brain if a bare expression_list can be reached from
expression.  That is, would
  assert "tuple","implied" as "Message"
or
  assert neverHappen > 0, "Programmer used 2.5 syntax here"
be valid statements?

In summary, I know that the current assert syntax is wrong.  I know
what it should look like.
I do not know if the implementation details of parenthesized tuples
make this difficult.   I
should have noticed it a year ago.

Charles Merriam
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to