Re: Best way to check if there is internet?

2022-02-22 Thread Abdur-Rahmaan Janhangeer
A front end eng sent me this for how to check for the internet in JS https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-online But it also says: "This attribute is inherently unreliable. A computer can be connected to a network without having Internet access." As discussed h

Re: Best way to check if there is internet?

2022-02-22 Thread Chris Angelico
On Tue, 22 Feb 2022 at 19:33, Abdur-Rahmaan Janhangeer 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 t

Re: Best way to check if there is internet?

2022-02-22 Thread Chris Angelico
On Tue, 22 Feb 2022 at 19:40, Chris Angelico wrote: > > On Tue, 22 Feb 2022 at 19:33, Abdur-Rahmaan Janhangeer > 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 n

Re: Best way to check if there is internet?

2022-02-22 Thread Abdur-Rahmaan Janhangeer
Thanks for the function but i think having the function as described won't return True all time Me: dipping my foot in hot water, yes we can go ... In the sprit of "practicality beats purity", devs needs a function XD Kind Regards, Abdur-Rahmaan Janhangeer about

Aw: Re: Best way to check if there is internet?

2022-02-22 Thread Karsten Hilbert
> Is there any value whatsoever in a lie? Do we _know_ it's a lie ? Does a lie become a Falsed Truth once it becomes known ? Karsten -- https://mail.python.org/mailman/listinfo/python-list

One-liner to merge lists?

2022-02-22 Thread Frank Millman
Hi all I think this should be a simple one-liner, but I cannot figure it out. I have a dictionary with a number of keys, where each value is a single list - >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} I want to combine all values into a single list - >>> ans = ['aaa', 'bbb', 'ccc'

Re: One-liner to merge lists?

2022-02-22 Thread Chris Angelico
On Tue, 22 Feb 2022 at 20:24, Frank Millman wrote: > > Hi all > > I think this should be a simple one-liner, but I cannot figure it out. > > I have a dictionary with a number of keys, where each value is a single > list - > > >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} > > I want to com

Re: One-liner to merge lists?

2022-02-22 Thread Frank Millman
On 2022-02-22 11:30 AM, Chris Angelico wrote: On Tue, 22 Feb 2022 at 20:24, Frank Millman wrote: Hi all I think this should be a simple one-liner, but I cannot figure it out. I have a dictionary with a number of keys, where each value is a single list - >>> d = {1: ['aaa', 'bbb', 'ccc'],

Re: One-liner to merge lists?

2022-02-22 Thread Chris Angelico
On Tue, 22 Feb 2022 at 20:46, Frank Millman wrote: > > On 2022-02-22 11:30 AM, Chris Angelico wrote: > > On Tue, 22 Feb 2022 at 20:24, Frank Millman wrote: > >> > >> Hi all > >> > >> I think this should be a simple one-liner, but I cannot figure it out. > >> > >> I have a dictionary with a number

Re: Best way to check if there is internet?

2022-02-22 Thread Antoon Pardon
Op 22/02/2022 om 09:40 schreef Chris Angelico: On Tue, 22 Feb 2022 at 19:33, Abdur-Rahmaan Janhangeer 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 conn

Re: Python

2022-02-22 Thread Mats Wichmann
On 2/21/22 23:17, SASI KANTH REDDY GUJJULA wrote: > Pip files are not installing after the python 3.10.2 version installing in my > devise. Please solve this for me. Please ask a clearer question. Can you tell us what "are not installing" means? Are you getting permission errors? Are you instal

Re: Best way to check if there is internet?

2022-02-22 Thread Chris Angelico
On Wed, 23 Feb 2022 at 01:06, Antoon Pardon wrote: > > > Op 22/02/2022 om 09:40 schreef Chris Angelico: > > On Tue, 22 Feb 2022 at 19:33, Abdur-Rahmaan Janhangeer > > wrote: > >> As discussed here but, it would have been nevertheless great to have this > >> tiny function instead of > >> nothing

Re: Best way to check if there is internet?

2022-02-22 Thread Chris Green
Chris Angelico wrote: > On Tue, 22 Feb 2022 at 19:33, Abdur-Rahmaan Janhangeer > 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 > conne

RE: One-liner to merge lists?

2022-02-22 Thread David Raymond
> Is there a simpler way? >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} >>> [a for b in d.values() for a in b] ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] >>> -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to check if there is internet?

2022-02-22 Thread Chris Angelico
On Wed, 23 Feb 2022 at 02:33, Chris Green wrote: > > Chris Angelico wrote: > > On Tue, 22 Feb 2022 at 19:33, Abdur-Rahmaan Janhangeer > > wrote: > > > > > > As discussed here but, it would have been nevertheless great to have this > > > tiny function instead of > > > nothing > > > > > > > Here's

Re: Best way to check if there is internet?

2022-02-22 Thread 2QdxY4RzWzUUiLuE
On 2022-02-09 at 11:15:34 +0400, Abdur-Rahmaan Janhangeer wrote: > I think for me having the internet means ability to request urls You can always ask. The real question is what will the response be? ;-) This entire exercise is a race condition, just like checking for that a file exists befor

Re: One-liner to merge lists?

2022-02-22 Thread Avi Gross via Python-list
Frank, Given this kind of data: d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} You seem focused on a one-liner, however ridiculous or inefficient. Does this count as a somewhat weird one liner? comb = []; _ = [comb.append(v) for v in d.values()] If you run the code and ignore the returned

Re: Best way to check if there is internet?

2022-02-22 Thread Abdur-Rahmaan Janhangeer
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 a

Re: Best way to check if there is internet?

2022-02-22 Thread Avi Gross via Python-list
As usual, his discussion is wandering a bit. Yes, some things are not reliable but sometimes a heuristic answer is better than none. Internet connections are beyond flaky and worse the connection you want may be blocked for many reasons even if other connections you try are working. Any number

Re: Best way to check if there is internet?

2022-02-22 Thread Chris Angelico
On Wed, 23 Feb 2022 at 05:38, Avi Gross via Python-list wrote: > It sounds to me like your main issue is not whether the internet is up right > now but whether the user has an internet connection. If they run the program > on a laptop at home or work then they may well be connected, but sitting

Re: Best way to check if there is internet?

2022-02-22 Thread Abdur-Rahmaan Janhangeer
I've got my answers but the 'wandering' a bit on this thread is at least connected to the topic ^^. Last question: If we check for wifi or ethernet cable connection? Wifi sometimes tell of connected but no internet connection. So it detected that there is or there is no internet ... -- https://m

Re: Best way to check if there is internet?

2022-02-22 Thread Barry
> On 22 Feb 2022, at 17:44, Abdur-Rahmaan Janhangeer > wrote: > > 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 inte

Re: One-liner to merge lists?

2022-02-22 Thread Dan Stromberg
On Tue, Feb 22, 2022 at 7:46 AM David Raymond wrote: > > Is there a simpler way? > > >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} > >>> [a for b in d.values() for a in b] > ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] > >>> > I like that way best. But I'd still: 1) use a little more descriptive

Re: Best way to check if there is internet?

2022-02-22 Thread Abdur-Rahmaan Janhangeer
> > > Since you have to deal with things that you do not control changing > after you check what is the point in checking? You have to write the code > to recover anyway. > Well foe my usecase, the operation running is not in months or a really long time. As Avi mentionned above, that would be po

Re: One-liner to merge lists?

2022-02-22 Thread Chris Angelico
On Wed, 23 Feb 2022 at 15:04, Dan Stromberg wrote: > > On Tue, Feb 22, 2022 at 7:46 AM David Raymond > wrote: > > > > Is there a simpler way? > > > > >>> d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} > > >>> [a for b in d.values() for a in b] > > ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] > > >>> >

Re: One-liner to merge lists?

2022-02-22 Thread Avi Gross via Python-list
I had to think about it too, David. Renaming it lets it make a bit more sense: [item for sublist in d.values() for item in sublist] This spells it out for me that you are taking one list within the main list at a time and then taking one item at a time from the list. Since the nesting is consi

Re: One-liner to merge lists?

2022-02-22 Thread Frank Millman
On 2022-02-22 5:45 PM, David Raymond wrote: Is there a simpler way? d = {1: ['aaa', 'bbb', 'ccc'], 2: ['fff', 'ggg']} [a for b in d.values() for a in b] ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] Now that's what I was looking for. I am not saying that I will use it, but as an academic exercis

Re: Best way to check if there is internet?

2022-02-22 Thread Dennis Lee Bieber
On Wed, 23 Feb 2022 07:08:27 +0300, Abdur-Rahmaan Janhangeer declaimed the following: >The upcoming operation is short enough and >though we cannot assume that it will be the case >when we are running the operation, we sensibly >assume it will still be the case. > >This is more an extra check to