PEP new assert idiom

John Roth newsgroups at jhrothjr.com
Sat Nov 6 19:07:04 EST 2004


"Fábio Mendes" <niels_bohr at uol.com.br> wrote in message 
news:mailman.6017.1099776962.5135.python-list at python.org...
> I'm sorry if it's an replicate. Either my e-mail program is messing with
> things or the python-list sent my msg to /dev/null. I couldn't find
> anything related in previous PEP's, so here it goes a very early draft
> for a new "assert" syntax:
>
[...]
>
> I'm interested to write a formal PEP if I receive good feedback from the
> community, but I never wrote a PEP before, and (the worst problem) my
> english is not so good. Anyone helps?
>
> Thanks,
> Fabio

I see two difficulties with it.

First, you can do the same thing (I think) with a
try block around a sequence of statements and
an assert in the except block. This means you
will need a fairly strong use case based on
convenience to add the syntax to the language.
You will have to show that it will be used a lot.

Second, the statement form has the potential to
cause side effects. There is a very strong
community of thought that says that asserts
are debugging or validation statements that
should not cause any behavior change by
removing them. This can be dealt with by
making it some form of block that has its
own local variables that are discarded on
exit.

John Roth 




More information about the Python-list mailing list