Best way to check if there is internet?

Chris Angelico rosuav at gmail.com
Tue Feb 22 10:21:36 EST 2022


On Wed, 23 Feb 2022 at 01:06, Antoon Pardon <antoon.pardon at vub.be> wrote:
>
>
> Op 22/02/2022 om 09:40 schreef Chris Angelico:
> > On Tue, 22 Feb 2022 at 19:33, Abdur-Rahmaan Janhangeer
> > <arj.python at gmail.com>  wrote:
> >> As discussed here but, it would have been nevertheless great to have this
> >> tiny function instead of
> >> nothing
> >>
> > Here's a function that determines whether or not you have an internet
> > connection. It's almost as reliable as some of the other examples
> > given - I know this, because I tried it ten times, and it gave the
> > correct result every time!
>
> So, you discovered a way of testing that is not very thorough.
>
> > def has_internet():
> >      return True
> >
> > Tell me, is it useful to have something that doesn't always give the
> > right answer, even if it usually does? Is there any value whatsoever
> > in a lie?
>
> Yes that is useful. Live is full of that kind of situations. We in computerland
> are spoiled with the accuracy we can enjoy. It seems even spoiled to the extend
> that when offered a solution that is not 100% accurated we consider it a lie.
>

Cool! Then you have a very useful internet-availability testing
function. Have fun!

ChrisA


More information about the Python-list mailing list