PEP new assert idiom
Terry Hancock
hancock at anansispaceworks.com
Sat Nov 6 21:21:18 EST 2004
On Saturday 06 November 2004 03:36 pm, Fábio Mendes wrote:
> My proposal is to add the following syntax to the language:
>
> >>> assert (statement 1), (statement 2), ... (statement n), 'Errormsg'
>
> Or, if the user prefers, the traditional comma rules also applies:
>
> >>> assert \
> >>> statement1,
> >>> statement2,
> >>> (...)
> >>> statement n,
> >>> 'Errormsg'
>
> This simple syntax change introduces a very useful idiom for unittesting
> and may equally be useful in other kinds of code. The most problematic
> issue, I see, is the potential ambiguity a assert usage:
I don't think it gains much over what is already possible:
try:
statement1
statement2
(...)
statementn
except:
raise AssertionError("Errormsg")
Cheers,
Terry
--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com
More information about the Python-list
mailing list