You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that Python includes a rich set of built-in exception classes. Leverage these appropriately, and you should "customize" them simply by instantiating them with string messages that describe the specific error condition you hit. It is most common to raise ValueError (bad argument), LookupError (bad key), or AssertionError (via the assert statement) in user code.
The link to the exception hierarchy uses Python 2 docs.
In this line:
As described in the blog post, "Python double-under, double-wonder", there is nothing "special" about dunders. They are nothing more than a lightweight namespace the Python core developers picked for all of Python's internal protocols. After all, init is a dunder, and there's nothing magic about it.
The redirect domain for the link can be updated.
In this line:
Also, don't re-invent the wheel. One thing str.format does unequivocally better is support various formatting modes, such as humanized numbers and percentages. Use them.
The link is for Python 2 docs.
Same for this line:
Truthiness is a tad complicated in Python and certainly the latter is safer against some classes of bugs. The former, however, is very common in much Python code, and it's shorter. We choose not to care.
And this one:
Essentially, Python turns the first line into the second automatically. You should probably prefer the second form, if for no other reason than to actually provide a useful argument, like a helpful message about why the ValueError occurred.
The text was updated successfully, but these errors were encountered:
In this line:
The
api.py
link no longer works.In this line:
The link to the exception hierarchy uses Python 2 docs.
In this line:
The redirect domain for the link can be updated.
In this line:
The link is for Python 2 docs.
Same for this line:
And this one:
The text was updated successfully, but these errors were encountered: