>
> If the target of the call isn't in an appropriate state, isn't that a
> bug in the constructor that it allows you to construct objects that are
> in an invalid state?
>
> You should fix the object so that it is never in an invalid state rather
> than blaming the caller.
>

You can't really do that with files that have been closed.

Unless you disallow manual closing of files altogether.

That being said, I'd suggest that people raise custom exception, so your
callers can catch exactly what they want to handle.

An generic exception like ValueError or the proposed InvalidStateError
could be thrown by almost anything you call in your block, instead of just
what you actually intend to catch.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/F7YKSRESIZV6R7BGUDUFOH6VUBPEIEWV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to