[Python-ideas] Making assert raise a different exception type

Guido van Rossum guido at python.org
Fri Oct 16 18:52:49 CEST 2009

I don't think so. You can already write

if not some_false_condition:
  raise ValueError("Message")

On Fri, Oct 16, 2009 at 9:16 AM, cool-RR <cool-rr at cool-rr.com> wrote:
> Hello!
> I would have liked to do something like this:
> assert some_false_condition, ValueError("Message")
> Meaning that if the assertion fails, the ValueError is raised instead of
> AssertionError. Do you think it's something that has a chance of being
> implemented? If so, I will write a PEP.
> Ram.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-ideas mailing list