Best way to check if there is internet?

Abdur-Rahmaan Janhangeer arj.python at gmail.com
Tue Feb 22 12:32:34 EST 2022


Well, nice perspective.

It's a valid consideration, sound theory
but poor practicality according to me.

It you view it like this then between the moment
we press run or enter key on the terminal,
our Python interpreter might get deleted.

We never know, it can happen.

Though it's nice to go in and catch exceptions,
if you have a long operation upcoming it might be nice
to see if your key element is present.

Much like checking if goal posts are present before
starting a football game. You can of course start
the match, pass the ball around and when shooting
you stop the match as you realise that the goal posts
are not around.

Checking by exceptions is what the snippet
i shared does. But we check for the ability to do it
before we start.

Of course, it can change in the seconds that follow. But it's too much pure
logic at work.


More information about the Python-list mailing list