Ethan Furman wrote:

Why is this? Doesn't the exception have to be instantiated at some point, even if just to print to stderr?

If it gets caught by an except clause without an else clause,
in theory there's no need to instantiate it.

However, Python doesn't currently seem to take advantage of
that:

>>> class E(Exception):
...  def __init__(self, *args):
...   Exception.__init__(self, *args)
...   print("E got instantiated!")
...
>>> try:
...  print("Trying")
...  raise E
... except E:
...  print("Caught an E")
...
Trying
E got instantiated!
Caught an E

--
Greg


_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to