4 ms·
> Here’s the big lie: in Python, this snippet will almost always raise an Exception. That’s because most users, faced with an input prompt, will press Ctrl+C or
by Kwpolska 2y ago
> Here’s the big lie: in Python, this snippet will almost always raise an Exception. That’s because most users, faced with an input prompt, will press Ctrl+C or enter a non-URL. And even if they enter a URL, it probably has a typo.
[citation needed]
> In English, “exception” means, “something unusual.” But if this code snipet raises ValueError 60 per cent of the time and prints the contents of a web page 10 per cent of the time … well, surely we need a new term?
The purpose of this code snippet is to download a web page and show it to the user. The code considers situations that lead to it not fulfilling its purpose “exceptional”. If someone exits when they see a prompt for a URL, or type gibberish, why did they run a program to download a web page in the first place?