Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?
Peter J. Holzer
hjp-python at hjp.at
Sat Feb 25 17:19:43 EST 2023
On 2023-02-25 21:58:18 +0000, Weatherby,Gerard wrote:
> I only use asserts for things I know to be true.
Yeah, that's what assers are for. Or rather for things that you *think*
are true.
> In other words, a failing assert means I have a hole in my program
> logic.
Yes, if you include your assumptions in your definition of "logic".
> For that use, the default behavior –telling me which line the assert
> is on, is more than sufficient. Depending on the circumstance, I’ll
> re-run the code with a breakpoint or replace the assert with an
> informative f-string Exception.
That may not always be practical. Things that we know (or think) are
true often have *are* true in most cases (otherwise we wouldn't think
so). So the case where the assumption fails may not be easily
reproducable and the more information you can get post-mortem the
better. For example, in C on Linux a failed assertion causes a core
dump. So you can inspect the complete state of the program.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp at hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20230225/52084f98/attachment.sig>
More information about the Python-list
mailing list