From gvm2121 at gmail.com Mon Aug 1 10:16:49 2022 From: gvm2121 at gmail.com (Gonzalo V) Date: Mon, 1 Aug 2022 10:16:49 -0400 Subject: Spotify technology Message-ID: Hi everyone! i need a guide or advice or anything. I few years ago, i was able to connect to my music receiver via spotify app from my phone or laptop. You had to connect to receiver and your laptop to the same wifi network and this is. Years later, that service was deprecated by spotify conditions. Spotify would only work with some brands, i can understand that. Do you know guys, how that technology works?, it could be replicated via python app?, Is there some kind a documentation that could help me?. i cant find anything because i cant find the keyword to start my research thanks in advance. Gonzalo form Chile. Saludos, Gonzalo From python at mrabarnett.plus.com Mon Aug 1 10:56:45 2022 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 1 Aug 2022 15:56:45 +0100 Subject: Spotify technology In-Reply-To: References: Message-ID: <52a300ea-175d-2de7-89d2-71180059cf5a@mrabarnett.plus.com> On 01/08/2022 15:16, Gonzalo V wrote: > Hi everyone! > i need a guide or advice or anything. > I few years ago, i was able to connect to my music receiver via spotify app > from my phone or laptop. You had to connect to receiver and your laptop to > the same wifi network and this is. Years later, that service was deprecated > by spotify conditions. Spotify would only work with some brands, i can > understand that. > Do you know guys, how that technology works?, > it could be replicated via python app?, > Is there some kind a documentation that could help me?. > i cant find anything because i cant find the keyword to start my research > thanks in advance. > Gonzalo form Chile. > Search for: spotify api From Daniel-ZX.Li at hotmail.com Mon Aug 1 08:17:09 2022 From: Daniel-ZX.Li at hotmail.com (Daniel Lee) Date: Mon, 1 Aug 2022 12:17:09 +0000 Subject: Tkinter not working Message-ID: Hello, I my code with tkinter was working before, and now, it has many errors in it. I?m not sure what has happened. The results after running are below: "D:\Python Projects\tes\venv\Scripts\python.exe" "D:/Python Projects/tes/main.py" Traceback (most recent call last): File "D:\Python Projects\tes\main.py", line 1, in import tkinter as tk File "C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 3, in import tkinter.messagebox File "C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\messagebox.py", line 25, in from tkinter.commondialog import Dialog File "C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\commondialog.py", line 13, in from tkinter import Frame, _get_temp_root, _destroy_temp_root ImportError: cannot import name 'Frame' from partially initialized module 'tkinter' (most likely due to a circular import) (C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py) Process finished with exit code 1 From dieter at handshake.de Mon Aug 1 13:34:49 2022 From: dieter at handshake.de (Dieter Maurer) Date: Mon, 1 Aug 2022 19:34:49 +0200 Subject: Register multiple excepthooks? In-Reply-To: References: Message-ID: <25320.3769.224412.136125@ixdm.fritz.box> Albert-Jan Roskam wrote at 2022-7-31 11:39 +0200: > I have a function init_logging.log_uncaught_errors() that I use for > sys.excepthook. Now I also want to call another function (ffi.dlclose()) > upon abnormal termination. Is it possible to register multiple > excepthooks, like with atexit.register? Or should I rename/redefine > log_uncaught_errors() so it does both things? `sys.excepthook` is a single function (not a list of them). This means: at any moment a single `excepthook` is effective. If you need a modular design, use a dispatcher function as your `excepthook` associated with a registry (e.g. a `list`). The dispatcher can then call all registered function. From mrabarnett at mrabarnett.plus.com Mon Aug 1 13:53:47 2022 From: mrabarnett at mrabarnett.plus.com (Matthew Barnett) Date: Mon, 1 Aug 2022 18:53:47 +0100 Subject: Tkinter not working In-Reply-To: References: Message-ID: On 01/08/2022 13:17, Daniel Lee wrote: > Hello, I my code with tkinter was working before, and now, it has many errors in it. I?m not sure what has happened. The results after running are below: > > "D:\Python Projects\tes\venv\Scripts\python.exe" "D:/Python Projects/tes/main.py" > Traceback (most recent call last): > File "D:\Python Projects\tes\main.py", line 1, in > import tkinter as tk > File "C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 3, in > import tkinter.messagebox > File "C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\messagebox.py", line 25, in > from tkinter.commondialog import Dialog > File "C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\commondialog.py", line 13, in > from tkinter import Frame, _get_temp_root, _destroy_temp_root > ImportError: cannot import name 'Frame' from partially initialized module 'tkinter' (most likely due to a circular import) (C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py) > > Process finished with exit code 1 The entry: File "C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 3, in import tkinter.messagebox in the traceback does not look right to me. On my PC that file starts with a long docstring. From 2QdxY4RzWzUUiLuE at potatochowder.com Mon Aug 1 14:27:55 2022 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Mon, 1 Aug 2022 13:27:55 -0500 Subject: Tkinter not working In-Reply-To: References: Message-ID: On 2022-08-01 at 18:53:47 +0100, Matthew Barnett wrote: > On 01/08/2022 13:17, Daniel Lee wrote: > > Hello, I my code with tkinter was working before, and now, it has many errors in it. I?m not sure what has happened. The results after running are below: > > > > "D:\Python Projects\tes\venv\Scripts\python.exe" "D:/Python Projects/tes/main.py" > > Traceback (most recent call last): > > File "D:\Python Projects\tes\main.py", line 1, in > > import tkinter as tk > > File "C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 3, in > > import tkinter.messagebox > > File "C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\messagebox.py", line 25, in > > from tkinter.commondialog import Dialog > > File "C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\commondialog.py", line 13, in > > from tkinter import Frame, _get_temp_root, _destroy_temp_root > > ImportError: cannot import name 'Frame' from partially initialized module 'tkinter' (most likely due to a circular import) (C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py) > > > > Process finished with exit code 1 > > The entry: > > File "C:\Users\Daniel.LAPTOP-6U1MQ9CR\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", > line 3, in > import tkinter.messagebox > > in the traceback does not look right to me. On my PC that file starts with a > long docstring. My tkinter/__init__.py, too. Do you have (and did you create since the last time your code worked) your own module called tkinter? Is line 3 "import tkinter.messagebox"? From drsalists at gmail.com Mon Aug 1 16:41:11 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 1 Aug 2022 13:41:11 -0700 Subject: Dictionary order? Message-ID: Hi folks. I'm still porting some code from Python 2.7 to 3.10. As part of that, I saw a list being extended with a dict.values(), and thought perhaps it wasn't ordered as intended on Python 2.7, even though the problem would conceivably just disappear on 3.10. So I decided to write a little test program to run on a variety of CPythons, to confirm what I was thinking. And instead I got a surprise. On 1.4 through 2.1 I got descending key order. I expected the keys to be scattered, but they weren't. On 2.2 through 3.5 I got ascending key order. I expected the keys to be scattered, but they weren't. On 3.6 through 3.10 I got insertion order, as expected. But why are 1.4 through 3.5 ordering so much? It's like they're a treap or red-black tree or something. I'm pretty sure dict's used to be ordered in a mostly-arbitrary way. What am I missing? Here's the little test program: #!/usr/local/cpython-2.7/bin/python2 import sys keys = [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] dict_ = {} for key in keys: dict_[key] = 1 if list(dict_.keys()) == keys: # The order matches print('compact') sys.exit(0) else: # The order does not match print('list(dict_): %s, keys: %s' % (list(dict_.keys()), keys)) sys.exit(1) Here's some output (irrelevant python's deleted) when run under https://stromberg.dnsalias.org/~strombrg/pythons/ /usr/local/cpython-1.4/bin/python (1.4) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-1.5/bin/python (1.5.2) bad list(dict_): [15, 14, 12, 11, 10, 9, 8, 7, 6, 5, 4, 2, 1], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-1.6/bin/python (1.6.1) bad list(dict_): [15, 14, 12, 11, 10, 9, 8, 7, 6, 5, 4, 2, 1], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-2.0/bin/python (2.0.1) bad list(dict_): [15, 14, 12, 11, 10, 9, 8, 7, 6, 5, 4, 2, 1], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-2.1/bin/python (2.1.0) bad list(dict_): [15, 14, 12, 11, 10, 9, 8, 7, 6, 5, 4, 2, 1], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-2.2/bin/python (2.2.0) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-2.3/bin/python (2.3.0) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-2.4/bin/python (2.4.0) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-2.5/bin/python (2.5.6) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-2.6/bin/python (2.6.9) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-2.7/bin/python (2.7.16) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-3.0/bin/python (3.0.1) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-3.1/bin/python (3.1.5) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-3.2/bin/python (3.2.5) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-3.3/bin/python (3.3.7) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-3.4/bin/python (3.4.8) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-3.5/bin/python (3.5.5) bad list(dict_): [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15], keys: [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] /usr/local/cpython-3.6/bin/python (3.6.13) good compact /usr/local/cpython-3.7/bin/python (3.7.0) good compact /usr/local/cpython-3.8/bin/python (3.8.0) good compact /usr/local/cpython-3.9/bin/python (3.9.0) good compact /usr/local/cpython-3.10/bin/python (3.10.0) good compact BTW, usually with pythons (the script which can be found at the URL above), a little test program will be written to exit shell-true for success or shell-false for failure. But in this case I'm using the exit code not as success+failure but as compact+notcompact. Why are those keys so ordered? Also, I realize that the keys could come up ordered somehow by accident, but I tried with 30 values (not just 12), and still got the same weirdness. Naturally, as the number of key-value pairs goes up, the chance of accidental ordering goes way down. Thanks for reading! From skip.montanaro at gmail.com Mon Aug 1 16:48:45 2022 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Mon, 1 Aug 2022 15:48:45 -0500 Subject: Dictionary order? In-Reply-To: References: Message-ID: > > So I decided to write a little test program to run on a variety of > CPythons, to confirm what I was thinking. > > And instead I got a surprise. > > On 1.4 through 2.1 I got descending key order. I expected the keys to be > scattered, but they weren't. > > On 2.2 through 3.5 I got ascending key order. I expected the keys to be > scattered, but they weren't. > > On 3.6 through 3.10 I got insertion order, as expected. > > But why are 1.4 through 3.5 ordering so much? > That's long in the past, but I seem to recall that key order was unspecified. That would give the implementer (likely Tim Peters much of the time) the freedom to do whatever worked best for performance or simplicity of implementation. Skip > From rosuav at gmail.com Mon Aug 1 17:09:03 2022 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 2 Aug 2022 07:09:03 +1000 Subject: Dictionary order? In-Reply-To: References: Message-ID: On Tue, 2 Aug 2022 at 06:50, Skip Montanaro wrote: > > > > > So I decided to write a little test program to run on a variety of > > CPythons, to confirm what I was thinking. > > > > And instead I got a surprise. > > > > On 1.4 through 2.1 I got descending key order. I expected the keys to be > > scattered, but they weren't. > > > > On 2.2 through 3.5 I got ascending key order. I expected the keys to be > > scattered, but they weren't. > > > > On 3.6 through 3.10 I got insertion order, as expected. > > > > But why are 1.4 through 3.5 ordering so much? > > > > That's long in the past, but I seem to recall that key order was > unspecified. That would give the implementer (likely Tim Peters much of the > time) the freedom to do whatever worked best for performance or simplicity > of implementation. > One thing that you might notice also is that using strings as keys will begin randomizing them with Python 3.3. But other than strings, it's always been "arbitrary" rather than "random". ChrisA From drsalists at gmail.com Mon Aug 1 17:24:09 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 1 Aug 2022 14:24:09 -0700 Subject: Dictionary order? In-Reply-To: References: Message-ID: On Mon, Aug 1, 2022 at 1:41 PM Dan Stromberg wrote: > On 1.4 through 2.1 I got descending key order. I expected the keys to be > scattered, but they weren't. > I just noticed that 1.4 was ascending order too - so it was closer to 2.2 than 1.5. I guess that's kind of beside the point though - it's still more ordered than I'd've expected. From 2QdxY4RzWzUUiLuE at potatochowder.com Mon Aug 1 17:46:54 2022 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Mon, 1 Aug 2022 16:46:54 -0500 Subject: Dictionary order? In-Reply-To: References: Message-ID: On 2022-08-01 at 13:41:11 -0700, Dan Stromberg wrote: > keys = [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] > > dict_ = {} > for key in keys: > dict_[key] = 1 $ python Python 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> [hash(x) for x in range(20)] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] Just sayin'. :-) From rosuav at gmail.com Mon Aug 1 17:50:52 2022 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 2 Aug 2022 07:50:52 +1000 Subject: Dictionary order? In-Reply-To: References: Message-ID: On Tue, 2 Aug 2022 at 07:48, <2QdxY4RzWzUUiLuE at potatochowder.com> wrote: > > On 2022-08-01 at 13:41:11 -0700, > Dan Stromberg wrote: > > > keys = [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] > > > > dict_ = {} > > for key in keys: > > dict_[key] = 1 > > $ python > Python 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> [hash(x) for x in range(20)] > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] > > Just sayin'. :-) Yes, but I'm pretty sure that's been true for a LONG time. The hashes for small integers have been themselves for as long as I can remember. But the behaviour of the dictionary, when fed such keys, is what's changed. ChrisA From 2QdxY4RzWzUUiLuE at potatochowder.com Mon Aug 1 18:24:17 2022 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Mon, 1 Aug 2022 17:24:17 -0500 Subject: Dictionary order? In-Reply-To: References: Message-ID: On 2022-08-02 at 07:50:52 +1000, Chris Angelico wrote: > On Tue, 2 Aug 2022 at 07:48, <2QdxY4RzWzUUiLuE at potatochowder.com> wrote: > > > > On 2022-08-01 at 13:41:11 -0700, > > Dan Stromberg wrote: > > > > > keys = [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] > > > > > > dict_ = {} > > > for key in keys: > > > dict_[key] = 1 > > > > $ python > > Python 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0] on linux > > Type "help", "copyright", "credits" or "license" for more information. > > >>> [hash(x) for x in range(20)] > > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] > > > > Just sayin'. :-) > > Yes, but I'm pretty sure that's been true for a LONG time. The hashes > for small integers have been themselves for as long as I can remember. > But the behaviour of the dictionary, when fed such keys, is what's > changed. I'm not disputing either of those facts. I'm pointing out that the apparently arbitrary order of a mapping's keys becomes obvious when you look at the hashes of those keys. From drsalists at gmail.com Mon Aug 1 19:42:58 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 1 Aug 2022 16:42:58 -0700 Subject: Dictionary order? In-Reply-To: References: Message-ID: On Mon, Aug 1, 2022 at 3:25 PM <2QdxY4RzWzUUiLuE at potatochowder.com> wrote: > On 2022-08-02 at 07:50:52 +1000, > Chris Angelico wrote: > > > On Tue, 2 Aug 2022 at 07:48, <2QdxY4RzWzUUiLuE at potatochowder.com> wrote: > > > > > > On 2022-08-01 at 13:41:11 -0700, > > > Dan Stromberg wrote: > > > > > > > keys = [5, 10, 15, 14, 9, 4, 1, 2, 8, 6, 7, 12, 11] > > > > > > > > dict_ = {} > > > > for key in keys: > > > > dict_[key] = 1 > > > > > > $ python > > > Python 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0] on linux > > > Type "help", "copyright", "credits" or "license" for more information. > > > >>> [hash(x) for x in range(20)] > > > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] > > > > > > Just sayin'. :-) > > > > Yes, but I'm pretty sure that's been true for a LONG time. The hashes > > for small integers have been themselves for as long as I can remember. > > But the behaviour of the dictionary, when fed such keys, is what's > > changed. > > I'm not disputing either of those facts. I'm pointing out that the > apparently arbitrary order of a mapping's keys becomes obvious when you > look at the hashes of those keys. > It looks like the relationship no longer holds at around keys = list(range(250, 260)) But i == hash(i) holds for the first million values at least. From drsalists at gmail.com Mon Aug 1 19:46:51 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 1 Aug 2022 16:46:51 -0700 Subject: Dictionary order? In-Reply-To: References: Message-ID: On Mon, Aug 1, 2022 at 4:42 PM Dan Stromberg wrote: > > > Yes, but I'm pretty sure that's been true for a LONG time. The hashes >> > for small integers have been themselves for as long as I can remember. >> > But the behaviour of the dictionary, when fed such keys, is what's >> > changed. >> >> I'm not disputing either of those facts. I'm pointing out that the >> apparently arbitrary order of a mapping's keys becomes obvious when you >> look at the hashes of those keys. >> > > It looks like the relationship no longer holds at around keys = > list(range(250, 260)) > > But i == hash(i) holds for the first million values at least. > I could've been more clear. int dict keys stop being stored-in-order at near 256. But i == hash(i) holds for the first million values, and probably more. This suggests to me that there's something more than i == hash(i) going on inside dict's - but it doesn't much matter what it is for my purposes. From gweatherby at uchc.edu Mon Aug 1 21:14:43 2022 From: gweatherby at uchc.edu (Weatherby,Gerard) Date: Tue, 2 Aug 2022 01:14:43 +0000 Subject: Dictionary order? In-Reply-To: References: Message-ID: <87d652dc-0bce-499c-92e9-a879d38236ba@Spark> I don?t see what is surprising. The interface for a dictionary never specified the ordering of the keys, so I would not be surprised to see it vary based on release, platform, values of keys inserted, number of items in the dictionary, etc. ? Gerard Weatherby | Application Architect NMRbox | NAN | Department of Molecular Biology and Biophysics UConn Health 263 Farmington Avenue, Farmington, CT 06030-6406 uchc.edu On Aug 1, 2022, 7:48 PM -0400, Dan Stromberg , wrote: *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** On Mon, Aug 1, 2022 at 4:42 PM Dan Stromberg wrote: Yes, but I'm pretty sure that's been true for a LONG time. The hashes for small integers have been themselves for as long as I can remember. But the behaviour of the dictionary, when fed such keys, is what's changed. I'm not disputing either of those facts. I'm pointing out that the apparently arbitrary order of a mapping's keys becomes obvious when you look at the hashes of those keys. It looks like the relationship no longer holds at around keys = list(range(250, 260)) But i == hash(i) holds for the first million values at least. I could've been more clear. int dict keys stop being stored-in-order at near 256. But i == hash(i) holds for the first million values, and probably more. This suggests to me that there's something more than i == hash(i) going on inside dict's - but it doesn't much matter what it is for my purposes. -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!j3p_Aq5MoGqDk5XMsKb4SKs3U1nfuMOx0wVkSa_hbURJ22w6lP8NrCOc_PYAfELYOdVlC9x6JzLfIMIw5sLe$ From pablogsal at gmail.com Tue Aug 2 06:12:38 2022 From: pablogsal at gmail.com (Pablo Galindo Salgado) Date: Tue, 2 Aug 2022 11:12:38 +0100 Subject: [RELEASE] Python 3.10.6 is available Message-ID: Here you have a nice package of 200 commits of bugfixes and documentation improvements freshly made for Python 3.10. Go and download it when is still hot: https://www.python.org/downloads/release/python-3106/ ## This is the sixth maintenance release of Python 3.10 Python 3.10.6 is the newest major release of the Python programming language, and it contains many new features and optimizations. # Major new features of the 3.10 series, compared to 3.9 Among the new major new features and changes so far: * [PEP 623](https://www.python.org/dev/peps/pep-0623/) -- Deprecate and prepare for the removal of the wstr member in PyUnicodeObject. * [PEP 604](https://www.python.org/dev/peps/pep-0604/) -- Allow writing union types as X | Y * [PEP 612](https://www.python.org/dev/peps/pep-0612/) -- Parameter Specification Variables * [PEP 626](https://www.python.org/dev/peps/pep-0626/) -- Precise line numbers for debugging and other tools. * [PEP 618 ](https://www.python.org/dev/peps/pep-0618/) -- Add Optional Length-Checking To zip. * [bpo-12782](https://bugs.python.org/issue12782): Parenthesized context managers are now officially allowed. * [PEP 632 ](https://www.python.org/dev/peps/pep-0632/) -- Deprecate distutils module. * [PEP 613 ](https://www.python.org/dev/peps/pep-0613/) -- Explicit Type Aliases * [PEP 634 ](https://www.python.org/dev/peps/pep-0634/) -- Structural Pattern Matching: Specification * [PEP 635 ](https://www.python.org/dev/peps/pep-0635/) -- Structural Pattern Matching: Motivation and Rationale * [PEP 636 ](https://www.python.org/dev/peps/pep-0636/) -- Structural Pattern Matching: Tutorial * [PEP 644 ](https://www.python.org/dev/peps/pep-0644/) -- Require OpenSSL 1.1.1 or newer * [PEP 624 ](https://www.python.org/dev/peps/pep-0624/) -- Remove Py_UNICODE encoder APIs * [PEP 597 ](https://www.python.org/dev/peps/pep-0597/) -- Add optional EncodingWarning [bpo-38605](https://bugs.python.org/issue38605): `from __future__ import annotations` ([PEP 563](https://www.python.org/dev/peps/pep-0563/)) used to be on this list in previous pre-releases but it has been postponed to Python 3.11 due to some compatibility concerns. You can read the Steering Council communication about it [here]( https://mail.python.org/archives/list/python-dev at python.org/thread/CLVXXPQ2T2LQ5MP2Y53VVQFCXYWQJHKZ/) to learn more. # More resources * [Changelog](https://docs.python.org/3.10/whatsnew/changelog.html#changelog ) * [Online Documentation](https://docs.python.org/3.10/) * [PEP 619](https://www.python.org/dev/peps/pep-0619/), 3.10 Release Schedule * Report bugs at [https://bugs.python.org](https://bugs.python.org). * [Help fund Python and its community](/psf/donations/). # And now for something completely different A pentaquark is a human-made subatomic particle, consisting of four quarks and one antiquark bound together; they are not known to occur naturally or exist outside of experiments to create them. As quarks have a baryon number of (+1/3), and antiquarks of (?1/3), the pentaquark would have a total baryon number of 1 and thus would be a baryon. Further, because it has five quarks instead of the usual three found in regular baryons (a.k.a. 'triquarks'), it is classified as an exotic baryon. The name pentaquark was coined by Claude Gignoux et al. (1987) and Harry J. Lipkin in 1987; however, the possibility of five-quark particles was identified as early as 1964 when Murray Gell-Mann first postulated the existence of quarks. Although predicted for decades, pentaquarks proved surprisingly tricky to discover and some physicists were beginning to suspect that an unknown law of nature prevented their production. # We hope you enjoy the new releases! Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation. https://www.python.org/psf/ Your friendly release team, Ned Deily @nad https://discuss.python.org/u/nad Steve Dower @steve.dower https://discuss.python.org/u/steve.dower Pablo Galindo Salgado @pablogsal https://discuss.python.org/u/pablogsal From jschwar at sbcglobal.net Tue Aug 2 13:13:16 2022 From: jschwar at sbcglobal.net (jschwar at sbcglobal.net) Date: Tue, 2 Aug 2022 12:13:16 -0500 Subject: [RELEASE] Python 3.10.6 is available In-Reply-To: References: Message-ID: <004b01d8a693$28929cd0$79b7d670$@sbcglobal.net> Does anyone know if this is being worked on? https://github.com/python/cpython/issues/90242 It was originally reported here: https://bugs.python.org/issue46084 -----Original Message----- From: Python-list On Behalf Of Pablo Galindo Salgado Sent: Tuesday, August 2, 2022 5:13 AM To: Python Dev ; python-list at python.org; python-committers ; python-announce at python.org Subject: [RELEASE] Python 3.10.6 is available Here you have a nice package of 200 commits of bugfixes and documentation improvements freshly made for Python 3.10. Go and download it when is still hot: https://www.python.org/downloads/release/python-3106/ ## This is the sixth maintenance release of Python 3.10 Python 3.10.6 is the newest major release of the Python programming language, and it contains many new features and optimizations. # Major new features of the 3.10 series, compared to 3.9 Among the new major new features and changes so far: * [PEP 623](https://www.python.org/dev/peps/pep-0623/) -- Deprecate and prepare for the removal of the wstr member in PyUnicodeObject. * [PEP 604](https://www.python.org/dev/peps/pep-0604/) -- Allow writing union types as X | Y * [PEP 612](https://www.python.org/dev/peps/pep-0612/) -- Parameter Specification Variables * [PEP 626](https://www.python.org/dev/peps/pep-0626/) -- Precise line numbers for debugging and other tools. * [PEP 618 ](https://www.python.org/dev/peps/pep-0618/) -- Add Optional Length-Checking To zip. * [bpo-12782](https://bugs.python.org/issue12782): Parenthesized context managers are now officially allowed. * [PEP 632 ](https://www.python.org/dev/peps/pep-0632/) -- Deprecate distutils module. * [PEP 613 ](https://www.python.org/dev/peps/pep-0613/) -- Explicit Type Aliases * [PEP 634 ](https://www.python.org/dev/peps/pep-0634/) -- Structural Pattern Matching: Specification * [PEP 635 ](https://www.python.org/dev/peps/pep-0635/) -- Structural Pattern Matching: Motivation and Rationale * [PEP 636 ](https://www.python.org/dev/peps/pep-0636/) -- Structural Pattern Matching: Tutorial * [PEP 644 ](https://www.python.org/dev/peps/pep-0644/) -- Require OpenSSL 1.1.1 or newer * [PEP 624 ](https://www.python.org/dev/peps/pep-0624/) -- Remove Py_UNICODE encoder APIs * [PEP 597 ](https://www.python.org/dev/peps/pep-0597/) -- Add optional EncodingWarning [bpo-38605](https://bugs.python.org/issue38605): `from __future__ import annotations` ([PEP 563](https://www.python.org/dev/peps/pep-0563/)) used to be on this list in previous pre-releases but it has been postponed to Python 3.11 due to some compatibility concerns. You can read the Steering Council communication about it [here]( https://mail.python.org/archives/list/python-dev at python.org/thread/CLVXXPQ2T2LQ5MP2Y53VVQFCXYWQJHKZ/) to learn more. # More resources * [Changelog](https://docs.python.org/3.10/whatsnew/changelog.html#changelog ) * [Online Documentation](https://docs.python.org/3.10/) * [PEP 619](https://www.python.org/dev/peps/pep-0619/), 3.10 Release Schedule * Report bugs at [https://bugs.python.org](https://bugs.python.org). * [Help fund Python and its community](/psf/donations/). # And now for something completely different A pentaquark is a human-made subatomic particle, consisting of four quarks and one antiquark bound together; they are not known to occur naturally or exist outside of experiments to create them. As quarks have a baryon number of (+1/3), and antiquarks of (?1/3), the pentaquark would have a total baryon number of 1 and thus would be a baryon. Further, because it has five quarks instead of the usual three found in regular baryons (a.k.a. 'triquarks'), it is classified as an exotic baryon. The name pentaquark was coined by Claude Gignoux et al. (1987) and Harry J. Lipkin in 1987; however, the possibility of five-quark particles was identified as early as 1964 when Murray Gell-Mann first postulated the existence of quarks. Although predicted for decades, pentaquarks proved surprisingly tricky to discover and some physicists were beginning to suspect that an unknown law of nature prevented their production. # We hope you enjoy the new releases! Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation. https://www.python.org/psf/ Your friendly release team, Ned Deily @nad https://discuss.python.org/u/nad Steve Dower @steve.dower https://discuss.python.org/u/steve.dower Pablo Galindo Salgado @pablogsal https://discuss.python.org/u/pablogsal -- https://mail.python.org/mailman/listinfo/python-list From axy at declassed.art Tue Aug 2 01:44:53 2022 From: axy at declassed.art (Axy) Date: Mon, 1 Aug 2022 22:44:53 -0700 Subject: Clabate: minimalistic class-based templates for Python Message-ID: <276b9df7-64e5-2d3e-7af7-1751d52ef2e6@declassed.art> Hi all, this is a test message after tweaking my self-hosted mail server and the subject is just in case if you receive it https://declassed.art/en/blog/2022/06/29/clabate-class-based-templates Previously I tried to reply to someone here but the message was rejected. Did not post to mail lists from my own mail server before, and this is the only problem left to dig in. Sorry for bothering. Axy From loris.bennett at fu-berlin.de Wed Aug 3 09:18:21 2022 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Wed, 03 Aug 2022 15:18:21 +0200 Subject: 2 options both mutually exclusive with respect to 3rd option Message-ID: <87bkt1xy76.fsf@hornfels.zedat.fu-berlin.de> Hi, I want to plot some data which are collected over time. I either want to specify start and/or end times for the plot, or specify last week, month or year. So the usage would look like: plot_data [[--start START --end END] | --last LAST ] I know about argsparse's mutually exclusive group, but this creates a group of option with are all mutually exclusive amoungst each other. I want both --start and --end to be mutually exclusive with respect to --last. Can I achieve this directly with argsparse, or do I just have to check the options by hand? Cheers, Loris -- This signature is currently under construction. From lsvalgaard at gmail.com Wed Aug 3 12:31:01 2022 From: lsvalgaard at gmail.com (Leif Svalgaard) Date: Wed, 3 Aug 2022 09:31:01 -0700 Subject: Python-list Digest, Vol 227, Issue 3 In-Reply-To: References: Message-ID: I also get 'file not found' when trying to let Spyder [v5.2] select the newly installed 3.10.6, and the path length is a lot less than 256. On Wed, Aug 3, 2022 at 9:03 AM wrote: > Send Python-list mailing list submissions to > python-list at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/python-list > or, via email, send a message with subject or body 'help' to > python-list-request at python.org > > You can reach the person managing the list at > python-list-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-list digest..." > Today's Topics: > > 1. RE: [RELEASE] Python 3.10.6 is available (jschwar at sbcglobal.net) > 2. Clabate: minimalistic class-based templates for Python (Axy) > 3. Re: Dictionary order? (Stefan Ram) > > > > ---------- Forwarded message ---------- > From: > To: "'Pablo Galindo Salgado'" , "'Python Dev'" < > python-dev at python.org>, , "'python-committers'" < > python-committers at python.org>, > Cc: > Bcc: > Date: Tue, 2 Aug 2022 12:13:16 -0500 > Subject: RE: [RELEASE] Python 3.10.6 is available > Does anyone know if this is being worked on? > https://github.com/python/cpython/issues/90242 > > It was originally reported here: https://bugs.python.org/issue46084 > > > -----Original Message----- > From: Python-list > On Behalf Of Pablo Galindo Salgado > Sent: Tuesday, August 2, 2022 5:13 AM > To: Python Dev ; python-list at python.org; > python-committers ; > python-announce at python.org > Subject: [RELEASE] Python 3.10.6 is available > > Here you have a nice package of 200 commits of bugfixes and documentation > improvements freshly made for Python 3.10. Go and download it when is still > hot: > > https://www.python.org/downloads/release/python-3106/ > > ## This is the sixth maintenance release of Python 3.10 > > Python 3.10.6 is the newest major release of the Python programming > language, and it contains many new features and optimizations. > > # Major new features of the 3.10 series, compared to 3.9 > > Among the new major new features and changes so far: > > * [PEP 623](https://www.python.org/dev/peps/pep-0623/) -- Deprecate and > prepare for the removal of the wstr member in PyUnicodeObject. > * [PEP 604](https://www.python.org/dev/peps/pep-0604/) -- Allow writing > union types as X | Y > * [PEP 612](https://www.python.org/dev/peps/pep-0612/) -- Parameter > Specification Variables > * [PEP 626](https://www.python.org/dev/peps/pep-0626/) -- Precise line > numbers for debugging and other tools. > * [PEP 618 ](https://www.python.org/dev/peps/pep-0618/) -- Add Optional > Length-Checking To zip. > * [bpo-12782](https://bugs.python.org/issue12782): Parenthesized context > managers are now officially allowed. > * [PEP 632 ](https://www.python.org/dev/peps/pep-0632/) -- Deprecate > distutils module. > * [PEP 613 ](https://www.python.org/dev/peps/pep-0613/) -- Explicit Type > Aliases > * [PEP 634 ](https://www.python.org/dev/peps/pep-0634/) -- Structural > Pattern Matching: Specification > * [PEP 635 ](https://www.python.org/dev/peps/pep-0635/) -- Structural > Pattern Matching: Motivation and Rationale > * [PEP 636 ](https://www.python.org/dev/peps/pep-0636/) -- Structural > Pattern Matching: Tutorial > * [PEP 644 ](https://www.python.org/dev/peps/pep-0644/) -- Require OpenSSL > 1.1.1 or newer > * [PEP 624 ](https://www.python.org/dev/peps/pep-0624/) -- Remove > Py_UNICODE encoder APIs > * [PEP 597 ](https://www.python.org/dev/peps/pep-0597/) -- Add optional > EncodingWarning > > [bpo-38605](https://bugs.python.org/issue38605): `from __future__ import > annotations` ([PEP 563](https://www.python.org/dev/peps/pep-0563/)) used > to be on this list in previous pre-releases but it has been postponed to > Python 3.11 due to some compatibility concerns. You can read the Steering > Council communication about it [here]( > > https://mail.python.org/archives/list/python-dev at python.org/thread/CLVXXPQ2T2LQ5MP2Y53VVQFCXYWQJHKZ/ > ) > to learn more. > > # More resources > > * [Changelog]( > https://docs.python.org/3.10/whatsnew/changelog.html#changelog > ) > * [Online Documentation](https://docs.python.org/3.10/) > * [PEP 619](https://www.python.org/dev/peps/pep-0619/), 3.10 Release > Schedule > * Report bugs at [https://bugs.python.org](https://bugs.python.org). > * [Help fund Python and its community](/psf/donations/). > > # And now for something completely different A pentaquark is a human-made > subatomic particle, consisting of four quarks and one antiquark bound > together; they are not known to occur naturally or exist outside of > experiments to create them. As quarks have a baryon number of (+1/3), and > antiquarks of (?1/3), the pentaquark would have a total baryon number of 1 > and thus would be a baryon. Further, because it has five quarks instead of > the usual three found in regular baryons (a.k.a. > 'triquarks'), it is classified as an exotic baryon. The name pentaquark > was coined by Claude Gignoux et al. (1987) and Harry J. Lipkin in 1987; > however, the possibility of five-quark particles was identified as early as > 1964 when Murray Gell-Mann first postulated the existence of quarks. > Although predicted for decades, pentaquarks proved surprisingly tricky to > discover and some physicists were beginning to suspect that an unknown law > of nature prevented their production. > > > # We hope you enjoy the new releases! > > Thanks to all of the many volunteers who help make Python Development and > these releases possible! Please consider supporting our efforts by > volunteering yourself or through organization contributions to the Python > Software Foundation. > > https://www.python.org/psf/ > > Your friendly release team, > > Ned Deily @nad https://discuss.python.org/u/nad Steve Dower @steve.dower > https://discuss.python.org/u/steve.dower > Pablo Galindo Salgado @pablogsal https://discuss.python.org/u/pablogsal > -- > https://mail.python.org/mailman/listinfo/python-list > > > > > > ---------- Forwarded message ---------- > From: Axy > To: Python List > Cc: > Bcc: > Date: Mon, 1 Aug 2022 22:44:53 -0700 > Subject: Clabate: minimalistic class-based templates for Python > Hi all, > > this is a test message after tweaking my self-hosted mail server and the > subject is just in case if you receive it > > https://declassed.art/en/blog/2022/06/29/clabate-class-based-templates > > Previously I tried to reply to someone here but the message was > rejected. Did not post to mail lists from my own mail server before, and > this is the only problem left to dig in. > > Sorry for bothering. > > Axy > > > > > ---------- Forwarded message ---------- > From: Stefan Ram > To: python-list at python.org > Cc: > Bcc: > Date: 2 Aug 2022 10:16:50 GMT > Subject: Re: Dictionary order? > Dan Stromberg writes: > >What am I missing? > > Modern Python Dictionaries A confluence of a dozen great ideas > - Raymond Hettinger (2017) > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Leif leif at leif.org From tdtemccna at gmail.com Wed Aug 3 22:22:41 2022 From: tdtemccna at gmail.com (Turritopsis Dohrnii Teo En Ming) Date: Thu, 4 Aug 2022 10:22:41 +0800 Subject: Which linux distro is more conducive for learning the Python programming language? Message-ID: Subject: Which linux distro is more conducive for learning the Python programming language? Good day from Singapore, May I know which linux distro is more conducive for learning the Python programming language? Since I have absolutely and totally FREE RHEL developer subscription (I don't need to spend a single cent), can I use Red Hat Enterprise Linux version 9.0 to learn Python? Is it the most popular linux distro for learning Python? I just want to know which linux distro and version is more conducive for learning Python. Because there are thousands of linux distros out there. And I just want to settle down on a particular linux distro and version. Thank you. Regards, Mr. Turritopsis Dohrnii Teo En Ming Targeted Individual in Singapore 4 Aug 2022 Thursday Blogs: https://tdtemcerts.blogspot.com https://tdtemcerts.wordpress.com From pbryan at anode.ca Wed Aug 3 22:31:13 2022 From: pbryan at anode.ca (Paul Bryan) Date: Wed, 03 Aug 2022 19:31:13 -0700 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: References: Message-ID: I wouldn't say any particular Linux distribution is appreciably better for Python development than another. I would suggest using a version of a Linux distribution that supports a recent Python release (e.g. 3.9 or 3.10). On Thu, 2022-08-04 at 10:22 +0800, Turritopsis Dohrnii Teo En Ming wrote: > Subject: Which linux distro is more conducive for learning the Python > programming language? > > Good day from Singapore, > > May I know which linux distro is more conducive for learning the > Python programming language? > > Since I have absolutely and totally FREE RHEL developer subscription > (I don't need to spend a single cent), can I use Red Hat Enterprise > Linux version 9.0 to learn Python? > > Is it the most popular linux distro for learning Python? > > I just want to know which linux distro and version is more conducive > for learning Python. Because there are thousands of linux distros out > there. And I just want to settle down on a particular linux distro > and > version. > > Thank you. > > Regards, > > Mr. Turritopsis Dohrnii Teo En Ming > Targeted Individual in Singapore > 4 Aug 2022 Thursday > Blogs: > https://tdtemcerts.blogspot.com > https://tdtemcerts.wordpress.com From tdtemccna at gmail.com Wed Aug 3 22:36:17 2022 From: tdtemccna at gmail.com (Turritopsis Dohrnii Teo En Ming) Date: Thu, 4 Aug 2022 10:36:17 +0800 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: References: Message-ID: I actually did a Google search for "which linux distro is best for python". Link: https://www.google.com/search?q=which+linux+distro+is+best+for+python&rlz=1C1GCEA_enSG1005SG1005&sxsrf=ALiCzsYaL58MJsevR2Uc0nnWtmc7kWFbIg%3A1659580387580&ei=4y_rYqWII8i7z7sPwPCtwAI&ved=0ahUKEwjlhenbkqz5AhXI3XMBHUB4CygQ4dUDCA8&uact=5&oq=which+linux+distro+is+best+for+python&gs_lcp=Cgdnd3Mtd2l6EAMyBQgAEIAEMgUIABCGAzIFCAAQhgMyBQgAEIYDMgUIABCGAzoECCMQJzoECAAQQzoLCAAQgAQQsQMQgwE6CAgAEIAEELEDOggILhCABBCxAzoFCAAQkQI6BQguEIAEOgsILhCABBDHARCvAToKCAAQgAQQhwIQFDoGCAAQHhAWSgQIQRgASgQIRhgAUABYljtg0D5oAXABeACAAesBiAG3E5IBBjM3LjAuMZgBAKABAcABAQ&sclient=gws-wiz Mr. Turritopsis Dohrnii Teo En Ming Targeted Individual in Singapore On Thu, 4 Aug 2022 at 10:31, Paul Bryan wrote: > > I wouldn't say any particular Linux distribution is appreciably better for Python development than another. I would suggest using a version of a Linux distribution that supports a recent Python release (e.g. 3.9 or 3.10). > > On Thu, 2022-08-04 at 10:22 +0800, Turritopsis Dohrnii Teo En Ming wrote: > > Subject: Which linux distro is more conducive for learning the Python > programming language? > > Good day from Singapore, > > May I know which linux distro is more conducive for learning the > Python programming language? > > Since I have absolutely and totally FREE RHEL developer subscription > (I don't need to spend a single cent), can I use Red Hat Enterprise > Linux version 9.0 to learn Python? > > Is it the most popular linux distro for learning Python? > > I just want to know which linux distro and version is more conducive > for learning Python. Because there are thousands of linux distros out > there. And I just want to settle down on a particular linux distro and > version. > > Thank you. > > Regards, > > Mr. Turritopsis Dohrnii Teo En Ming > Targeted Individual in Singapore > 4 Aug 2022 Thursday > Blogs: > https://tdtemcerts.blogspot.com > https://tdtemcerts.wordpress.com > > From ceo at teo-en-ming-corp.com Wed Aug 3 22:01:24 2022 From: ceo at teo-en-ming-corp.com (Turritopsis Dohrnii Teo En Ming) Date: Thu, 04 Aug 2022 10:01:24 +0800 Subject: Which linux distro is more conducive for learning the Python programming language? Message-ID: <6925a2865417ad64c41cfb3f5a509dfb@teo-en-ming-corp.com> Subject: Which linux distro is more conducive for learning the Python programming language? Good day from Singapore, May I know which linux distro is more conducive for learning the Python programming language? Since I have absolutely and totally FREE RHEL developer subscription (I don't need to spend a single cent), can I use Red Hat Enterprise Linux version 9.0 to learn Python? Is it the most popular linux distro for learning Python? I just want to know which linux distro and version is more conducive for learning Python. Because there are thousands of linux distros out there. And I just want to settle down on a particular linux distro and version. Thank you. Regards, Mr. Turritopsis Dohrnii Teo En Ming Targeted Individual in Singapore 4 Aug 2022 Thursday Blogs: https://tdtemcerts.blogspot.com https://tdtemcerts.wordpress.com From PythonList at DancesWithMice.info Wed Aug 3 23:03:58 2022 From: PythonList at DancesWithMice.info (dn) Date: Thu, 4 Aug 2022 15:03:58 +1200 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: References: Message-ID: <817fc64a-15c4-c713-6451-128224da80ed@DancesWithMice.info> On 04/08/2022 14.31, Paul Bryan wrote: > I wouldn't say any particular Linux distribution is appreciably better > for Python development than another. I would suggest using a version of > a Linux distribution that supports a recent Python release (e.g. 3.9 or > 3.10). +1 As a Python-learner (there's no comment about current programming expertise), it is unlikely to make any difference which Linux distro is used. Answers to such open-ended questions are usually seated in bias - which in-turn is mostly likely to be the same answer as 'which is the Linux distro *I* use? (I've used a number, with Python, over the years) The better alignment is to match the version of Python with the book or course you are using as learning-materials. That way, there are unlikely to be surprises. There are differences in Python implementations between Linux, Mac, and Windows. However, I can't think of a book or course which spends any time discussing them, or having a chapter which demands one or other OpSys. When you become more experienced two things will happen: firstly you will start using tools which enable the use of different versions of Python for different dev.projects; and secondly you will form your own opinions of "best"! (it's not difficult to change distro) PS most of us will qualify for RedHat's Developer program[me] and free copies of software. -- Regards, =dn From kushal at locationd.net Thu Aug 4 00:56:14 2022 From: kushal at locationd.net (Kushal Kumaran) Date: Wed, 03 Aug 2022 21:56:14 -0700 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: (Turritopsis Dohrnii Teo En Ming's message of "Thu, 4 Aug 2022 10:22:41 +0800") References: Message-ID: <8735ectxn5.fsf@locationd.net> On Thu, Aug 04 2022 at 10:22:41 AM, Turritopsis Dohrnii Teo En Ming wrote: > Subject: Which linux distro is more conducive for learning the Python > programming language? > > Good day from Singapore, > > May I know which linux distro is more conducive for learning the > Python programming language? > > Since I have absolutely and totally FREE RHEL developer subscription > (I don't need to spend a single cent), can I use Red Hat Enterprise > Linux version 9.0 to learn Python? > > Is it the most popular linux distro for learning Python? > > I just want to know which linux distro and version is more conducive > for learning Python. Because there are thousands of linux distros out > there. And I just want to settle down on a particular linux distro and > version. > The best one would be whatever you happen to have installed and for which you understand system administration. Beyond that, distribution choice matters very little. Every distribution I've used ships python3 packages, which was fine for learning the language. -- regards, kushal From sjeik_appie at hotmail.com Thu Aug 4 03:41:00 2022 From: sjeik_appie at hotmail.com (Albert-Jan Roskam) Date: Thu, 04 Aug 2022 09:41:00 +0200 Subject: Register multiple excepthooks? In-Reply-To: <25320.3769.224412.136125@ixdm.fritz.box> Message-ID: On Aug 1, 2022 19:34, Dieter Maurer wrote: Albert-Jan Roskam wrote at 2022-7-31 11:39 +0200: >?? I have a function init_logging.log_uncaught_errors() that I use for >?? sys.excepthook. Now I also want to call another function (ffi.dlclose()) >?? upon abnormal termination. Is it possible to register multiple >?? excepthooks, like with atexit.register? Or should I rename/redefine >?? log_uncaught_errors() so it does both things? `sys.excepthook` is a single function (not a list of them). This means: at any moment a single `excepthook` is effective. If you need a modular design, use a dispatcher function as your `excepthook` associated with a registry (e.g. a `list`). The dispatcher can then call all registered function. ==== Thank you both. I'll give this a try. I think it would be nice if the standard library function atexit.register would be improved, such that the registered functions would not only be called upon (a) normal program termination, but that one could also register functions that are called (b) upon error (c) unconditionally. Much like (a) try - (b) except - (c) finally. From tdtemccna at gmail.com Thu Aug 4 04:36:27 2022 From: tdtemccna at gmail.com (Turritopsis Dohrnii Teo En Ming) Date: Thu, 4 Aug 2022 16:36:27 +0800 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: References: Message-ID: On Thu, 4 Aug 2022 at 10:47, orzodk wrote: > > Turritopsis Dohrnii Teo En Ming writes: > > > noted with thanks. I have been using Linux for more than 10 years already > > Ah, if you're familiar with Redhat (RPM) based distributions, consider > Fedora as you will have access to newer versions sooner. > > If you're more familiar with Debian (DEB) based distributions, consider > Ubuntu, again, as the new version release cycle is twice a year. > > (Also, my apologies -- I meant to CC the list but failed to do so.) I am actually quite familiar with many linux distros. I am familiar with RPM-based linux distros as well as DEB-based linux distros. Mr. Turritopsis Dohrnii Teo En Ming Targeted Individual in Singapore From tdtemccna at gmail.com Thu Aug 4 04:41:54 2022 From: tdtemccna at gmail.com (Turritopsis Dohrnii Teo En Ming) Date: Thu, 4 Aug 2022 16:41:54 +0800 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: <817fc64a-15c4-c713-6451-128224da80ed@DancesWithMice.info> References: <817fc64a-15c4-c713-6451-128224da80ed@DancesWithMice.info> Message-ID: On Thu, 4 Aug 2022 at 11:05, dn wrote: > > On 04/08/2022 14.31, Paul Bryan wrote: > > I wouldn't say any particular Linux distribution is appreciably better > > for Python development than another. I would suggest using a version of > > a Linux distribution that supports a recent Python release (e.g. 3.9 or > > 3.10). > > +1 > > As a Python-learner (there's no comment about current programming > expertise), it is unlikely to make any difference which Linux distro is > used. > > Answers to such open-ended questions are usually seated in bias - which > in-turn is mostly likely to be the same answer as 'which is the Linux > distro *I* use? > (I've used a number, with Python, over the years) > > The better alignment is to match the version of Python with the book or > course you are using as learning-materials. That way, there are unlikely > to be surprises. Noted on this. > > There are differences in Python implementations between Linux, Mac, and > Windows. However, I can't think of a book or course which spends any > time discussing them, or having a chapter which demands one or other OpSys. > > When you become more experienced two things will happen: firstly you > will start using tools which enable the use of different versions of > Python for different dev.projects; and secondly you will form your own > opinions of "best"! > (it's not difficult to change distro) > > > PS most of us will qualify for RedHat's Developer program[me] and free > copies of software. I can download free copies of RHEL 7.x, 8.x, and 9.x :) Just that I dunno which RHEL version is better. Is RHEL 9.0 the best out of 7.x, 8.x and 9.x? > -- > Regards, > =dn Regards, Mr. Turritopsis Dohrnii Teo En Ming Targeted Individual in Singapore From tdtemccna at gmail.com Thu Aug 4 04:45:03 2022 From: tdtemccna at gmail.com (Turritopsis Dohrnii Teo En Ming) Date: Thu, 4 Aug 2022 16:45:03 +0800 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: <8735ectxn5.fsf@locationd.net> References: <8735ectxn5.fsf@locationd.net> Message-ID: On Thu, 4 Aug 2022 at 13:02, Kushal Kumaran wrote: > > On Thu, Aug 04 2022 at 10:22:41 AM, Turritopsis Dohrnii Teo En Ming wrote: > > Subject: Which linux distro is more conducive for learning the Python > > programming language? > > > > Good day from Singapore, > > > > May I know which linux distro is more conducive for learning the > > Python programming language? > > > > Since I have absolutely and totally FREE RHEL developer subscription > > (I don't need to spend a single cent), can I use Red Hat Enterprise > > Linux version 9.0 to learn Python? > > > > Is it the most popular linux distro for learning Python? > > > > I just want to know which linux distro and version is more conducive > > for learning Python. Because there are thousands of linux distros out > > there. And I just want to settle down on a particular linux distro and > > version. > > > > The best one would be whatever you happen to have installed and for > which you understand system administration. Beyond that, distribution > choice matters very little. Every distribution I've used ships python3 > packages, which was fine for learning the language. > > -- > regards, > kushal Noted with thanks Kushal. Since I can download FREE copies of RHEL 9.0, I will use it then. Mr. Turritopsis Dohrnii Teo En Ming Targeted Individual in Singapore From PythonList at DancesWithMice.info Thu Aug 4 04:50:41 2022 From: PythonList at DancesWithMice.info (dn) Date: Thu, 4 Aug 2022 20:50:41 +1200 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: References: <817fc64a-15c4-c713-6451-128224da80ed@DancesWithMice.info> Message-ID: >> PS most of us will qualify for RedHat's Developer program[me] and free >> copies of software. > > I can download free copies of RHEL 7.x, 8.x, and 9.x :) Just that I > dunno which RHEL version is better. Is RHEL 9.0 the best out of 7.x, > 8.x and 9.x? RedHat is a stable OpSys. Accordingly, it doesn't much matter which version. The general assumption is that the more recent distribution has more advanced facilities, eg improved security features in RHEL9. As another post says, Fedora is closer to the bleeding-edge of Linux development. Be aware that there are many methods of adding Python. For example, if your training is based on the Anaconda [Python] distribution, then it is irrelevant which version of Python comes with the Linux distro. As mentioned before, if you advance to developing in [Python] virtual environments, then each of these could run a different version of Python. Similarly, using a VM... The question is relatively minor. More important to 'get going'! (also mentioned previously: relatively easy to change (Python or distro) 'later'!) -- Regards, =dn From tdtemccna at gmail.com Thu Aug 4 04:58:53 2022 From: tdtemccna at gmail.com (Turritopsis Dohrnii Teo En Ming) Date: Thu, 4 Aug 2022 16:58:53 +0800 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: References: <817fc64a-15c4-c713-6451-128224da80ed@DancesWithMice.info> Message-ID: On Thu, 4 Aug 2022 at 16:50, dn wrote: > > >> PS most of us will qualify for RedHat's Developer program[me] and free > >> copies of software. > > > > I can download free copies of RHEL 7.x, 8.x, and 9.x :) Just that I > > dunno which RHEL version is better. Is RHEL 9.0 the best out of 7.x, > > 8.x and 9.x? > > RedHat is a stable OpSys. Accordingly, it doesn't much matter which > version. The general assumption is that the more recent distribution has > more advanced facilities, eg improved security features in RHEL9. > > As another post says, Fedora is closer to the bleeding-edge of Linux > development. RHEL 9.0 is also quite close to the bleeding edge of Linux development. It has Linux kernel version 5.14.0. > > Be aware that there are many methods of adding Python. For example, if > your training is based on the Anaconda [Python] distribution, then it is > irrelevant which version of Python comes with the Linux distro. As > mentioned before, if you advance to developing in [Python] virtual > environments, then each of these could run a different version of > Python. Similarly, using a VM... > > The question is relatively minor. More important to 'get going'! I am going to get going on learning Python with RHEL 9.0. > (also mentioned previously: relatively easy to change (Python or distro) > 'later'!) > -- > Regards, > =dn Regards, Mr. Turritopsis Dohrnii Teo En Ming Targeted Individual in Singapore From gweatherby at uchc.edu Thu Aug 4 06:57:49 2022 From: gweatherby at uchc.edu (Weatherby,Gerard) Date: Thu, 4 Aug 2022 10:57:49 +0000 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: References: <817fc64a-15c4-c713-6451-128224da80ed@DancesWithMice.info> Message-ID: Just be aware https://docs.python.org/3/ defaults to the latest Python version (3.10). When looking up a module, it?s best to explicitly set the documentation to the version you are using. It won?t matter the vast majority of the time but I have been burned by trying to use a function or parameter that was introduced with a later version. ? Gerard Weatherby | Application Architect NMRbox | NAN | Department of Molecular Biology and Biophysics UConn Health 263 Farmington Avenue, Farmington, CT 06030-6406 uchc.edu On Aug 4, 2022, 5:00 AM -0400, Turritopsis Dohrnii Teo En Ming , wrote: *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** On Thu, 4 Aug 2022 at 16:50, dn wrote: PS most of us will qualify for RedHat's Developer program[me] and free copies of software. I can download free copies of RHEL 7.x, 8.x, and 9.x :) Just that I dunno which RHEL version is better. Is RHEL 9.0 the best out of 7.x, 8.x and 9.x? RedHat is a stable OpSys. Accordingly, it doesn't much matter which version. The general assumption is that the more recent distribution has more advanced facilities, eg improved security features in RHEL9. As another post says, Fedora is closer to the bleeding-edge of Linux development. RHEL 9.0 is also quite close to the bleeding edge of Linux development. It has Linux kernel version 5.14.0. Be aware that there are many methods of adding Python. For example, if your training is based on the Anaconda [Python] distribution, then it is irrelevant which version of Python comes with the Linux distro. As mentioned before, if you advance to developing in [Python] virtual environments, then each of these could run a different version of Python. Similarly, using a VM... The question is relatively minor. More important to 'get going'! I am going to get going on learning Python with RHEL 9.0. (also mentioned previously: relatively easy to change (Python or distro) 'later'!) -- Regards, =dn Regards, Mr. Turritopsis Dohrnii Teo En Ming Targeted Individual in Singapore -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!mxIe1U15eEI7AomZUwIzjK0lVTfFXHto6Atu7jqaE58V0YUQc2K8s9LrjPDNjOXjQ5NB3Tu-cqbRDnx0pmu6$ From 2QdxY4RzWzUUiLuE at potatochowder.com Thu Aug 4 07:13:28 2022 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Thu, 4 Aug 2022 06:13:28 -0500 Subject: Register multiple excepthooks? In-Reply-To: References: <25320.3769.224412.136125@ixdm.fritz.box> Message-ID: On 2022-08-04 at 09:41:00 +0200, Albert-Jan Roskam wrote: > Thank you both. I'll give this a try. I think it would be nice if > the standard library function atexit.register would be improved, > such that the registered functions would not only be called upon > (a) normal program termination, but that one could also register > functions that are called (b) upon error (c) unconditionally. Much > like (a) try - (b) except - (c) finally. There. You've just designed the top level of a better behaved, more robust application (completely untested): on_normal_exit_funcs = list() on_error_exit_funcs = list() on_any_exit_funcs = list() def run_exit_funcs(exit_funcs): for func in exit_funcs: try: func() except e: maybe_do_some_logging(e) try: run_the_application() run_exit_funcs(on_normal_exit_funcs) except: run_exit_funcs(on_error_exit_funcs) finally: run_exit_funcs(on_any_exit_funcs) def register_normal_exit_func(f): on_normal_exit_funcs.append(f) def register_error_exit_func(f): on_error_exit_funcs.append(f) def register_any_exit_func(f): on_any_exit_funcs.append(f) No, really. There are worse ways to build an extremely generic, fairly minimalist application framework. Season to taste,? add it to your personal (or company) toolbox, and refine and improve it as things come up. You may discover some number of common exit functions that are useful across appliations, too. ? are you object oriented, functional, imperative, or something else? do you like long names, short names, names that follow some existing coding standard, non-English names? do you have a standardized logging/exception library? From grant.b.edwards at gmail.com Thu Aug 4 10:34:48 2022 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 04 Aug 2022 07:34:48 -0700 (PDT) Subject: Which linux distro is more conducive for learning the Python programming language? References: Message-ID: <62ebd908.c80a0220.9175a.1dcf@mx.google.com> On 2022-08-04, Turritopsis Dohrnii Teo En Ming wrote: > Subject: Which linux distro is more conducive for learning the Python > programming language? You can learn Python on any Linux distribution. First answer this question: * Whom are you going to ask for help when you run into Linux questions? Install the Linux distro that person uses. -- Grant From maharajashiv1532 at outlook.com Thu Aug 4 09:33:46 2022 From: maharajashiv1532 at outlook.com (MahaRaja Shiv) Date: Thu, 4 Aug 2022 13:33:46 +0000 Subject: My application failed to start because no Qt platform plugin could be initialized. Reinstalled the application several times my problem didn't got fixed. Message-ID: Sent from Mail for Windows From loris.bennett at fu-berlin.de Thu Aug 4 07:51:24 2022 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Thu, 04 Aug 2022 13:51:24 +0200 Subject: Exclude 'None' from list comprehension of dicts Message-ID: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> Hi, I am constructing a list of dictionaries via the following list comprehension: data = [get_job_efficiency_dict(job_id) for job_id in job_ids] However, get_job_efficiency_dict(job_id) uses 'subprocess.Popen' to run an external program and this can fail. In this case, the dict should just be omitted from 'data'. I can have 'get_job_efficiency_dict' return 'None' and then run filtered_data = list(filter(None, data)) but is there a more elegant way? Cheers, Loris -- This signature is currently under construction. From loris.bennett at fu-berlin.de Thu Aug 4 08:58:28 2022 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Thu, 04 Aug 2022 14:58:28 +0200 Subject: Exclude 'None' from list comprehension of dicts References: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <87sfmcjhcb.fsf@hornfels.zedat.fu-berlin.de> ram at zedat.fu-berlin.de (Stefan Ram) writes: > "Loris Bennett" writes: >>data = [get_job_efficiency_dict(job_id) for job_id in job_ids] > ... >>filtered_data = list(filter(None, data)) > > You could have "get_job_efficiency_dict" return an iterable > that yields either zero dictionaries or one dictionary. > For example, a list with either zero entries or one entry. > > Then, use "itertools.chain.from_iterable" to merge all those > lists with empty lists effectively removed. E.g., > > print( list( itertools.chain.from_iterable( [[ 1 ], [], [ 2 ], [ 3 ]]))) > > will print > > [1, 2, 3] 'itertool' is a bit of a blind-spot of mine, so thanks for pointing that out. > . Or, consider a boring old "for" loop: > > data = [] > for job_id in job_ids: > dictionary = get_job_efficiency_dict( job_id ) > if dictionary: > data.append( dictionary ) > > . It might not be "elegant", but it's quite readable to me. To me to. However, 'data' can occasionally consist of many 10,000s of elements. Would there be a potential performance problem here? Even if there is, it wouldn't be so bad, as the aggregation of the data is not time-critical and only occurs once a month. Still, I wouldn't want the program to be unnecessarily inefficient. Cheers, Loris -- This signature is currently under construction. From toby at tobiah.org Thu Aug 4 10:51:53 2022 From: toby at tobiah.org (Tobiah) Date: Thu, 4 Aug 2022 07:51:53 -0700 Subject: Which linux distro is more conducive for learning the Python programming language? References: <6925a2865417ad64c41cfb3f5a509dfb@teo-en-ming-corp.com> Message-ID: On 8/3/22 19:01, Turritopsis Dohrnii Teo En Ming wrote: > Subject: Which linux distro is more conducive for learning the Python programming language? You might try Pythontu. Not really. Get the distro that looks appealing to you. One won't be better than the other with regard to learning python. > Good day from Singapore, > > May I know which linux distro is more conducive for learning the Python programming language? > > Since I have absolutely and totally FREE RHEL developer subscription (I don't need to spend a single cent), can I use Red Hat Enterprise Linux version 9.0 to learn Python? > > Is it the most popular linux distro for learning Python? > > I just want to know which linux distro and version is more conducive for learning Python. Because there are thousands of linux distros out there. And I just want to settle down on a particular linux distro and version. > > Thank you. > > Regards, > > Mr. Turritopsis Dohrnii Teo En Ming > Targeted Individual in Singapore > 4 Aug 2022 Thursday > Blogs: > https://tdtemcerts.blogspot.com > https://tdtemcerts.wordpress.com From barry at barrys-emacs.org Thu Aug 4 14:12:17 2022 From: barry at barrys-emacs.org (Barry) Date: Thu, 4 Aug 2022 19:12:17 +0100 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: References: Message-ID: > On 4 Aug 2022, at 09:48, Turritopsis Dohrnii Teo En Ming wrote: > > ?On Thu, 4 Aug 2022 at 13:02, Kushal Kumaran wrote: >> >>> On Thu, Aug 04 2022 at 10:22:41 AM, Turritopsis Dohrnii Teo En Ming wrote: >>> Subject: Which linux distro is more conducive for learning the Python >>> programming language? >>> >>> Good day from Singapore, >>> >>> May I know which linux distro is more conducive for learning the >>> Python programming language? >>> >>> Since I have absolutely and totally FREE RHEL developer subscription >>> (I don't need to spend a single cent), can I use Red Hat Enterprise >>> Linux version 9.0 to learn Python? >>> >>> Is it the most popular linux distro for learning Python? >>> >>> I just want to know which linux distro and version is more conducive >>> for learning Python. Because there are thousands of linux distros out >>> there. And I just want to settle down on a particular linux distro and >>> version. >>> >> >> The best one would be whatever you happen to have installed and for >> which you understand system administration. Beyond that, distribution >> choice matters very little. Every distribution I've used ships python3 >> packages, which was fine for learning the language. >> >> -- >> regards, >> kushal > > Noted with thanks Kushal. Since I can download FREE copies of RHEL > 9.0, I will use it then. I consider rhel 9 is an old os. I would suggest using fedora over rhel. Fedora 36 has python 3.10 and the when fedora 37 is released it will have python 3.11. And fedora is free as well. Barry > > Mr. Turritopsis Dohrnii Teo En Ming > Targeted Individual in Singapore > -- > https://mail.python.org/mailman/listinfo/python-list > From christian at python.org Thu Aug 4 14:33:13 2022 From: christian at python.org (Christian Heimes) Date: Thu, 4 Aug 2022 20:33:13 +0200 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: References: Message-ID: <0aa3498a-ccec-c013-6829-d2e17ae51506@python.org> On 04/08/2022 20.12, Barry wrote: >> Noted with thanks Kushal. Since I can download FREE copies of RHEL >> 9.0, I will use it then. > > I consider rhel 9 is an old os. I would suggest using fedora over rhel. > Fedora 36 has python 3.10 and the when fedora 37 is released it will have python 3.11. > And fedora is free as well. Fedora is an excellent choice for Python users. Fedora 36 already comes with Python 3.11.0b5 in its main repository. In fact you have Python 2.7, 3.5-3.11, PyPy 2.7, PyPy 3.7-3.9, and MicroPython at your fingertips. Christian From antoon.pardon at vub.be Thu Aug 4 14:35:55 2022 From: antoon.pardon at vub.be (Antoon Pardon) Date: Thu, 4 Aug 2022 20:35:55 +0200 Subject: Exclude 'None' from list comprehension of dicts In-Reply-To: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> References: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <137bc40d-4545-226b-44d0-4770dcd8fea6@vub.be> Op 4/08/2022 om 13:51 schreef Loris Bennett: > Hi, > > I am constructing a list of dictionaries via the following list > comprehension: > > data = [get_job_efficiency_dict(job_id) for job_id in job_ids] > > However, > > get_job_efficiency_dict(job_id) > > uses 'subprocess.Popen' to run an external program and this can fail. > In this case, the dict should just be omitted from 'data'. > > I can have 'get_job_efficiency_dict' return 'None' and then run > > filtered_data = list(filter(None, data)) > > but is there a more elegant way? Just wondering, why don't you return an empty dictionary in case of a failure? In that case your list will be all dictionaries and empty ones will be processed fast enough. -- Antoon Pardon. From python at mrabarnett.plus.com Thu Aug 4 14:50:16 2022 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 4 Aug 2022 19:50:16 +0100 Subject: Exclude 'None' from list comprehension of dicts In-Reply-To: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> References: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> Message-ID: On 2022-08-04 12:51, Loris Bennett wrote: > Hi, > > I am constructing a list of dictionaries via the following list > comprehension: > > data = [get_job_efficiency_dict(job_id) for job_id in job_ids] > > However, > > get_job_efficiency_dict(job_id) > > uses 'subprocess.Popen' to run an external program and this can fail. > In this case, the dict should just be omitted from 'data'. > > I can have 'get_job_efficiency_dict' return 'None' and then run > > filtered_data = list(filter(None, data)) > > but is there a more elegant way? > I'm not sure how elegant it is, but: data = [result for job_id in job_ids if (result := get_job_efficiency_dict(job_id)) is not None] From grant.b.edwards at gmail.com Thu Aug 4 15:00:29 2022 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 04 Aug 2022 12:00:29 -0700 (PDT) Subject: Which linux distro is more conducive for learning the Python programming language? References: <0aa3498a-ccec-c013-6829-d2e17ae51506@python.org> Message-ID: <62ec174d.c80a0220.b04eb.3ad1@mx.google.com> On 2022-08-04, Christian Heimes wrote: > Fedora is an excellent choice for Python users. Fedora 36 already comes > with Python 3.11.0b5 in its main repository. In fact you have Python > 2.7, 3.5-3.11, PyPy 2.7, PyPy 3.7-3.9, and MicroPython at your fingertips. Except that real programmers use Python 1.52 because they depend on the assumption that integers are native word size and arithmatic is done modulo-maxunsigned the same way it is in assembly language... ;) Honestly, back when I was implementing netowrk protocols in Python on a 32-bit machine, it was very useful having 32-bit Python integers. From gweatherby at uchc.edu Thu Aug 4 15:01:03 2022 From: gweatherby at uchc.edu (Weatherby,Gerard) Date: Thu, 4 Aug 2022 19:01:03 +0000 Subject: Exclude 'None' from list comprehension of dicts In-Reply-To: References: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> Message-ID: Or: data = [d for d in [get_job_efficiency_dict(job_id) for job_id in job_ids] if d is not None] or for job_id in job_ids: if (d := get_job_efficiency_dict(job_id)) is not None: data.append(d) Personally, I?d got with the latter in my own code. ? Gerard Weatherby | Application Architect NMRbox | NAN | Department of Molecular Biology and Biophysics UConn Health 263 Farmington Avenue, Farmington, CT 06030-6406 uchc.edu On Aug 4, 2022, 2:52 PM -0400, MRAB , wrote: *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** On 2022-08-04 12:51, Loris Bennett wrote: Hi, I am constructing a list of dictionaries via the following list comprehension: data = [get_job_efficiency_dict(job_id) for job_id in job_ids] However, get_job_efficiency_dict(job_id) uses 'subprocess.Popen' to run an external program and this can fail. In this case, the dict should just be omitted from 'data'. I can have 'get_job_efficiency_dict' return 'None' and then run filtered_data = list(filter(None, data)) but is there a more elegant way? I'm not sure how elegant it is, but: data = [result for job_id in job_ids if (result := get_job_efficiency_dict(job_id)) is not None] -- https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!iqxhYMoHcYQY1xohGCpafpBKZIUcGEV6Zj1-RLzOCF61TUXGr-8oh9HLuL-H8w4gxgDCypcOYOYkqNXLJxUIqhWd$ From avi.e.gross at gmail.com Thu Aug 4 16:22:45 2022 From: avi.e.gross at gmail.com (avi.e.gross at gmail.com) Date: Thu, 4 Aug 2022 16:22:45 -0400 Subject: Which linux distro is more conducive for learning the Python programming language? In-Reply-To: <62ebd908.c80a0220.9175a.1dcf@mx.google.com> References: <62ebd908.c80a0220.9175a.1dcf@mx.google.com> Message-ID: <007101d8a83f$f5b8e1d0$e12aa570$@gmail.com> To be clear, the discussion strikes me oddly. You can learn python without a computer. Of course to actually have people write code and try it out is another story. Python by itself is simply a program that can be typed into an interpreter or given a file to process and works just as well on LINUX, Windows and so on. I have half a dozen varieties on my machine from various modes/distributions. As some have pointed out, any RECENT version of python (presumably the 3 version unless your goal is to teach the older version) should be fine for teaching but obviously all kinds of tools can help. But there are online resources that may be adequate that require NOTHING but a browser: https://py3.codeskulptor.org/ The above URL allows you to create and run and save python files and is probably adequate for teaching basics and for sharing programs others have saved by sending you the URL. Of course, beyond a certain point, it fails to meet needs such as not supporting importing random modules. But as was discussed here before, you can find little time to teach python if you also have to teach every environment and editor and especially handle students using other choices. But to ask everyone to use the same LINUX distribution may also be a drastic step. The reality is that simple python programs can be handled with any standard text editor. Sure, lots of bells and whistles can be added and there may well be advantages to using systems ranging from anaconda to lately RSTUDIO but they often come with many superfluous features and lots of complexity. -----Original Message----- From: Python-list On Behalf Of Grant Edwards Sent: Thursday, August 4, 2022 10:35 AM To: python-list at python.org Subject: Re: Which linux distro is more conducive for learning the Python programming language? On 2022-08-04, Turritopsis Dohrnii Teo En Ming wrote: > Subject: Which linux distro is more conducive for learning the Python > programming language? You can learn Python on any Linux distribution. First answer this question: * Whom are you going to ask for help when you run into Linux questions? Install the Linux distro that person uses. -- Grant -- https://mail.python.org/mailman/listinfo/python-list From ojomooluwatolami675 at gmail.com Fri Aug 5 03:34:45 2022 From: ojomooluwatolami675 at gmail.com (ojomooluwatolami675 at gmail.com) Date: Fri, 5 Aug 2022 08:34:45 +0100 Subject: Trying to understand nested loops Message-ID: Hello, I?m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks var = 0 for i in range(3): for j in range(-2,-7,-2): var += 1 print(var) Sent from my iPhone From lal at solute.de Fri Aug 5 03:47:22 2022 From: lal at solute.de (Lars Liedtke) Date: Fri, 5 Aug 2022 09:47:22 +0200 Subject: Trying to understand nested loops In-Reply-To: References: Message-ID: Hello, this looks to me like it might be a piece of homework, as it would be given by teachers or professors. This list has got the rule, that members do not solve other's homework. Because very often homework is meant to sit down and think about it. But maybe I interpreted that wrongly, so if you could try to formulate in words what this loop does, I or other people on this list, will be pleased to show you where you might have got things wrong and how it really works. Cheers Lars -- Lars Liedtke Software Entwickler Phone: Fax: +49 721 98993- E-mail: lal at solute.de solute GmbH Zeppelinstra?e 15 76185 Karlsruhe Germany Marken der solute GmbH | brands of solute GmbH billiger.de | Shopping.de Gesch?ftsf?hrer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten Webseite | www.solute.de Sitz | Registered Office: Karlsruhe Registergericht | Register Court: Amtsgericht Mannheim Registernummer | Register No.: HRB 110579 USt-ID | VAT ID: DE234663798 Informationen zum Datenschutz | Information about privacy policy http://solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php Am 05.08.22 um 09:34 schrieb ojomooluwatolami675 at gmail.com: > Hello, I?m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks > > var = 0 > for i in range(3): > for j in range(-2,-7,-2): > var += 1 > print(var) > > Sent from my iPhone From frank at chagford.com Fri Aug 5 03:56:03 2022 From: frank at chagford.com (Frank Millman) Date: Fri, 5 Aug 2022 09:56:03 +0200 Subject: Trying to understand nested loops In-Reply-To: References: Message-ID: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> On 2022-08-05 9:34 AM, ojomooluwatolami675 at gmail.com wrote: > Hello, I?m new to learning python and I stumbled upon a question nested loops. This is the question below. Can you please how they arrived at 9 as the answer. Thanks > > var = 0 > for i in range(3): > for j in range(-2,-7,-2): > var += 1 > print(var) > Welcome to Python. I am sure you are going to enjoy it. To learn Python, you must learn to use the Python interactive prompt (also known as the REPL). Type 'python' at your console, and it should bring up something like this - C:\Users\E7280>python Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> The confusing part of your example above is 'for j in range(-2,-7,-2)'. To find out what it does, enter it at the '>>>' prompt - >>> for j in range(-2, -7, -2): ... print(j) ... -2 -4 -6 >>> For the purposes of your exercise, all you need to know at this stage is that it loops three times. Does that help answer your question? If not, feel free to come back with more questions. BTW, there is an indentation error in your original post - line 5 should line up with line 4. It is preferable to copy/paste your code into any messages posted here rather than type it in, as that avoids the possibility of any typos. Frank Millman From cs at cskk.id.au Fri Aug 5 04:30:05 2022 From: cs at cskk.id.au (Cameron Simpson) Date: Fri, 5 Aug 2022 18:30:05 +1000 Subject: Trying to understand nested loops In-Reply-To: References: Message-ID: On 05Aug2022 09:47, Lars Liedtke wrote: >this looks to me like it might be a piece of homework, as it would be >given by teachers or professors. > >This list has got the rule, that members do not solve other's >homework. Because very often homework is meant to sit down and think >about it. Very true. However, we're happy to help people understand things. In this case it look like Frank has provided apt advice, showing the OP how to see how many times the inner loop runs, which affects how many times `var+=1` occurs. Cheers, Cameron Simpson From gweatherby at uchc.edu Fri Aug 5 09:13:09 2022 From: gweatherby at uchc.edu (Weatherby,Gerard) Date: Fri, 5 Aug 2022 13:13:09 +0000 Subject: Trying to understand nested loops In-Reply-To: References: Message-ID: <797d3669-0161-4d4d-8704-07fb622ef812@Spark> It?s also a poor code example. Doing a pointless double loop is not good instructional practice, especially when simpler alternatives exist. e.g. for i in range(3): for j in range(-2.-7,-2): print(i +j ) ? Gerard Weatherby | Application Architect NMRbox | NAN | Department of Molecular Biology and Biophysics UConn Health 263 Farmington Avenue, Farmington, CT 06030-6406 uchc.edu On Aug 5, 2022, 4:38 AM -0400, ojomooluwatolami675 at gmail.com , wrote: var = 0 for i in range(3): for j in range(-2,-7,-2): var += 1 print(var) From dieter at handshake.de Fri Aug 5 13:38:05 2022 From: dieter at handshake.de (Dieter Maurer) Date: Fri, 5 Aug 2022 19:38:05 +0200 Subject: Trying to understand nested loops In-Reply-To: References: Message-ID: <25325.21885.560476.715686@ixdm.fritz.box> ojomooluwatolami675 at gmail.com wrote at 2022-8-5 08:34 +0100: >Hello, I?m new to learning python and I stumbled upon a question nested loops. For future, more complex, questions of this kind, you might have a look at the module `pdb` in Python's runtime library. It implements a debugger which allows you (among other features) to interactively run a program line by line and explore the state of all involved variables. There are also IDEs (= Integrated Development Environments) which support this. Whenever a program does things you do not understand, debugging usually helps to bring light into the scene. From loris.bennett at fu-berlin.de Fri Aug 5 01:50:25 2022 From: loris.bennett at fu-berlin.de (Loris Bennett) Date: Fri, 05 Aug 2022 07:50:25 +0200 Subject: Exclude 'None' from list comprehension of dicts References: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> <137bc40d-4545-226b-44d0-4770dcd8fea6@vub.be> Message-ID: <87czdf9r32.fsf@hornfels.zedat.fu-berlin.de> Antoon Pardon writes: > Op 4/08/2022 om 13:51 schreef Loris Bennett: >> Hi, >> >> I am constructing a list of dictionaries via the following list >> comprehension: >> >> data = [get_job_efficiency_dict(job_id) for job_id in job_ids] >> >> However, >> >> get_job_efficiency_dict(job_id) >> >> uses 'subprocess.Popen' to run an external program and this can fail. >> In this case, the dict should just be omitted from 'data'. >> >> I can have 'get_job_efficiency_dict' return 'None' and then run >> >> filtered_data = list(filter(None, data)) >> >> but is there a more elegant way? > > Just wondering, why don't you return an empty dictionary in case of a failure? > In that case your list will be all dictionaries and empty ones will be processed > fast enough. When the list of dictionaries is processed, I would have to check each element to see if it is empty. That strikes me as being less efficient than filtering out the empty dictionaries in one go, although obviously one would need to benchmark that. Cheers, Loris -- This signature is currently under construction. From NOTsomeone at microsoft.invalid Fri Aug 5 05:56:34 2022 From: NOTsomeone at microsoft.invalid (GB) Date: Fri, 5 Aug 2022 10:56:34 +0100 Subject: Trying to understand nested loops In-Reply-To: References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> Message-ID: On 05/08/2022 08:56, Frank Millman wrote: > BTW, there is an indentation error in your original post - line 5 should > line up with line 4. As a Python beginner, I find that Python is annoyingly picky about indents. And, the significance of indents is a bit of a minefield for beginners. For example, in the above code, the indent of the final line very significantly affects the results: print(var) print(var) print(var) These are all different. From grant.b.edwards at gmail.com Fri Aug 5 15:53:59 2022 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 05 Aug 2022 12:53:59 -0700 (PDT) Subject: Trying to understand nested loops References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> Message-ID: <62ed7557.050a0220.1d68f.2d24@mx.google.com> On 2022-08-05, GB wrote: >> BTW, there is an indentation error in your original post - line 5 >> should line up with line 4. > > As a Python beginner, I find that Python is annoyingly picky about > indents. And, the significance of indents is a bit of a minefield for > beginners. As a C beginner, you'll find that C is annoyingly picky about curly braces and semcolons. All programming languages are picky about syntax. > For example, in the above code, the indent of the final line very > significantly affects the results: > > print(var) > print(var) > print(var) > > These are all different. Indeed. It looks different, and it _is_ different. Seems like a good thing to me. I like programs to do what it looks like they are going to do. In C, this doesn't do what it looks like it's supposed to do. if (foo) do_this(); and_this(); then_do_this(); From avi.e.gross at gmail.com Fri Aug 5 16:44:37 2022 From: avi.e.gross at gmail.com (avi.e.gross at gmail.com) Date: Fri, 5 Aug 2022 16:44:37 -0400 Subject: Exclude 'None' from list comprehension of dicts In-Reply-To: <87czdf9r32.fsf@hornfels.zedat.fu-berlin.de> References: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> <137bc40d-4545-226b-44d0-4770dcd8fea6@vub.be> <87czdf9r32.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <01a101d8a90c$2d89d8e0$889d8aa0$@gmail.com> Benchmarking aside, Lori, there are some ideas about such things. You are describing a case, in abstract terms, where an algorithm grinds away and produces results that may include an occasional or a common unwanted result. The question is when to eliminate the unwanted. Do you eliminate them immediately at the expense of some extra code at that point, or do you want till much later or even at the end? The answer is it DEPENDS and let me point out that many problems can start multi-dimensional (as in processing a 5-D matrix) and produce a linear output (as in a 1-D list) or it can be the other way around. Sometimes what you want eliminated is something like duplicates. Is it easier to remove duplicates as they happen, or later when you have some huge data structure containing oodles of copies of each duplicate? You can imagine many scenarios and sometimes you need to also look at costs. What does it cost to check if a token is valid, as in can the word be found in a dictionary? Is it cheaper to wait till you have lots of words including duplicates and do one lookup to find a bad word then mark it so future occurrences are removed without that kind of lookup? Or is it better to read I the dictionary once and hash it so later access is easy? In your case, you have a single simple criterion for recognizing an item to leave out. So the above may not apply. But I note we often use pre-created software that simply returns a result and then the only reasonable way to remove things is after calling it. Empty or unwanted items may take up some room, though, so a long-running process may be better off pruning as it goes. -----Original Message----- From: Python-list On Behalf Of Loris Bennett Sent: Friday, August 5, 2022 1:50 AM To: python-list at python.org Subject: Re: Exclude 'None' from list comprehension of dicts Antoon Pardon writes: > Op 4/08/2022 om 13:51 schreef Loris Bennett: >> Hi, >> >> I am constructing a list of dictionaries via the following list >> comprehension: >> >> data = [get_job_efficiency_dict(job_id) for job_id in job_ids] >> >> However, >> >> get_job_efficiency_dict(job_id) >> >> uses 'subprocess.Popen' to run an external program and this can fail. >> In this case, the dict should just be omitted from 'data'. >> >> I can have 'get_job_efficiency_dict' return 'None' and then run >> >> filtered_data = list(filter(None, data)) >> >> but is there a more elegant way? > > Just wondering, why don't you return an empty dictionary in case of a failure? > In that case your list will be all dictionaries and empty ones will be > processed fast enough. When the list of dictionaries is processed, I would have to check each element to see if it is empty. That strikes me as being less efficient than filtering out the empty dictionaries in one go, although obviously one would need to benchmark that. Cheers, Loris -- This signature is currently under construction. -- https://mail.python.org/mailman/listinfo/python-list From mats at wichmann.us Fri Aug 5 16:57:41 2022 From: mats at wichmann.us (Mats Wichmann) Date: Fri, 5 Aug 2022 14:57:41 -0600 Subject: Trying to understand nested loops In-Reply-To: References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> Message-ID: <8d988c61-c229-ff0d-7c0b-c3f7cc4c40b4@wichmann.us> On 8/5/22 03:56, GB wrote: > On 05/08/2022 08:56, Frank Millman wrote: > >> BTW, there is an indentation error in your original post - line 5 >> should line up with line 4. > > As a Python beginner, I find that Python is annoyingly picky about > indents.? And, the significance of indents is a bit of a minefield for > beginners. > > For example, in the above code, the indent of the final line very > significantly affects the results: > > print(var) > ??? print(var) > ??????? print(var) > > These are all different. Yes, very picky. Python has chosen to use a (consistent) indent to indicate a code block, as opposed to using extra syntactical characters (curly braces, etc.) to delimit blocks. It's just a choice that was made about how to instruct the interpreter what you mean, and there's some argument that it improves readability later, when you go look at your code months later, or someone else's code: the requirement to have consistent indents means your brain can trust that the way the code is indented is meaningful, rather than arbitrary. Also note that most (all?) code formatters for other languages will enforce consistent indenting too, In Python it just happens to be part of the language rather than optional. So: you need to be clear about what you mean by indenting correctly. All good code editors that understand Python understand about this and will help you as much as they can. From drsalists at gmail.com Fri Aug 5 18:50:49 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 5 Aug 2022 15:50:49 -0700 Subject: Trying to understand nested loops In-Reply-To: References: Message-ID: On Fri, Aug 5, 2022 at 12:35 AM wrote: > Hello, I?m new to learning python and I stumbled upon a question nested > loops. This is the question below. Can you please how they arrived at 9 as > the answer. Thanks > > var = 0 > for i in range(3): > for j in range(-2,-7,-2): > var += 1 > print(var) > A debugger is useful for more than debugging; it can also help give an intuition for control flow. If you single step through this snippet with a debugger, you'll probably see what's happening. Of if you don't have (or want) a debugger, you could change it to: var = 0 for i in range(3): print('i is', i) for j in range(-2,-7,-2): print('j is', j) var += 1 print(var) And note that 3 times 3 is 9. From PythonList at DancesWithMice.info Fri Aug 5 19:15:26 2022 From: PythonList at DancesWithMice.info (dn) Date: Sat, 6 Aug 2022 11:15:26 +1200 Subject: Trying to understand nested loops In-Reply-To: References: Message-ID: <97365836-784a-f9f1-00f0-1d4420340d11@DancesWithMice.info> On 06/08/2022 10.50, Dan Stromberg wrote: > On Fri, Aug 5, 2022 at 12:35 AM wrote: ... > Of if you don't have (or want) a debugger, you could change it to: > > var = 0 > for i in range(3): > print('i is', i) > for j in range(-2,-7,-2): > print('j is', j) > var += 1 > print(var) > > And note that 3 times 3 is 9. Combining the above advice and illustration, with several more recent comments about indentation revealing structure, should the above be amended to: indent = " " # your choice of how many spaces/tabs ... print( "i is", i ) ... print( indent + "j is", j ) ... print( indent + indent, var ) # add sep="" if pernickety ... Thus, the output matches the code and each complements the other's view of structure! -- Regards, =dn From avi.e.gross at gmail.com Fri Aug 5 19:41:59 2022 From: avi.e.gross at gmail.com (avi.e.gross at gmail.com) Date: Fri, 5 Aug 2022 19:41:59 -0400 Subject: Trying to understand nested loops In-Reply-To: References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> Message-ID: <01f101d8a924$f4f71560$dee54020$@gmail.com> I wonder if someone is pulling our leg as they are sending from an invalid email address of "GB " which is a bit sick. I have trouble imagining ANYONE learning a language like python without rapidly being told that python uses indentation instead of various ways to detect when a body of text is considered a single composite item. And code like their example is also nonsense: print(var) print(var) print(var) On my version of python, and likely most or all, it generates an error message like: SyntaxError: multiple statements found while compiling a single statement The way I see it, it is beyond irrelevant when learning a language what YOU (the learner) think. The rules are the rules. If you do not like them and do not have to use that language, go find another you might like. If you want to stay with the language, you not only adjust but welcome new ways of doing things. I have seen people stuck on code like this: a, b, c = 5,4,3 others get nauseous at something like: a, b, _ = some_func(args) But the whole point is learning to appreciate what someone decided might make the language more useful, easier to program in, avoid errors, be more flexible, or maybe more efficient, or whatever design criteria apply. Only once you understand more things like that, can you be in a position to critique it as horrible. So, speaking for myself, the poster is assumed, for now, to not be worth responding to. I doubt they are a true beginner or at least that they have spent any serious time learning. -----Original Message----- From: Python-list On Behalf Of GB Sent: Friday, August 5, 2022 5:57 AM To: python-list at python.org Subject: Re: Trying to understand nested loops On 05/08/2022 08:56, Frank Millman wrote: > BTW, there is an indentation error in your original post - line 5 > should line up with line 4. As a Python beginner, I find that Python is annoyingly picky about indents. And, the significance of indents is a bit of a minefield for beginners. For example, in the above code, the indent of the final line very significantly affects the results: print(var) print(var) print(var) These are all different. -- https://mail.python.org/mailman/listinfo/python-list From drsalists at gmail.com Fri Aug 5 19:55:18 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 5 Aug 2022 16:55:18 -0700 Subject: Trying to understand nested loops In-Reply-To: References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> Message-ID: On Fri, Aug 5, 2022 at 12:30 PM GB wrote: > On 05/08/2022 08:56, Frank Millman wrote: > > > BTW, there is an indentation error in your original post - line 5 should > > line up with line 4. > > As a Python beginner, I find that Python is annoyingly picky about > indents. And, the significance of indents is a bit of a minefield for > beginners. > No, you should indent properly anyway. Python just reduces the number of things to worry about. Please see: https://stromberg.dnsalias.org/~strombrg/significant-whitespace.html ...for the usual. From PythonList at DancesWithMice.info Fri Aug 5 19:57:30 2022 From: PythonList at DancesWithMice.info (dn) Date: Sat, 6 Aug 2022 11:57:30 +1200 Subject: Trying to understand nested loops In-Reply-To: <01f101d8a924$f4f71560$dee54020$@gmail.com> References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> <01f101d8a924$f4f71560$dee54020$@gmail.com> Message-ID: On 06/08/2022 11.41, avi.e.gross at gmail.com wrote: > I wonder if someone is pulling our leg as they are sending from an invalid > email address of "GB " which is a bit sick. There are a number of folk who use evidently false email addresses - the OP's had me amused. Such 'hiding' is a matter for the List-Admins (thanks for all the work exerted on our behalf!) and how it fits with the Code-of-Conduct. > I have trouble imagining ANYONE learning a language like python without > rapidly being told that python uses indentation instead of various ways to > detect when a body of text is considered a single composite item. > > And code like their example is also nonsense: > > print(var) > print(var) > print(var) Another way to look at that post, and what the author may have meant; is that the final print(), incorrectly indented in the OP, could have been written with three different indentations, and thus have three very different effects (cf that they are all to be used, as-is). -- Regards, =dn From avi.e.gross at gmail.com Fri Aug 5 20:28:31 2022 From: avi.e.gross at gmail.com (avi.e.gross at gmail.com) Date: Fri, 5 Aug 2022 20:28:31 -0400 Subject: Trying to understand nested loops In-Reply-To: References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> <01f101d8a924$f4f71560$dee54020$@gmail.com> Message-ID: <01f901d8a92b$750bb8e0$5f232aa0$@gmail.com> I had considered that, Dave. Albeit others did at least put in some three-dot markers to show there was other code between the three lines shown. But the same silly argument they used applies elsewhere. Consider nested calls like: Delta(Gamma(Beta(Alpha))) Now say one of those functions takes an argument like 666. The following lines all mean different things, especially if all the above functions can take an optional argument of 666. Delta(Gamma(Beta(Alpha,666))) Delta(Gamma(Beta(Alpha),666)) Delta(Gamma(Beta(Alpha)),666) Delta(666,Gamma(Beta(Alpha))) Delta(Gamma(666,Beta(Alpha))) Delta(Gamma(Beta(666,Alpha))) And of course any such function calls may be in contexts such as this: Result, const = Delta(Gamma(Beta(Alpha))),666 My point is that whether using indentation or parentheses or braces or other grouping techniques, exact placement according to the rules must apply. I often write code where I use indentation to remind ME which argument goes with which, such as this (more often not in python where indentation has no real meaning and things can span multiple lines. This: Delta(Gamma(666,Beta(Alpha))) May make more sense to write like this: Delta(Gamma(666, Beta(Alpha))) Or in a more general case where each of the functions may take multiple arguments before and/or after nested, calls, I might have a long convoluted code where all arguments to a particular function are vertically aligned and it is easier to spot if you left one out or put it in the wrong place. It becomes a somewhat childish argument when writing CODE in any language with rules, to suggest that it should ignore your mistakes and assume you meant to have a comma here or parentheses there and similarly, that the indentation level should govern which block your print statement is part of. Hence my suggestion that perhaps someone is in a sense punking us Of course it is perfectly possible the software this person is using makes that deliberately unworkable email address as I have seen this elsewhere. It just raises my suspicion level when I have seen other posts on various mailing lists ranging from someone with pretty much no knowledge about a topic but wanting someone to do their homework, to someone who throws in something (perhaps incendiary) to watch others waste their time trying to deal with their best guesses of what was wanted, to one guy who seems to write articles or books and wants to see what people think but then does not participate or tell us that is what they wanted. My point was not to tell anyone else here what to do, simply that I will be cautious with such posters as I have way better things to do! Nested loops are indeed a hard topic for many. But when explained it no longer seems reasonable to ask why print statements at different levels of nesting differ. Not to me, at least. - Avi (for those like someone on another language/group who did not know how to address me in overall too-polite format and referred to me as "Dear " followed by more lines. -----Original Message----- From: Python-list On Behalf Of dn Sent: Friday, August 5, 2022 7:58 PM To: python-list at python.org Subject: Re: Trying to understand nested loops On 06/08/2022 11.41, avi.e.gross at gmail.com wrote: > I wonder if someone is pulling our leg as they are sending from an > invalid email address of "GB " which is a bit sick. There are a number of folk who use evidently false email addresses - the OP's had me amused. Such 'hiding' is a matter for the List-Admins (thanks for all the work exerted on our behalf!) and how it fits with the Code-of-Conduct. > I have trouble imagining ANYONE learning a language like python > without rapidly being told that python uses indentation instead of > various ways to detect when a body of text is considered a single composite item. > > And code like their example is also nonsense: > > print(var) > print(var) > print(var) Another way to look at that post, and what the author may have meant; is that the final print(), incorrectly indented in the OP, could have been written with three different indentations, and thus have three very different effects (cf that they are all to be used, as-is). -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list From mgogala at yahoo.com Fri Aug 5 20:29:19 2022 From: mgogala at yahoo.com (Mladen Gogala) Date: Sat, 6 Aug 2022 00:29:19 -0000 (UTC) Subject: Trying to understand nested loops References: Message-ID: On Fri, 5 Aug 2022 08:34:45 +0100, ojomooluwatolami675 wrote: > Hello, I?m new to learning python and I stumbled upon a question nested > loops. This is the question below. Can you please how they arrived at 9 > as the answer. Thanks > > var = 0 for i in range(3): > for j in range(-2,-7,-2): > var += 1 > print(var) > > Sent from my iPhone That's simple. Number 9 itself is equal to 3*3. Inner loop executes 3 times for each of the 3 executions of the outer loop. PS: The reply is intentionally written in such a way that it cannot be used as an answer to a homework question. You'll have to work out the details yourself. -- Mladen Gogala Database Consultant https://dbwhisperer.wordpress.com From drsalists at gmail.com Fri Aug 5 23:53:03 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 5 Aug 2022 20:53:03 -0700 Subject: Trying to understand nested loops In-Reply-To: <62ed7557.050a0220.1d68f.2d24@mx.google.com> References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> <62ed7557.050a0220.1d68f.2d24@mx.google.com> Message-ID: On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards wrote: > In C, this doesn't do what it looks like it's supposed to do. > > if (foo) > do_this(); > and_this(); > then_do_this(); > It's been quite a while since I used C, but with the right compiler flag(s), I think this may be a thing of the past when compiling with gcc: https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indentation-vs-goto-fail From rosuav at gmail.com Sat Aug 6 00:01:13 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 6 Aug 2022 14:01:13 +1000 Subject: Trying to understand nested loops In-Reply-To: References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> <62ed7557.050a0220.1d68f.2d24@mx.google.com> Message-ID: On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: > > On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards > wrote: > > > In C, this doesn't do what it looks like it's supposed to do. > > > > if (foo) > > do_this(); > > and_this(); > > then_do_this(); > > > It's been quite a while since I used C, but with the right compiler > flag(s), I think this may be a thing of the past when compiling with gcc: > https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indentation-vs-goto-fail Ah yes, because compiler warnings are always viewed and acted upon. Have you ever watched the compilation of a large open-source project, done using the project's own build system and therefore the team's preferred warning settings? It's normal to have such a spew of warnings that you can't find anything interesting, or to have new warnings in new versions of GCC be utterly useless for the same reason. ChrisA From Richard at Damon-Family.org Sat Aug 6 08:06:40 2022 From: Richard at Damon-Family.org (Richard Damon) Date: Sat, 6 Aug 2022 08:06:40 -0400 Subject: Trying to understand nested loops In-Reply-To: References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> <62ed7557.050a0220.1d68f.2d24@mx.google.com> Message-ID: <7bb4f809-d0f4-c30e-a2cb-516ab8a961fa@Damon-Family.org> On 8/6/22 12:01 AM, Chris Angelico wrote: > On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: >> On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards >> wrote: >> >>> In C, this doesn't do what it looks like it's supposed to do. >>> >>> if (foo) >>> do_this(); >>> and_this(); >>> then_do_this(); >>> >> It's been quite a while since I used C, but with the right compiler >> flag(s), I think this may be a thing of the past when compiling with gcc: >> https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indentation-vs-goto-fail > Ah yes, because compiler warnings are always viewed and acted upon. > > Have you ever watched the compilation of a large open-source project, > done using the project's own build system and therefore the team's > preferred warning settings? It's normal to have such a spew of > warnings that you can't find anything interesting, or to have new > warnings in new versions of GCC be utterly useless for the same > reason. > > ChrisA You make it so you HAVE to fix the warning by adding the option to make warnings into errors. This does mean that you need to fix all the warnings that don't actually mean anything, Good code shouldn't generate many warnings, either you have warnings enabled that you don't care about, or your code is doing things you have told the complier you shouldn't do. -- Richard Damon From rosuav at gmail.com Sat Aug 6 08:12:21 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 6 Aug 2022 22:12:21 +1000 Subject: Trying to understand nested loops In-Reply-To: <7bb4f809-d0f4-c30e-a2cb-516ab8a961fa@Damon-Family.org> References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> <62ed7557.050a0220.1d68f.2d24@mx.google.com> <7bb4f809-d0f4-c30e-a2cb-516ab8a961fa@Damon-Family.org> Message-ID: On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: > > On 8/6/22 12:01 AM, Chris Angelico wrote: > > On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: > >> On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards > >> wrote: > >> > >>> In C, this doesn't do what it looks like it's supposed to do. > >>> > >>> if (foo) > >>> do_this(); > >>> and_this(); > >>> then_do_this(); > >>> > >> It's been quite a while since I used C, but with the right compiler > >> flag(s), I think this may be a thing of the past when compiling with gcc: > >> https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indentation-vs-goto-fail > > Ah yes, because compiler warnings are always viewed and acted upon. > > > > Have you ever watched the compilation of a large open-source project, > > done using the project's own build system and therefore the team's > > preferred warning settings? It's normal to have such a spew of > > warnings that you can't find anything interesting, or to have new > > warnings in new versions of GCC be utterly useless for the same > > reason. > > > > ChrisA > > You make it so you HAVE to fix the warning by adding the option to make > warnings into errors. > > This does mean that you need to fix all the warnings that don't actually > mean anything, > > Good code shouldn't generate many warnings, either you have warnings > enabled that you don't care about, or your code is doing things you have > told the complier you shouldn't do. > I say again: have you ever watched the compilation of a large open-source project? You cannot turn warnings into errors, because there are ALWAYS warnings. Maybe, once upon a time, the policy was to ensure that there were no warnings on any major compiler; but times change, compilers add new warnings, new compilers join the club, and it becomes practically impossible to prevent warnings. Which, in turn, makes all warnings basically meaningless. Hmm. I don't think I've ever compiled gcc from source. Maybe I should do that, just to see whether gcc itself compiles with no warnings under gcc. ChrisA From Richard at Damon-Family.org Sat Aug 6 08:38:21 2022 From: Richard at Damon-Family.org (Richard Damon) Date: Sat, 6 Aug 2022 08:38:21 -0400 Subject: Trying to understand nested loops In-Reply-To: References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> <62ed7557.050a0220.1d68f.2d24@mx.google.com> <7bb4f809-d0f4-c30e-a2cb-516ab8a961fa@Damon-Family.org> Message-ID: On 8/6/22 8:12 AM, Chris Angelico wrote: > On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: >> On 8/6/22 12:01 AM, Chris Angelico wrote: >>> On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: >>>> On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards >>>> wrote: >>>> >>>>> In C, this doesn't do what it looks like it's supposed to do. >>>>> >>>>> if (foo) >>>>> do_this(); >>>>> and_this(); >>>>> then_do_this(); >>>>> >>>> It's been quite a while since I used C, but with the right compiler >>>> flag(s), I think this may be a thing of the past when compiling with gcc: >>>> https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indentation-vs-goto-fail >>> Ah yes, because compiler warnings are always viewed and acted upon. >>> >>> Have you ever watched the compilation of a large open-source project, >>> done using the project's own build system and therefore the team's >>> preferred warning settings? It's normal to have such a spew of >>> warnings that you can't find anything interesting, or to have new >>> warnings in new versions of GCC be utterly useless for the same >>> reason. >>> >>> ChrisA >> You make it so you HAVE to fix the warning by adding the option to make >> warnings into errors. >> >> This does mean that you need to fix all the warnings that don't actually >> mean anything, >> >> Good code shouldn't generate many warnings, either you have warnings >> enabled that you don't care about, or your code is doing things you have >> told the complier you shouldn't do. >> > I say again: have you ever watched the compilation of a large > open-source project? You cannot turn warnings into errors, because > there are ALWAYS warnings. Maybe, once upon a time, the policy was to > ensure that there were no warnings on any major compiler; but times > change, compilers add new warnings, new compilers join the club, and > it becomes practically impossible to prevent warnings. Which, in turn, > makes all warnings basically meaningless. > > Hmm. I don't think I've ever compiled gcc from source. Maybe I should > do that, just to see whether gcc itself compiles with no warnings > under gcc. > > ChrisA And for any project, that is a choice THEY made. For projects where code quality is actually a defined metric, there is normally a specified warning level (for a specified set of compilers and versions) that the code needs to compile at least nearly clean at. Yes, you can get that ton of warnings when at a higher warning level, but that is why you specify the warning level to use, and put the specific mitigations/suppressions for the few cases where the code is correct, but generates that warning. Yes, you can get a lot of warnings with another compiler, but that is because you aren't running at the correct warning level for that compiler, which is why the set of compilers that you are "warning free" on is specified. When you add a new compiler, it may first not be warning free until you make the effort (if you ever do) to make it warning free for that. Major open source projects will have a "toll gate" on the official repository that checks that additions keep the code to the standard it has established, -- Richard Damon From rosuav at gmail.com Sat Aug 6 08:46:27 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 6 Aug 2022 22:46:27 +1000 Subject: Trying to understand nested loops In-Reply-To: References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> <62ed7557.050a0220.1d68f.2d24@mx.google.com> <7bb4f809-d0f4-c30e-a2cb-516ab8a961fa@Damon-Family.org> Message-ID: On Sat, 6 Aug 2022 at 22:39, Richard Damon wrote: > > On 8/6/22 8:12 AM, Chris Angelico wrote: > > On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: > >> On 8/6/22 12:01 AM, Chris Angelico wrote: > >>> On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: > >>>> On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards > >>>> wrote: > >>>> > >>>>> In C, this doesn't do what it looks like it's supposed to do. > >>>>> > >>>>> if (foo) > >>>>> do_this(); > >>>>> and_this(); > >>>>> then_do_this(); > >>>>> > >>>> It's been quite a while since I used C, but with the right compiler > >>>> flag(s), I think this may be a thing of the past when compiling with gcc: > >>>> https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-indentation-vs-goto-fail > >>> Ah yes, because compiler warnings are always viewed and acted upon. > >>> > >>> Have you ever watched the compilation of a large open-source project, > >>> done using the project's own build system and therefore the team's > >>> preferred warning settings? It's normal to have such a spew of > >>> warnings that you can't find anything interesting, or to have new > >>> warnings in new versions of GCC be utterly useless for the same > >>> reason. > >>> > >>> ChrisA > >> You make it so you HAVE to fix the warning by adding the option to make > >> warnings into errors. > >> > >> This does mean that you need to fix all the warnings that don't actually > >> mean anything, > >> > >> Good code shouldn't generate many warnings, either you have warnings > >> enabled that you don't care about, or your code is doing things you have > >> told the complier you shouldn't do. > >> > > I say again: have you ever watched the compilation of a large > > open-source project? You cannot turn warnings into errors, because > > there are ALWAYS warnings. Maybe, once upon a time, the policy was to > > ensure that there were no warnings on any major compiler; but times > > change, compilers add new warnings, new compilers join the club, and > > it becomes practically impossible to prevent warnings. Which, in turn, > > makes all warnings basically meaningless. > > > > Hmm. I don't think I've ever compiled gcc from source. Maybe I should > > do that, just to see whether gcc itself compiles with no warnings > > under gcc. > > > > ChrisA > > And for any project, that is a choice THEY made. Indeed. So you can't really say "good code shouldn't generate many warnings" unless (a) you're saying that lots of projects are made up of bad code, or (b) your statement that this is "a thing of the past" is flat-out false, because it can only be valid if you assume that everyone has that warning enabled, and preferably set to be an error. So, for the vast majority of projects out there, indentation errors are going to continue to go uncaught by C compilers. It's not "a thing of the past" until most projects use the flag, and preferably, the flag becomes active by default. And for the record, I have seen spurious warnings from *that exact flag* in a large project (an image parsing library). Spurious in that the code was actually correct, despite the compiler warning about it. ChrisA From avi.e.gross at gmail.com Sat Aug 6 12:37:26 2022 From: avi.e.gross at gmail.com (avi.e.gross at gmail.com) Date: Sat, 6 Aug 2022 12:37:26 -0400 Subject: Trying to understand nested loops In-Reply-To: References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> <62ed7557.050a0220.1d68f.2d24@mx.google.com> <7bb4f809-d0f4-c30e-a2cb-516ab8a961fa@Damon-Family.org> Message-ID: <007b01d8a9b2$d0cf9ed0$726edc70$@gmail.com> This reminds me a bit of how routine spelling checkers and often especially grammar checkers, generate so many suggestions about mistakes as to become ignored. If you are writing using lots of names and jargon that keep getting flagged as errors and they are spelled or used exactly as you want, then it gets to be too annoying and you turn off the feature. Yes, you can sometimes silence some things in a spell checker that allows you to add words to a custom dictionary but for now, that dictionary is not known to every application that checks your spelling. That can be the nature of the beast. If your compiler decides to warn you every time you do a division that you might be dividing by zero because you do not perform the test right before that, then you end up with code that tests it AGAIN after having arranged for the value to never be zero in the first place, then test it again when you divide something else by it, ... I am sure some programming language has some kind of pragma that lets you whisper to the compiler that this variable at this time is guaranteed not to be zero, or that the region is in a try/catch zone which will intercept and fix the results of a divide by zero error. Just an example. And as you say, new or improved compilers can be made to be ever more picky about trying to find possible anomalies. Things are useful when they are somewhat manageable. If a compiler things it detects 372 places in your code where the same thing needs to be mentioned, such as reserving space for an object without simultaneously filling it with some contents, then it would be nice if instead of printing ALL of them, it consolidated it into one warning and say you can click on something to see the 372 instances. -----Original Message----- From: Python-list On Behalf Of Chris Angelico Sent: Saturday, August 6, 2022 8:12 AM To: python-list at python.org Subject: Re: Trying to understand nested loops On Sat, 6 Aug 2022 at 22:08, Richard Damon wrote: > > On 8/6/22 12:01 AM, Chris Angelico wrote: > > On Sat, 6 Aug 2022 at 13:54, Dan Stromberg wrote: > >> On Fri, Aug 5, 2022 at 12:54 PM Grant Edwards > >> > >> wrote: > >> > >>> In C, this doesn't do what it looks like it's supposed to do. > >>> > >>> if (foo) > >>> do_this(); > >>> and_this(); > >>> then_do_this(); > >>> > >> It's been quite a while since I used C, but with the right compiler > >> flag(s), I think this may be a thing of the past when compiling with gcc: > >> https://developers.redhat.com/blog/2016/02/26/gcc-6-wmisleading-ind > >> entation-vs-goto-fail > > Ah yes, because compiler warnings are always viewed and acted upon. > > > > Have you ever watched the compilation of a large open-source > > project, done using the project's own build system and therefore the > > team's preferred warning settings? It's normal to have such a spew > > of warnings that you can't find anything interesting, or to have new > > warnings in new versions of GCC be utterly useless for the same > > reason. > > > > ChrisA > > You make it so you HAVE to fix the warning by adding the option to > make warnings into errors. > > This does mean that you need to fix all the warnings that don't > actually mean anything, > > Good code shouldn't generate many warnings, either you have warnings > enabled that you don't care about, or your code is doing things you > have told the complier you shouldn't do. > I say again: have you ever watched the compilation of a large open-source project? You cannot turn warnings into errors, because there are ALWAYS warnings. Maybe, once upon a time, the policy was to ensure that there were no warnings on any major compiler; but times change, compilers add new warnings, new compilers join the club, and it becomes practically impossible to prevent warnings. Which, in turn, makes all warnings basically meaningless. Hmm. I don't think I've ever compiled gcc from source. Maybe I should do that, just to see whether gcc itself compiles with no warnings under gcc. ChrisA -- https://mail.python.org/mailman/listinfo/python-list From skip.montanaro at gmail.com Sun Aug 7 17:55:13 2022 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Sun, 7 Aug 2022 16:55:13 -0500 Subject: Python gets a mention on Reddit - in r/tifu Message-ID: Not exactly where I expected to see Python mentioned on Reddit, but I found this amusing (yes, despite the subreddit, it should be safe for work): https://www.reddit.com/r/tifu/comments/wibmkh/tifu_by_teaching_my_13yo_brother_python/ Just a little diversion for a Sunday afternoon. I was particularly amused, as my son is in dev ops, writes Python from time-to-time, and my grandson is 13. I could definitely see the pattern in the story transferring over to Chris and Carmine. Skip From nhlanhlah198506 at gmail.com Sun Aug 7 12:59:36 2022 From: nhlanhlah198506 at gmail.com (nhlanhlah198506) Date: Sun, 07 Aug 2022 18:59:36 +0200 Subject: Information about Dying kernel Message-ID: <62efef7a.050a0220.220a4.5349@mx.google.com> Greetings?What can I do if my computer said my kernels has died?Thank you?Sent from my Galaxy From pfeiffer at cs.nmsu.edu Sun Aug 7 16:53:51 2022 From: pfeiffer at cs.nmsu.edu (Joe Pfeiffer) Date: Sun, 07 Aug 2022 14:53:51 -0600 Subject: SyntaxError: multiple statements found while compiling a single statement References: <4c024831-aa68-4468-93f6-1cb37f70e7den@googlegroups.com> Message-ID: <1bczdbyduo.fsf@pfeifferfamily.net> Sohail Ahmad writes: > kindly please help me about issues > SyntaxError: multiple statements found while compiling a single statement how to solve this issues Please post the code that got the error. Preferably several lines before the actual error, and the line with the error itself. From pbryan at anode.ca Sun Aug 7 21:38:20 2022 From: pbryan at anode.ca (Paul Bryan) Date: Sun, 07 Aug 2022 18:38:20 -0700 Subject: Information about Dying kernel In-Reply-To: <62efef7a.050a0220.220a4.5349@mx.google.com> References: <62efef7a.050a0220.220a4.5349@mx.google.com> Message-ID: Have you tried turning it off and back on again? On Sun, 2022-08-07 at 18:59 +0200, nhlanhlah198506 wrote: > Greetings?What can I do if my computer said my kernels has died?Thank > you?Sent from my Galaxy From pablogsal at gmail.com Mon Aug 8 12:59:52 2022 From: pablogsal at gmail.com (Pablo Galindo Salgado) Date: Mon, 8 Aug 2022 17:59:52 +0100 Subject: [RELEASE] Python 3.11 release candidate 1 (3.11.0rc1) is available Message-ID: Python 3.11.0 is almost ready. This release, 3.11.0rc1, is the penultimate release preview. You can get it here: ## This is the first release candidate of Python 3.11 https://www.python.org/downloads/release/python-3110rc1/ This release, **3.11.0rc1**, is the penultimate release preview. Entering the release candidate phase, only reviewed code changes which are clear bug fixes are allowed between this release candidate and the final release. The second candidate and the last planned release preview is currently planned for Monday, 2022-09-05 while the official release is planned for Monday, 2022-10-03. There will be no ABI changes from this point forward in the 3.11 series and the goal is that there will be as few code changes as possible. ## Call to action #### Core developers: all eyes on the docs now * Are all your changes properly documented? * Did you notice other changes you know of to have insufficient documentation? #### Community members We strongly encourage maintainers of third-party Python projects to prepare their projects for 3.11 compatibilities during this phase. As always, report any issues to [the Python bug tracker ](https://github.com/issues). Please keep in mind that this is a preview release and its use is **not** recommended for production environments. # Major new features of the 3.11 series, compared to 3.10 Some of the new major new features and changes in Python 3.11 are: ## General changes * [PEP 657](https://www.python.org/dev/peps/pep-0657/) -- Include Fine-Grained Error Locations in Tracebacks * [PEP 654](https://www.python.org/dev/peps/pep-0654/) -- Exception Groups and `except*` * [PEP 680](https://www.python.org/dev/peps/pep-0680/) -- tomllib: Support for Parsing TOML in the Standard Library * [gh-90908](https://github.com/python/cpython/issues/90908) -- Introduce task groups to asyncio * [gh-34627](https://github.com/python/cpython/issues/34627/) -- Atomic grouping (`(?>...)`) and possessive quantifiers (`*+, ++, ?+, {m,n}+`) are now supported in regular expressions. * The [Faster CPython Project](https://github.com/faster-cpython/) is already yielding some exciting results. Python 3.11 is up to 10-60% faster than Python 3.10. On average, we measured a 1.22x speedup on the standard benchmark suite. See [Faster CPython]( https://docs.python.org/3.11/whatsnew/3.11.html#faster-cpython) for details. ## Typing and typing language changes * [PEP 673](https://www.python.org/dev/peps/pep-0673/) -- Self Type * [PEP 646](https://www.python.org/dev/peps/pep-0646/) -- Variadic Generics * [PEP 675](https://www.python.org/dev/peps/pep-0675/) -- Arbitrary Literal String Type * [PEP 655](https://www.python.org/dev/peps/pep-0655/) -- Marking individual TypedDict items as required or potentially-missing * [PEP 681](https://www.python.org/dev/peps/pep-0681/) -- Data Class Transforms (Hey, **fellow core developer,** if a feature you find important is missing from this list, [let Pablo know](mailto:pablogsal at python.org ).) The next pre-release of Python 3.11 will be 3.11.0rc2, currently scheduled for Monday, 2022-09-05. # More resources * [Online Documentation](https://docs.python.org/3.11/) * [PEP 664](https://www.python.org/dev/peps/pep-0664/), 3.11 Release Schedule * Report bugs at [ https://github.com/python/cpython/issues](https://github.com/python/cpython/issues) . * [Help fund Python and its community](/psf/donations/). # And now for something completely different A quark star is a hypothetical type of compact, exotic star, where extremely high core temperature and pressure have forced nuclear particles to form quark matter, a continuous state of matter consisting of free quarks. Some massive stars collapse to form neutron stars at the end of their life cycle, as has been both observed and explained theoretically. Under the extreme temperatures and pressures inside neutron stars, the neutrons are normally kept apart by degeneracy pressure, stabilizing the star and hindering further gravitational collapse. However, it is hypothesized that under even more extreme temperature and pressure, the degeneracy pressure of the neutrons is overcome, and the neutrons are forced to merge and dissolve into their constituent quarks, creating an ultra-dense phase of quark matter based on densely packed quarks. In this state, a new equilibrium is supposed to emerge, as a new degeneracy pressure between the quarks, as well as repulsive electromagnetic forces, will occur and hinder total gravitational collapse. If these ideas are correct, quark stars might occur, and be observable, somewhere in the universe. Theoretically, such a scenario is seen as scientifically plausible, but it has been impossible to prove both observationally and experimentally because the very extreme conditions needed for stabilizing quark matter cannot be created in any laboratory nor observed directly in nature. The stability of quark matter, and hence the existence of quark stars, is for these reasons among the unsolved problems in physics. # We hope you enjoy the new releases! Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation. https://www.python.org/psf/ If you have any questions, please reach out to me or another member of the release team :) Your friendly release team, Ned Deily @nad https://discuss.python.org/u/nad Steve Dower @steve.dower https://discuss.python.org/u/steve.dower Pablo Galindo Salgado @pablogsal https://discuss.python.org/u/pablogsal From andrea.croci at gmx.de Mon Aug 8 06:47:26 2022 From: andrea.croci at gmx.de (Andreas Croci) Date: Mon, 8 Aug 2022 12:47:26 +0200 Subject: Parallel(?) programming with python Message-ID: tI would like to write a program, that reads from the network a fixed amount of bytes and appends them to a list. This should happen once a second. Another part of the program should take the list, as it has been filled so far, every 6 hours or so, and do some computations on the data (a FFT). Every so often (say once a week) the list should be saved to a file, shorthened in the front by so many items, and filled further with the data coming fom the network. After the first saving of the whole list, only the new part (the data that have come since the last saving) should be appended to the file. A timestamp is in the data, so it's easy to say what is new and what was already there. I'm not sure how to do this properly: can I write a part of a program that keeps doing its job (appending data to the list once every second) while another part computes something on the data of the same list, ignoring the new data being written? Basically the question boils down to wether it is possible to have parts of a program (could be functions) that keep doing their job while other parts do something else on the same data, and what is the best way to do this. From andrea.croci at gmx.de Mon Aug 8 07:53:20 2022 From: andrea.croci at gmx.de (Andreas Croci) Date: Mon, 8 Aug 2022 13:53:20 +0200 Subject: Parallel(?) programming with python References: Message-ID: Thanks for your reply. On 08.08.22 13:20, Stefan Ram wrote: > Yes, but this is difficult. If you ask this question here, > you might not be ready for this. Indeed. > > I haven't learned it yet myself, but nevertheless tried to > write a small example program quickly, which might still > contain errors because of my lack of education. > > import threading > import time > > def write_to_list( list, lock, event ): > for i in range( 10 ): > lock.acquire() > try: > list.append( i ) > finally: > lock.release() > event.set() > time.sleep( 3 ) > > def read_from_list( list, lock, event ): > while True: > event.wait() > print( "Waking up." ) > event.clear() > if len( list ): > print( "List contains " + str( list[ 0 ]) + "." ) > lock.acquire() > try: > del list[ 0 ] > finally: > lock.release() > else: > print( "List is empty." ) > > list = [] > lock = threading.Lock() > event = threading.Event() > threading.Thread( target=write_to_list, args=[ list, lock, event ]).start() > threading.Thread( target=read_from_list, args=[ list, lock, event ]).start() If I understand some things correctly, a "lock" would be something that, as the name says, locks, meaning prevents parts of the program from executing on the locked resource until ohter parts have finished doing their things and have released the lock. If this is correct, it's not exactly what I wanted, because this way "parts of the program" would not "keep doing their things, while other parts do other things on the same data". I'm in principle ok with locks, if it must be. What I fear is that the lock could last long and prevent the function that writes into the list from doing so every second. With an FFT on a list that contains a few bytes taken every second over one week time (604.800 samples), I believe it's very likely that the FFT function takes longer than a second to return. Then I would have to import all the data I have missed since the lock was aquired, which is doable, but I would like to avoid it if possible. > > In basketball, first you must learn to dribble and pass, > before you can begin to shoot. Sure. > > With certain reservations, texts that can be considered > to learn Python are: > > "Object-Oriented Programming in Python Documentation" - a PDF file, > Introduction to Programming Using Python - Y Daniel Liang (2013), > How to Think Like a Computer Scientist - Peter Wentworth (2012-08-12), > The Coder's Apprentice - Pieter Spronck (2016-09-21), and > Python Programming - John Zelle (2009). > Thank you for the list. I an currently taking a Udemy course and at the same time reading the tutorials on python.org. I hope I will some day come to any of the books you suggest (I'm doing this only in my spare time and it will take forever). From dan at djph.net Mon Aug 8 07:59:15 2022 From: dan at djph.net (Dan Purgert) Date: Mon, 8 Aug 2022 11:59:15 -0000 (UTC) Subject: Trying to understand nested loops References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> <01f101d8a924$f4f71560$dee54020$@gmail.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 dn wrote: > On 06/08/2022 11.41, avi.e.gross at gmail.com wrote: >> I wonder if someone is pulling our leg as they are sending from an >> invalid email address of "GB " which is >> a bit sick. > > There are a number of folk who use evidently false email addresses - the > OP's had me amused. > > Such 'hiding' is a matter for the List-Admins (thanks for all the work > exerted on our behalf!) and how it fits with the Code-of-Conduct. Invalid sending addresses (email at somewhere.invalid) are a standard practice in Usenet, to combat bots scraping posts for email addresses (remember, Usenet predates basically all spam prevention tech). As there is a gateway between the mailing lists and Usenet, I *imagine* that the use of said invalid addresses are within the rules -- I mean, if they weren't, the maintainers wouldn't keep the two lists connected. -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE3asj+xn6fYUcweBnbWVw5UznKGAFAmLw+rkACgkQbWVw5Uzn KGBT4A/8DR8GWlEgZhcoaLYTnQCfBv8YmykUxQ69/Xwf7o34S/ObtN0WTapgEBkB xamJHzFKENVeOoFwNgWkAaLSfOm2704DqO4vEJBZmCGrPtLTjHmpQuIcg2c+cjwz EEaYCuWmQZrviFS9ZeWX4FIMX9IlZ3Sgy7e/qHvdI5jeclw4oltYdRxVO3h9WylM BXn3Lvqntw+/5xV3vI/B2SODBTkB8a4D0vC64a3NwGqA3eUkyZrJYlVX8igubBwJ /sDLTy9EOK7wmokoXIHjj7KN+s5bC8idUN/V6DJiE6Z3vU0AOujKsw8jyQbndP9d 7da3gDLECMTHTFuKkj8kWC005aaWdM+GYzm1nofQC0jpINCP88IVce9curm11IQa AVWmxNBuGtLh8E3iE5WaydkgwZJXAll2cewOtzyJ0H8qeMwcqtL7hcKwdVPSzSYG JDqcbthDAzJg/PXcLjBHidXNZQ1BhyLw9ySzf+/7buiSsMdHuYZEohHXH4ybRMtL hlg6r09b5nDbKD7C9hVfL21+mogcX9t+LehsqiPLXssyMHRpTmGRzQ+CBySg5QaV gXshFJxRqvp9UtL+xw/wNL3wODsaVTU430qSKUI1ov7ClqcUXvEP5cbmKa9ufJ/J 8iDSbAP2B54pGyF9hfF0f8h267bZy13gWWqBqiFoCBZcVkaC/Jo= =6yDi -----END PGP SIGNATURE----- -- |_|O|_| |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1 E067 6D65 70E5 4CE7 2860 From darcy at VybeNetworks.com Mon Aug 8 09:32:21 2022 From: darcy at VybeNetworks.com (D'Arcy Cain) Date: Mon, 8 Aug 2022 09:32:21 -0400 Subject: Information about Dying kernel In-Reply-To: References: <62efef7a.050a0220.220a4.5349@mx.google.com> Message-ID: <2a74c2cc-ad25-ec07-ebf6-5f55c56d7b2b@VybeNetworks.com> On 2022-08-07 21:38, Paul Bryan wrote: > Have you tried turning it off and back on again? Thank you, Roy. -- D'Arcy J.M. Cain Vybe Networks Inc. A unit of Excelsior Solutions Corporation - Propelling Business Forward http://www.VybeNetworks.com/ IM:darcy at VybeNetworks.com VoIP: sip:darcy at VybeNetworks.com From NOTsomeone at microsoft.invalid Mon Aug 8 10:42:09 2022 From: NOTsomeone at microsoft.invalid (GB) Date: Mon, 8 Aug 2022 15:42:09 +0100 Subject: Trying to understand nested loops In-Reply-To: References: <1c043e8f-47c9-153e-84c3-8343a28247db@chagford.com> <01f101d8a924$f4f71560$dee54020$@gmail.com> Message-ID: On 08/08/2022 12:59, Dan Purgert wrote: > dn wrote: >> On 06/08/2022 11.41, avi.e.gross at gmail.com wrote: >>> I wonder if someone is pulling our leg as they are sending from an >>> invalid email address of "GB " which is >>> a bit sick. > >> There are a number of folk who use evidently false email addresses - the >> OP's had me amused. > >> Such 'hiding' is a matter for the List-Admins (thanks for all the work >> exerted on our behalf!) and how it fits with the Code-of-Conduct. > > Invalid sending addresses (email at somewhere.invalid) are a standard > practice in Usenet, to combat bots scraping posts for email addresses > (remember, Usenet predates basically all spam prevention tech). > > As there is a gateway between the mailing lists and Usenet, I *imagine* > that the use of said invalid addresses are within the rules -- I mean, > if they weren't, the maintainers wouldn't keep the two lists > connected. > > > The history in my case is as follows: Years ago, I used Outlook Express, and, for setting up NG access, they suggested an example email address: someone at microsoft.com. I did not want to give my true email address, lest it be 'scraped', so I used: NOTsomeone at microsoft.com. I added the NOT, to avoid misleading people. Later, I was prevailed upon to change com to invalid. List admins? This particular NG appears to be blessedly free of spam, but I hadn't realised it is moderated? From andrea.croci at gmx.de Mon Aug 8 13:39:27 2022 From: andrea.croci at gmx.de (Andreas Croci) Date: Mon, 8 Aug 2022 19:39:27 +0200 Subject: Parallel(?) programming with python References: Message-ID: Thank you for your reply. On 08.08.22 14:55, Julio Di Egidio wrote: > Concurrent programming is quite difficult, plus you better think > in terms of queues than shared data... Do you mean queues in the sense of deque (the data structure)? I ask because I can see the advantage there when I try to pop data from the front of it, but I don't see the sense of the following statement ("than shared data"). I mean, I called my structure a list, but it may well be a queue instead. That wouldn't prevent it from being shared in the idea I described: one function would still append data to it while the other is reading what is there up to a certain point and calculate the FFT of it. But, an easier and often > better option for concurrent data access is use a (relational) > database, then the appropriate transaction isolation levels > when reading and/or writing. > That would obviusly save some coding (but would introduce the need to code the interaction with the database), but I'm not sure it would speed up the thing. Would the RDBMS allow to read a table while something else is writing to it? I doubt it and I'm not sure it doesn't flush the cache before letting you read, which would include a normally slow disk access. Andreas > Julio From David.Raymond at tomtom.com Mon Aug 8 14:46:28 2022 From: David.Raymond at tomtom.com (David Raymond) Date: Mon, 8 Aug 2022 18:46:28 +0000 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: >> But, an easier and often >> better option for concurrent data access is use a (relational) >> database, then the appropriate transaction isolation levels >> when reading and/or writing. >> > > That would obviusly save some coding (but would introduce the need to > code the interaction with the database), but I'm not sure it would speed > up the thing. Would the RDBMS allow to read a table while something else > is writing to it? I doubt it and I'm not sure it doesn't flush the cache > before letting you read, which would include a normally slow disk access. SQLite for example allows only 1 write transaction at a time, but in WAL mode you can have as many read transactions as you want all going along at the same time as that 1 writer. It also allows you to specify how thorough it is in flushing data to disk, including not forcing a sync to disk at all and just leaving that to the OS to do on its own time. From wlfraed at ix.netcom.com Mon Aug 8 13:56:02 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 08 Aug 2022 13:56:02 -0400 Subject: Parallel(?) programming with python References: Message-ID: <0fh2fhdquppev7cu2dqh0dsl5dieh970tn@4ax.com> On Mon, 8 Aug 2022 12:47:26 +0200, Andreas Croci declaimed the following: >tI would like to write a program, that reads from the network a fixed >amount of bytes and appends them to a list. This should happen once a >second. > Ignoring leap seconds, there are 86400 seconds in a day -- how many bytes are you planning to read each second? Maybe more important? Is this a constant network connection feeding you bytes (in which case the bytes available to read will be controlled by the sender -- which may be sending continuously and building up a back log if you don't empty the stream. Or are you planning to make a socket connection, read n-bytes, close socket? >Another part of the program should take the list, as it has been filled >so far, every 6 hours or so, and do some computations on the data (a FFT). > "6 hours or so"? That leaves one open to all sorts of variable timing. In either event, a 6 hour interval is more suited to a process started by a cron job (Linux/Unix) or Task Scheduler (Windows). Having a thread sleep for 6 hours means no safeguard if the parent process should die at some point (and if you are keeping the data in an internal list, you lose all that data too) >Every so often (say once a week) the list should be saved to a file, This REQUIRES the process to not fail at any point, nor any system restarts, etc. And (see prior paragraphs) how much data are you accumulating. In one week you have 604800 "reads". If you are reading 10 bytes each time, that makes 6MB of data you could potentially lose (on most modern hardware, 6MB is not a memory concern... Even 32-bit OS should be able to find space for 600MB of data...). Much better would be to write the file as you read each chunk. If the file is configured right, a separate process should be able to do read-only processing of the file even while the write process is on-going. OR, you attempt an open/write/close cycle which could be blocked while your FFT is processing -- you'd have to detect that situation and buffer the read data until you get a subsequent successful open, at which time you'd write all the backlog data. Or you could even have your FFT process copy the data to the long term file, while the write process just starts a new file when it finds itself blocked (and the FFT deletes the file it was reading). >shorthened in the front by so many items, and filled further with the >data coming fom the network. After the first saving of the whole list, >only the new part (the data that have come since the last saving) should >be appended to the file. A timestamp is in the data, so it's easy to say >what is new and what was already there. > Personally, this sounds more suited for something like SQLite3... Insert new records as the data is read, with timestamps. FFT process selects records based upon last data ID (that it processed previously) to end of new data. SQLite3 database IS the long-term storage. Might need a second table to hold the FFT process "last data ID" so on start up it can determine where to begin. >I'm not sure how to do this properly: can I write a part of a program >that keeps doing its job (appending data to the list once every second) >while another part computes something on the data of the same list, >ignoring the new data being written? > Well, if you really want ONE program -- you'll likely be looking at the Threading module (I don't do "async", and your task doesn't seem suited for async type call backs -- one thread that does the fetching of data, and a second that does the FFT processing, which will be sleeping most of the time). But either way, I'd suggest not keeping the data in an internal list; use some RDBM to keep the long-term data, accumulating it as you fetch it, and letting the FFT read from the database for its processing. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From lkrupp at invalid.pssw.com.invalid Mon Aug 8 14:02:19 2022 From: lkrupp at invalid.pssw.com.invalid (Louis Krupp) Date: Mon, 8 Aug 2022 12:02:19 -0600 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: On 8/8/2022 4:47 AM, Andreas Croci wrote: > tI would like to write a program, that reads from the network a fixed > amount of bytes and appends them to a list. This should happen once a > second. > > Another part of the program should take the list, as it has been > filled so far, every 6 hours or so, and do some computations on the > data (a FFT). > > Every so often (say once a week) the list should be saved to a file, > shorthened in the front by so many items, and filled further with the > data coming fom the network. After the first saving of the whole list, > only the new part (the data that have come since the last saving) > should be appended to the file. A timestamp is in the data, so it's > easy to say what is new and what was already there. > > I'm not sure how to do this properly: can I write a part of a program > that keeps doing its job (appending data to the list once every > second) while another part computes something on the data of the same > list, ignoring the new data being written? > > Basically the question boils down to wether it is possible to have > parts of a program (could be functions) that keep doing their job > while other parts do something else on the same data, and what is the > best way to do this. You might be able to do what you need by making the file system work for you: Use numbered files, something like DATA/0001, DATA/0002, etc. Start by initializing a file number variable to 1 and creating an empty file, DATA/0001. The current time will be your start time. In an infinite loop, just as in Stefan's example: Read from the network and append to the current data file. This shouldn't take long unless the file is on a remote system. If six hours have gone by (compare the current time to the start time), close the current date file, create a thread (see Stefan's example) to call your FFT with the name of the current file, increment the file number, and open a new empty data file. If you want to, you can consolidate files every week or so. The Python library has functions that will let you get a list files in a directory. If you're on a Linux or UNIX system, you can use shell commands to append, copy or rename files. Have fun. Louis From tjreedy at udel.edu Mon Aug 8 15:06:31 2022 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 8 Aug 2022 15:06:31 -0400 Subject: [python-committers] [RELEASE] Python 3.11 release candidate 1 (3.11.0rc1) is available In-Reply-To: References: Message-ID: On 8/8/2022 12:59 PM, Pablo Galindo Salgado wrote: > Python 3.11.0?is almost?ready. This release, 3.11.0rc1, is the > penultimate release?preview. You can get it here: > > ## This is the first release candidate of Python 3.11 > > https://www.python.org/downloads/release/python-3110rc1/ > > > This release, **3.11.0rc1**, is the penultimate release preview. > Entering the release candidate phase, only reviewed code changes which > are clear bug fixes are allowed between this release candidate and the > final release. The second candidate and the last planned release preview > is currently planned for Monday, 2022-09-05 while the official release > is planned for Monday, 2022-10-03. > > There will be no ABI changes from this point forward in the 3.11 series > and the goal is that there will be as few code changes as possible. > #### Core developers: all eyes on the docs now > > * Are all your changes properly documented? > * Did you notice other changes you know of to have insufficient > documentation? Pablo, are you going to unlock 3.11 and revert merges you don't like, or keep it locked and merge PRs you think are OK? From python at mrabarnett.plus.com Mon Aug 8 15:18:16 2022 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 8 Aug 2022 20:18:16 +0100 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: <91ac042d-b3c0-72c8-e396-f1032ec6d7a0@mrabarnett.plus.com> On 2022-08-08 12:20, Stefan Ram wrote: > Andreas Croci writes: >>Basically the question boils down to wether it is possible to have parts >>of a program (could be functions) that keep doing their job while other >>parts do something else on the same data, and what is the best way to do >>this. > > Yes, but this is difficult. If you ask this question here, > you might not be ready for this. > > I haven't learned it yet myself, but nevertheless tried to > write a small example program quickly, which might still > contain errors because of my lack of education. > > import threading > import time > > def write_to_list( list, lock, event ): > for i in range( 10 ): > lock.acquire() > try: > list.append( i ) > finally: > lock.release() > event.set() > time.sleep( 3 ) > > def read_from_list( list, lock, event ): > while True: > event.wait() > print( "Waking up." ) > event.clear() > if len( list ): > print( "List contains " + str( list[ 0 ]) + "." ) > lock.acquire() > try: > del list[ 0 ] > finally: > lock.release() > else: > print( "List is empty." ) > > list = [] > lock = threading.Lock() > event = threading.Event() > threading.Thread( target=write_to_list, args=[ list, lock, event ]).start() > threading.Thread( target=read_from_list, args=[ list, lock, event ]).start() > > In basketball, first you must learn to dribble and pass, > before you can begin to shoot. > > With certain reservations, texts that can be considered > to learn Python are: > > "Object-Oriented Programming in Python Documentation" - a PDF file, > Introduction to Programming Using Python - Y Daniel Liang (2013), > How to Think Like a Computer Scientist - Peter Wentworth (2012-08-12), > The Coder's Apprentice - Pieter Spronck (2016-09-21), and > Python Programming - John Zelle (2009). > When working with threads, you should use queues, not lists, because queues do their own locking and can wait for items to arrive, with a timeout, if desired: import queue import threading import time def write_to_item_queue(item_queue): for i in range(10): print("Put", i, "in queue.", flush=True) item_queue.put(i) time.sleep(3) # Using None to indicate that there's no more to come. item_queue.put(None) def read_from_item_queue(item_queue): while True: try: item = item_queue.get() except item_queue.Empty: print("Queue is empty; should've have got here!", flush=True) else: print("Queue contains " + str(item) + ".", flush=True) if item is None: # Using None to indicate that there's no more to come. break item_queue = queue.Queue() write_thread = threading.Thread(target=write_to_item_queue, args=[item_queue]) write_thread.start() read_thread = threading.Thread(target=read_from_item_queue, args=[item_queue]) read_thread.start() # Wait for the threads to finish. write_thread.join() read_thread.join() print("Finished.") From barry at barrys-emacs.org Mon Aug 8 16:43:13 2022 From: barry at barrys-emacs.org (Barry) Date: Mon, 8 Aug 2022 21:43:13 +0100 Subject: Parallel(?) programming with python In-Reply-To: <91ac042d-b3c0-72c8-e396-f1032ec6d7a0@mrabarnett.plus.com> References: <91ac042d-b3c0-72c8-e396-f1032ec6d7a0@mrabarnett.plus.com> Message-ID: > On 8 Aug 2022, at 20:24, MRAB wrote: > > ?On 2022-08-08 12:20, Stefan Ram wrote: >> Andreas Croci writes: >>> Basically the question boils down to wether it is possible to have parts of a program (could be functions) that keep doing their job while other parts do something else on the same data, and what is the best way to do this. >> Yes, but this is difficult. If you ask this question here, >> you might not be ready for this. >> I haven't learned it yet myself, but nevertheless tried to >> write a small example program quickly, which might still >> contain errors because of my lack of education. >> import threading >> import time >> def write_to_list( list, lock, event ): >> for i in range( 10 ): >> lock.acquire() >> try: >> list.append( i ) >> finally: >> lock.release() >> event.set() >> time.sleep( 3 ) >> def read_from_list( list, lock, event ): >> while True: >> event.wait() >> print( "Waking up." ) >> event.clear() >> if len( list ): >> print( "List contains " + str( list[ 0 ]) + "." ) >> lock.acquire() >> try: >> del list[ 0 ] >> finally: >> lock.release() >> else: >> print( "List is empty." ) >> list = [] >> lock = threading.Lock() >> event = threading.Event() >> threading.Thread( target=write_to_list, args=[ list, lock, event ]).start() >> threading.Thread( target=read_from_list, args=[ list, lock, event ]).start() >> In basketball, first you must learn to dribble and pass, >> before you can begin to shoot. >> With certain reservations, texts that can be considered >> to learn Python are: >> "Object-Oriented Programming in Python Documentation" - a PDF file, >> Introduction to Programming Using Python - Y Daniel Liang (2013), >> How to Think Like a Computer Scientist - Peter Wentworth (2012-08-12), >> The Coder's Apprentice - Pieter Spronck (2016-09-21), and >> Python Programming - John Zelle (2009). > When working with threads, you should use queues, not lists, because queues do their own locking and can wait for items to arrive, with a timeout, if desired: Lists do not need to be locked in python because of the GIL. However you need locks to synchronise between threads. And as you say a queue has all that locking built in. Barry > > > import queue > import threading > import time > > def write_to_item_queue(item_queue): > for i in range(10): > print("Put", i, "in queue.", flush=True) > item_queue.put(i) > time.sleep(3) > > # Using None to indicate that there's no more to come. > item_queue.put(None) > > def read_from_item_queue(item_queue): > while True: > try: > item = item_queue.get() > except item_queue.Empty: > print("Queue is empty; should've have got here!", flush=True) > else: > print("Queue contains " + str(item) + ".", flush=True) > > if item is None: > # Using None to indicate that there's no more to come. > break > > item_queue = queue.Queue() > > write_thread = threading.Thread(target=write_to_item_queue, args=[item_queue]) > write_thread.start() > > read_thread = threading.Thread(target=read_from_item_queue, args=[item_queue]) > read_thread.start() > > # Wait for the threads to finish. > write_thread.join() > read_thread.join() > > print("Finished.") > -- > https://mail.python.org/mailman/listinfo/python-list > From hjp-python at hjp.at Mon Aug 8 17:09:27 2022 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 8 Aug 2022 23:09:27 +0200 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: <20220808210927.3f3zbwuonptbtazm@hjp.at> On 2022-08-08 13:53:20 +0200, Andreas Croci wrote: > I'm in principle ok with locks, if it must be. What I fear is that the lock > could last long and prevent the function that writes into the list from > doing so every second. With an FFT on a list that contains a few bytes taken > every second over one week time (604.800 samples), I believe it's very > likely that the FFT function takes longer than a second to return. You woudn't lock the part performing the FFT, of course, only the part manipulating the shared list. That said, CPython (the reference implementation of Python) has what is called the Global Interpreter Lock (GIL) which locks every single Python instruction. So you can't have two threads actually computing anything at the same time - at least not if the computation is written in Python. Math packages like Numpy may or may not release the lock while they are busy. hp PS: I also agree with what others have said about the perils of multi-threaded programming. -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From cs at cskk.id.au Mon Aug 8 18:37:34 2022 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 9 Aug 2022 08:37:34 +1000 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: On 08Aug2022 11:20, Stefan Ram wrote: >Andreas Croci writes: >>Basically the question boils down to wether it is possible to have parts >>of a program (could be functions) that keep doing their job while other >>parts do something else on the same data, and what is the best way to do >>this. > > Yes, but this is difficult. If you ask this question here, > you might not be ready for this. This is a very standard requirement for any concurrent activity and the typical approach is a mutex (mutual exclusion). You've already hit on the "standard" approach: a `threading.Lock` object. > lock.acquire() > try: > list.append( i ) > finally: > lock.release() Small note, which makes writing this much clearer. Lock objects are context managers. So: with lock: list.append(i) is all you need. Cheers, Cameron Simpson From oscar.j.benjamin at gmail.com Mon Aug 8 19:22:12 2022 From: oscar.j.benjamin at gmail.com (Oscar Benjamin) Date: Tue, 9 Aug 2022 00:22:12 +0100 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: On Mon, 8 Aug 2022 at 19:01, Andreas Croci wrote: > > tI would like to write a program, that reads from the network a fixed > amount of bytes and appends them to a list. This should happen once a > second. > > Another part of the program should take the list, as it has been filled > so far, every 6 hours or so, and do some computations on the data (a FFT). > > Every so often (say once a week) the list should be saved to a file, > shorthened in the front by so many items, and filled further with the > data coming fom the network. After the first saving of the whole list, > only the new part (the data that have come since the last saving) should > be appended to the file. A timestamp is in the data, so it's easy to say > what is new and what was already there. > > I'm not sure how to do this properly: can I write a part of a program > that keeps doing its job (appending data to the list once every second) > while another part computes something on the data of the same list, > ignoring the new data being written? > > Basically the question boils down to wether it is possible to have parts > of a program (could be functions) that keep doing their job while other > parts do something else on the same data, and what is the best way to do > this. Why do these "parts of a program" need to be part of the *same* program. I would write this as just two separate programs. One collects the data and writes it to a file. The other periodically reads the file and computes the DFT. Note that a lot of the complexity discussed in other posts to do with threads and locks etc comes from the supposed constraint that this needs to be done with threads or something else that can work in parallel *within the same program*. If you relax that constraint the problem becomes a lot simpler. -- Oscar From avi.e.gross at gmail.com Mon Aug 8 19:50:13 2022 From: avi.e.gross at gmail.com (avi.e.gross at gmail.com) Date: Mon, 8 Aug 2022 19:50:13 -0400 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: <00ab01d8ab81$9b36cb60$d1a46220$@gmail.com> Stefan, You are correct that the goal of a lock is to do something rather quickly and atomically, so your design should not do something complex or long before releasing the lock. In your example, you have a producer adding data as regularly as every second and another that wakes up rarely and processes all the data since the last time. So you may want to augment the code you had to do something fast like point another variable at the data gathered so far and move the original variable to an empty list or whatever. Then you release the lock within fractions of a second and let the regular job keep adding to the initially empty list while the other part of the code processes without a lock. A design like the above has the busy worker constantly checking the lock. An alternative if you are sure the other process will only show up almost exactly at 6 hours on the clock, is to have the busy one check the time instead, but that may be more expensive. Still other architectures are possible, such as writing to not a single list for six hours, but some data structure with multiple sub-lists such as one where you switch every minute or so. The second process can note how many entries there are at the moment, and does all but the last and notes the location so the next time it starts there. This would work if you did not need every last bit of data as the two do not interfere with each other. And no real locks would be needed as the only thing the two parts share is the position or identity of the current last fragment which only one process actually touches. Just some ideas. Lots of other variations are very possible. -----Original Message----- From: Python-list On Behalf Of Stefan Ram Sent: Monday, August 8, 2022 7:21 AM To: python-list at python.org Subject: Re: Parallel(?) programming with python Andreas Croci writes: >Basically the question boils down to wether it is possible to have >parts of a program (could be functions) that keep doing their job while >other parts do something else on the same data, and what is the best >way to do this. Yes, but this is difficult. If you ask this question here, you might not be ready for this. I haven't learned it yet myself, but nevertheless tried to write a small example program quickly, which might still contain errors because of my lack of education. import threading import time def write_to_list( list, lock, event ): for i in range( 10 ): lock.acquire() try: list.append( i ) finally: lock.release() event.set() time.sleep( 3 ) def read_from_list( list, lock, event ): while True: event.wait() print( "Waking up." ) event.clear() if len( list ): print( "List contains " + str( list[ 0 ]) + "." ) lock.acquire() try: del list[ 0 ] finally: lock.release() else: print( "List is empty." ) list = [] lock = threading.Lock() event = threading.Event() threading.Thread( target=write_to_list, args=[ list, lock, event ]).start() threading.Thread( target=read_from_list, args=[ list, lock, event ]).start() In basketball, first you must learn to dribble and pass, before you can begin to shoot. With certain reservations, texts that can be considered to learn Python are: "Object-Oriented Programming in Python Documentation" - a PDF file, Introduction to Programming Using Python - Y Daniel Liang (2013), How to Think Like a Computer Scientist - Peter Wentworth (2012-08-12), The Coder's Apprentice - Pieter Spronck (2016-09-21), and Python Programming - John Zelle (2009). -- https://mail.python.org/mailman/listinfo/python-list From cs at cskk.id.au Mon Aug 8 22:30:53 2022 From: cs at cskk.id.au (Cameron Simpson) Date: Tue, 9 Aug 2022 12:30:53 +1000 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: On 09Aug2022 00:22, Oscar Benjamin wrote: >On Mon, 8 Aug 2022 at 19:01, Andreas Croci wrote: >> Basically the question boils down to wether it is possible to have >> parts >> of a program (could be functions) that keep doing their job while other >> parts do something else on the same data, and what is the best way to do >> this. Which is of course feasible, as others have outlined. >Why do these "parts of a program" need to be part of the *same* >program. I would write this as just two separate programs. One >collects the data and writes it to a file. The other periodically >reads the file and computes the DFT. I would also write these as separate programmes, or at least as distinct modes of the same programme (eg "myprog poll" and "myprog archive" etc). Largely because you might run the "poll" regularly and briefly, and the processes phase separately and less frequently. You don't need to keep a single programme lurking around forever - fire it up as required. However, I want to point out that this _in no way_ removes the need for access contol and mutexes. It will change the mechanism (because your two programmes are now operating separately) and makes it more concrete in your mind what _actually and precisely_ needs protection. For example, you probably want to avoid _processing_ a data file at the same time as _updating_ that file. Depending on what you're doing this can be as simple as keeping "to be updated" files with distinct names from "available to be processed/archived" files. This is a standard difficulty with "hot folder" upload areas. A common approach might be to write a file with a "temp" style name (eg ".tmp*") until completed, then rename it to its official name (eg "datafile*"). And then your processing/archiving side can simply ignore the "in progress" files because they do not match the names it cares about. Anyway, those are specifics, which will be driven by what you're actually doing. The point is that you still need to coordinate use of the files suitably for your needs. Doing this in one long running programme with Threads/mutexes or separate programmes sharing a data directory just changes the mechanisms. Cheers, Cameron Simpson From drsalists at gmail.com Mon Aug 8 23:43:37 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 8 Aug 2022 20:43:37 -0700 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: Queues are better than lists for concurrency. If you get the right kind, they have implicit locking, making your code simpler and more robust at the same time. CPython threading is mediocre for software systems that have one or more CPU-bound threads, and your FFT might be CPU-bound. Rather than using threading directly, you probably should use https://docs.python.org/3/library/concurrent.futures.html , which gives you easy switching between threads and processes. Or if you, like me, get inordinately joyous over programs that run on more than one kind of Python, you could give up concurrent.futures and use _thread. Sadly, that gives up easy flipping between threads and processes, but gives you easy flipping between CPython and micropython. Better still, micropython appears to have more scalable threading than CPython, so if you decide you need 20 CPU-hungry threads someday, you are less likely to be in a bind. For reading from a socket, if you're not going the REST route, may I suggest https://stromberg.dnsalias.org/~strombrg/bufsock.html ? It deals with framing and lengths relatively smoothly. Otherwise, robust socket code tends to need while loops and tedious arithmetic. HTH On Mon, Aug 8, 2022 at 10:59 AM Andreas Croci wrote: > I would like to write a program, that reads from the network a fixed > amount of bytes and appends them to a list. This should happen once a > second. > From wlfraed at ix.netcom.com Mon Aug 8 20:50:17 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 08 Aug 2022 20:50:17 -0400 Subject: Parallel(?) programming with python References: Message-ID: <6ua3fhlps6l1pk1akakj5d93i942vua8so@4ax.com> On Mon, 8 Aug 2022 19:39:27 +0200, Andreas Croci declaimed the following: > >Do you mean queues in the sense of deque (the data structure)? I ask >because I can see the advantage there when I try to pop data from the >front of it, but I don't see the sense of the following statement ("than Most likely this was a reference to the Queue module -- which is used to pass data from one thread to another. Your "fetch" thread would package up the "new" data to be processed by the FFT thread. The FFT thread is blocked waiting for data to appear on the queue -- when it appears, the FFT thread reads the entire packet of data and proceeds to process it. Note that in this scheme, the FFT thread is NOT on a timer -- the fetch thread controls the timing by when it puts data into the queue. cf: https://docs.python.org/3/library/threading.html https://docs.python.org/3/library/queue.html > >That would obviusly save some coding (but would introduce the need to >code the interaction with the database), but I'm not sure it would speed >up the thing. Would the RDBMS allow to read a table while something else >is writing to it? I doubt it and I'm not sure it doesn't flush the cache >before letting you read, which would include a normally slow disk access. > Depends upon the RDBMs. Some are "multi-version concurrency" -- they snapshot the data at the time of the read, while letting new writes proceed. But if one is doing read/modify/write, this can cause a problem as the RDBM will detect that a record was modified by someone else and prevent you from changing it -- you have to reselect the data to get the current version. You will want to treat each of your network fetches as a transaction -- and close the transaction fast. Your FFT process would need to select all data in the range to be processed, and load it into memory so you can free that transaction https://www.sqlite.org/lockingv3.html See section 3.0 and section 5.0 -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From guilhermecamposbh at gmail.com Mon Aug 8 21:26:07 2022 From: guilhermecamposbh at gmail.com (Guilherme Campos) Date: Mon, 8 Aug 2022 22:26:07 -0300 Subject: Conecting to MySQL Message-ID: Hello folks, trying to connect to MYSQL it appears the error msg below: InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' (111 Connection refused) [image: conexao.png] How can i fix that.? thanks in advance Guilherme Campos Belo Horizonte - MG From ikorot01 at gmail.com Tue Aug 9 10:18:03 2022 From: ikorot01 at gmail.com (Igor Korot) Date: Tue, 9 Aug 2022 09:18:03 -0500 Subject: Conecting to MySQL In-Reply-To: References: Message-ID: Hi, On Tue, Aug 9, 2022 at 9:07 AM Guilherme Campos wrote: > > Hello folks, > > trying to connect to MYSQL it appears the error msg below: > InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' > (111 Connection refused) > [image: conexao.png] > How can i fix that.? What do you use for connection? Does the firewall interfere with the connection? Thank you. > > thanks in advance > > Guilherme Campos > Belo Horizonte - MG > -- > https://mail.python.org/mailman/listinfo/python-list From guilhermecamposbh at gmail.com Tue Aug 9 10:55:27 2022 From: guilhermecamposbh at gmail.com (Guilherme Campos) Date: Tue, 9 Aug 2022 11:55:27 -0300 Subject: Conecting to MySQL In-Reply-To: References: Message-ID: Igor, firewall was disable... Em ter., 9 de ago. de 2022 ?s 11:18, Igor Korot escreveu: > Hi, > > On Tue, Aug 9, 2022 at 9:07 AM Guilherme Campos > wrote: > > > > Hello folks, > > > > trying to connect to MYSQL it appears the error msg below: > > InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' > > (111 Connection refused) > > [image: conexao.png] > > How can i fix that.? > > What do you use for connection? > Does the firewall interfere with the connection? > > Thank you. > > > > > thanks in advance > > > > Guilherme Campos > > Belo Horizonte - MG > > -- > > https://mail.python.org/mailman/listinfo/python-list > From axy at declassed.art Tue Aug 9 11:27:16 2022 From: axy at declassed.art (Axy) Date: Tue, 9 Aug 2022 08:27:16 -0700 Subject: Conecting to MySQL In-Reply-To: References: Message-ID: >> trying to connect to MYSQL it appears the error msg below: >> InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' >> (111 Connection refused) >> [image: conexao.png] >> How can i fix that.? > What do you use for connection? > Does the firewall interfere with the connection? Firewall usually causes connection to hang and timeout with no response. But in this case connection looks immediately refused which means either port number is wrong or mysql is not listening on 127.0.0.1. Axy From ikorot01 at gmail.com Tue Aug 9 11:36:14 2022 From: ikorot01 at gmail.com (Igor Korot) Date: Tue, 9 Aug 2022 10:36:14 -0500 Subject: Conecting to MySQL In-Reply-To: References: Message-ID: Hi, @OP, Can you try to connect with mysql-workbench? Also - you didn't answer my first question. Are you using an ODBC wrapper or python module? Thank you. On Tue, Aug 9, 2022 at 10:27 AM Axy wrote: > > > >> trying to connect to MYSQL it appears the error msg below: > >> InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' > >> (111 Connection refused) > >> [image: conexao.png] > >> How can i fix that.? > > What do you use for connection? > > Does the firewall interfere with the connection? > > Firewall usually causes connection to hang and timeout with no response. > > But in this case connection looks immediately refused which means either > port number is wrong or mysql is not listening on 127.0.0.1. > > > Axy > From guilhermecamposbh at gmail.com Tue Aug 9 11:45:33 2022 From: guilhermecamposbh at gmail.com (Guilherme Campos) Date: Tue, 9 Aug 2022 12:45:33 -0300 Subject: Conecting to MySQL In-Reply-To: References: Message-ID: Hi Igor, Accessing mysql-workbench it appeared new error messages when I clicked Server Status. I created my database on MySQL Workbench . Is that your question? [image: image.png] [image: image.png] Em ter., 9 de ago. de 2022 ?s 12:36, Igor Korot escreveu: > Hi, > @OP, > Can you try to connect with mysql-workbench? > Also - you didn't answer my first question. > > Are you using an ODBC wrapper or python module? > > Thank you. > > > On Tue, Aug 9, 2022 at 10:27 AM Axy wrote: > > > > > > >> trying to connect to MYSQL it appears the error msg below: > > >> InterfaceError: 2003: Can't connect to MySQL server on > 'localhost:3306' > > >> (111 Connection refused) > > >> [image: conexao.png] > > >> How can i fix that.? > > > What do you use for connection? > > > Does the firewall interfere with the connection? > > > > Firewall usually causes connection to hang and timeout with no response. > > > > But in this case connection looks immediately refused which means either > > port number is wrong or mysql is not listening on 127.0.0.1. > > > > > > Axy > > > From Joseph.Schachner at Teledyne.com Tue Aug 9 13:04:51 2022 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph (US)) Date: Tue, 9 Aug 2022 17:04:51 +0000 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: Why would this application *require* parallel programming? This could be done in one, single thread program. Call time to get time and save it as start_time. Keep a count of the number of 6 hour intervals, initialize it to 0. Once a second read data an append to list. At 6 hours after start time, call a function that does an FFT (see comment about scipy below) and increment the count of 6 hour intervals. Call time and save new start time. Continue execution. After 28 six hour intervals, save the list and then slice the list to shorten it as you want. Reset the count of 6 hour intervals to zero. The FFT might take a second, even if you use scipy, depending on how long the list is (If you don?t know about numpy and scipy, look them up! You need them. Your list can be an array in numpy). Saving and slicing the list should take less than a second. This single thread approach avoids thinking about multiprocessing, locking and unlocking data structures, all that stuff that does not contribute to the goal of the program. --- Joseph S. Teledyne Confidential; Commercially Sensitive Business Data -----Original Message----- From: Andreas Croci Sent: Monday, August 8, 2022 6:47 AM To: python-list at python.org Subject: Parallel(?) programming with python tI would like to write a program, that reads from the network a fixed amount of bytes and appends them to a list. This should happen once a second. Another part of the program should take the list, as it has been filled so far, every 6 hours or so, and do some computations on the data (a FFT). Every so often (say once a week) the list should be saved to a file, shorthened in the front by so many items, and filled further with the data coming fom the network. After the first saving of the whole list, only the new part (the data that have come since the last saving) should be appended to the file. A timestamp is in the data, so it's easy to say what is new and what was already there. I'm not sure how to do this properly: can I write a part of a program that keeps doing its job (appending data to the list once every second) while another part computes something on the data of the same list, ignoring the new data being written? Basically the question boils down to wether it is possible to have parts of a program (could be functions) that keep doing their job while other parts do something else on the same data, and what is the best way to do this. From dciprus at cisco.com Tue Aug 9 14:40:10 2022 From: dciprus at cisco.com (Dan Ciprus (dciprus)) Date: Tue, 9 Aug 2022 18:40:10 +0000 Subject: Conecting to MySQL In-Reply-To: References: Message-ID: <20220809183655.ef4yzx2jfvyihoy3@carbon> Yes, exactly that .. I replied from different account and my email was rejected. Just make sure that your mysql is actually running. Depending on your OS, run netstat -an | grep 3306 and this will tell you whether socket is actually in listening mode or not. If it's not, your mysql is either not running or you have a problem with the configuration. On Tue, Aug 09, 2022 at 08:27:16AM -0700, Axy via Python-list wrote: > >>>trying to connect to MYSQL it appears the error msg below: >>>InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' >>>(111 Connection refused) >>>[image: conexao.png] >>>How can i fix that.? >>What do you use for connection? >>Does the firewall interfere with the connection? > >Firewall usually causes connection to hang and timeout with no response. > >But in this case connection looks immediately refused which means >either port number is wrong or mysql is not listening on 127.0.0.1. > > >Axy > >-- >https://mail.python.org/mailman/listinfo/python-list -- Daniel Ciprus .:|:.:|:. [ curl -L http://git.io/unix ] -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: From dciprus at cisco.com Tue Aug 9 15:01:33 2022 From: dciprus at cisco.com (Dan Ciprus (dciprus)) Date: Tue, 9 Aug 2022 19:01:33 +0000 Subject: Conecting to MySQL In-Reply-To: References: Message-ID: <20220809190131.pvuynuz4fewijpk5@carbon> I'm not sure about this but this mailing list does not allow attachments ... On Tue, Aug 09, 2022 at 12:45:33PM -0300, Guilherme Campos wrote: >Hi Igor, > >Accessing mysql-workbench it appeared new error messages when I clicked >Server Status. > >I created my database on MySQL Workbench . Is that your question? > > >[image: image.png] > >[image: image.png] > > >Em ter., 9 de ago. de 2022 ?s 12:36, Igor Korot >escreveu: > >> Hi, >> @OP, >> Can you try to connect with mysql-workbench? >> Also - you didn't answer my first question. >> >> Are you using an ODBC wrapper or python module? >> >> Thank you. >> >> >> On Tue, Aug 9, 2022 at 10:27 AM Axy wrote: >> > >> > >> > >> trying to connect to MYSQL it appears the error msg below: >> > >> InterfaceError: 2003: Can't connect to MySQL server on >> 'localhost:3306' >> > >> (111 Connection refused) >> > >> [image: conexao.png] >> > >> How can i fix that.? >> > > What do you use for connection? >> > > Does the firewall interfere with the connection? >> > >> > Firewall usually causes connection to hang and timeout with no response. >> > >> > But in this case connection looks immediately refused which means either >> > port number is wrong or mysql is not listening on 127.0.0.1. >> > >> > >> > Axy >> > >> >-- >https://mail.python.org/mailman/listinfo/python-list -- Daniel Ciprus .:|:.:|:. CONSULTING ENGINEER.CUSTOMER DELIVERY Cisco Systems Inc. dciprus at cisco.com tel: +1-703-484-0205 mob: +1-540-223-7098 [ curl -L http://git.io/unix ] -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: From helmut at weingrill.net Wed Aug 10 04:02:57 2022 From: helmut at weingrill.net (Helmut Weingrill) Date: Wed, 10 Aug 2022 10:02:57 +0200 Subject: cols_justification Message-ID: <32b522e0-828a-b7ca-c978-8d5320aa69a1@weingrill.net> I installed Python 3.11 0b3. In the IDLE, cols_justification works fine in my program "sg.Table". When installing Pycharm 2022.2 later, "cols_just.." does not work. Error message: File "H:\pf\PyFibu\FIBU.py", line 85, in beg_buchen [sg.table(values=list field, headings=header, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Table.__init__() received an unexpected keyword argument 'cols_justification'. Please, I need help - thanks! From python at mrabarnett.plus.com Wed Aug 10 13:04:50 2022 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 10 Aug 2022 18:04:50 +0100 Subject: cols_justification In-Reply-To: <32b522e0-828a-b7ca-c978-8d5320aa69a1@weingrill.net> References: <32b522e0-828a-b7ca-c978-8d5320aa69a1@weingrill.net> Message-ID: <0dfb6785-4242-4579-4927-b91ff631f4a8@mrabarnett.plus.com> On 2022-08-10 09:02, Helmut Weingrill wrote: > I installed Python 3.11 0b3. In the IDLE, cols_justification works fine > in my program "sg.Table". When installing Pycharm 2022.2 later, > "cols_just.." does not work. Error message: File "H:\pf\PyFibu\FIBU.py", > line 85, in beg_buchen [sg.table(values=list field, headings=header, > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Table.__init__() received an > unexpected keyword argument 'cols_justification'. Please, I need help - > thanks! It would've helped if you had mentioned PySimpleGUI. It took me some time to figure out what you were talking about! Anyway, it looks like you're using an older version of it when using PyCharm (or PyCharm is finding an older version of it or Python). From dieter at handshake.de Wed Aug 10 13:33:04 2022 From: dieter at handshake.de (Dieter Maurer) Date: Wed, 10 Aug 2022 19:33:04 +0200 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: <25331.60368.319662.710495@ixdm.fritz.box> Schachner, Joseph (US) wrote at 2022-8-9 17:04 +0000: >Why would this application *require* parallel programming? This could be done in one, single thread program. Call time to get time and save it as start_time. Keep a count of the number of 6 hour intervals, initialize it to 0. You could also use the `sched` module from Python's library. From wlfraed at ix.netcom.com Wed Aug 10 14:19:37 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Wed, 10 Aug 2022 14:19:37 -0400 Subject: Parallel(?) programming with python References: <25331.60368.319662.710495@ixdm.fritz.box> Message-ID: On Wed, 10 Aug 2022 19:33:04 +0200, "Dieter Maurer" declaimed the following: >Schachner, Joseph (US) wrote at 2022-8-9 17:04 +0000: >>Why would this application *require* parallel programming? This could be done in one, single thread program. Call time to get time and save it as start_time. Keep a count of the number of 6 hour intervals, initialize it to 0. > >You could also use the `sched` module from Python's library. Time to really read the library reference manual again... Though if I read this correctly, a long running action /will/ delay others -- which could mean the (FFT) process could block collecting new 1-second readings while it is active. It also is "one-shot" on the scheduled actions, meaning those actions still have to reschedule themselves for the next time period. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From 2QdxY4RzWzUUiLuE at potatochowder.com Wed Aug 10 14:43:47 2022 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Wed, 10 Aug 2022 13:43:47 -0500 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: On 2022-08-09 at 17:04:51 +0000, "Schachner, Joseph (US)" wrote: > Why would this application *require* parallel programming? This could > be done in one, single thread program. Call time to get time and save > it as start_time. Keep a count of the number of 6 hour intervals, > initialize it to 0. In theory, you are correct. In practice, [stuff] happens. What if your program crashes? Or the computer crashes? Or there's a Python update? Or an OS update? Where does all that pending data go, and how will you recover it after you've addressed whatever happened? ? OTOH, once you start writing the pending data to a file, then it's an extremely simple leap to multiple programs (rather than multiple threads) for all kinds of good reasons. ? FWIW, I used to develop highly available systems, such as telephone switches, which allow [stuff] to happen, and yet continue to function. It's pretty cool to yank a board (yes, physically remove it, without warning) from the system without [apparently] disrupting anything. Such systems also allow for hardware, OS, and application upgrades, too (IIRC, we were allowed a handful of seconds of downtime per year to meet our availability requirements). That said, designing and building such a system for the sakes of simplicity and convenience of the application we're talking about here would make a pretty good definition of "overkill." From avi.e.gross at gmail.com Wed Aug 10 14:54:36 2022 From: avi.e.gross at gmail.com (avi.e.gross at gmail.com) Date: Wed, 10 Aug 2022 14:54:36 -0400 Subject: Parallel(?) programming with python In-Reply-To: <25331.60368.319662.710495@ixdm.fritz.box> References: <25331.60368.319662.710495@ixdm.fritz.box> Message-ID: <011901d8acea$a32bc8b0$e9835a10$@gmail.com> There are many possible discussions we can have here and some are not really about whether and how to use Python. The user asked how to do what is a fairly standard task for some people and arguably is not necessarily best done using a single application running things in parallel. So, yes, if you have full access to your machine and can schedule tasks, then some obvious answers come to mind where one process listens and receives data and stores it, and another process periodically wakes up and grabs recent data and processes it and perhaps still another process comes up even less often and does some re-arrangement of old data. And, yes, for such large volumes of data it may be a poor design to hold all the data in memory for many hours or even days and various ways of using a database or files/folders with a naming structure are a good idea. But the original question remains, in my opinion, a not horrible one. All kinds of applications can be written with sets of tasks run largely in parallel with some form of communication between tasks using shared data structures like queues and perhaps locks and with a requirement that any tasks that take nontrivial time need a way to buffer any communications to not block others. Also, for people who want to start ONE process and let it run, and perhaps may not be able to easily schedule other processes on a system level, it can be advantageous to know how to set up something along those lines within a single python session. Of course, for efficiency reasons, any I/O to files slows things down but what is described here as the situation seems to be somewhat easier and safer to do in so many other ways. I think a main point is that there are good ways to avoid the data from being acted on by two parties that share memory. One is NOT to share memory for this purpose. Another might be to have the 6-hour process use a lock to move the data aside or send a message to the receiving process to pause a moment and set the data aside and begin collecting anew while the old is processed and so on. There are many such choices and the parts need not be in the same process or all written in python. But some solutions can be generalized easier than others. For example, can there become a need to collect data from multiple sources, perhaps using multiple listeners? -----Original Message----- From: Python-list On Behalf Of Dieter Maurer Sent: Wednesday, August 10, 2022 1:33 PM To: Schachner, Joseph (US) Cc: Andreas Croci ; python-list at python.org Subject: RE: Parallel(?) programming with python Schachner, Joseph (US) wrote at 2022-8-9 17:04 +0000: >Why would this application *require* parallel programming? This could be done in one, single thread program. Call time to get time and save it as start_time. Keep a count of the number of 6 hour intervals, initialize it to 0. You could also use the `sched` module from Python's library. -- https://mail.python.org/mailman/listinfo/python-list From hjp-python at hjp.at Wed Aug 10 16:29:38 2022 From: hjp-python at hjp.at (Peter J. Holzer) Date: Wed, 10 Aug 2022 22:29:38 +0200 Subject: Parallel(?) programming with python In-Reply-To: References: <25331.60368.319662.710495@ixdm.fritz.box> Message-ID: <20220810202938.rakcvusfgenmvsrx@hjp.at> On 2022-08-10 14:19:37 -0400, Dennis Lee Bieber wrote: > On Wed, 10 Aug 2022 19:33:04 +0200, "Dieter Maurer" > declaimed the following: > >Schachner, Joseph (US) wrote at 2022-8-9 17:04 +0000: > >>Why would this application *require* parallel programming? This > >>could be done in one, single thread program. Call time to get time > >>and save it as start_time. Keep a count of the number of 6 hour > >>intervals, initialize it to 0. [...] > Though if I read this correctly, a long running action /will/ > delay others -- which could mean the (FFT) process could block > collecting new 1-second readings while it is active. Certainly, but does it matter? Data is received from some network connection and network connections often involve quite a bit of buffering. If the consumer is blocked for 3 or 4 or maybe even 20 seconds, the producer might not even notice. (This of course depends very much on the details which we know nothing about.) hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From subtitle.indo at gmail.com Thu Aug 11 08:52:05 2022 From: subtitle.indo at gmail.com (subin) Date: Thu, 11 Aug 2022 13:52:05 +0100 Subject: Parallel(?) programming with python In-Reply-To: <20220810202938.rakcvusfgenmvsrx@hjp.at> References: <25331.60368.319662.710495@ixdm.fritz.box> <20220810202938.rakcvusfgenmvsrx@hjp.at> Message-ID: Thanks again for the info. On Wed, Aug 10, 2022 at 9:31 PM Peter J. Holzer wrote: > On 2022-08-10 14:19:37 -0400, Dennis Lee Bieber wrote: > > On Wed, 10 Aug 2022 19:33:04 +0200, "Dieter Maurer" > > > declaimed the following: > > >Schachner, Joseph (US) wrote at 2022-8-9 17:04 +0000: > > >>Why would this application *require* parallel programming? This > > >>could be done in one, single thread program. Call time to get time > > >>and save it as start_time. Keep a count of the number of 6 hour > > >>intervals, initialize it to 0. > [...] > > Though if I read this correctly, a long running action /will/ > > delay others -- which could mean the (FFT) process could block > > collecting new 1-second readings while it is active. > > Certainly, but does it matter? Data is received from some network > connection and network connections often involve quite a bit of > buffering. If the consumer is blocked for 3 or 4 or maybe even 20 > seconds, the producer might not even notice. (This of course depends > very much on the details which we know nothing about.) > > hp > > -- > _ | Peter J. Holzer | Story must make more sense than reality. > |_|_) | | > | | | hjp at hjp.at | -- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!" > -- > https://mail.python.org/mailman/listinfo/python-list > From subtitle.indo at gmail.com Thu Aug 11 08:54:56 2022 From: subtitle.indo at gmail.com (subin) Date: Thu, 11 Aug 2022 13:54:56 +0100 Subject: Parallel(?) programming with python In-Reply-To: References: Message-ID: Please let me know if that is okay. On Wed, Aug 10, 2022 at 7:46 PM <2QdxY4RzWzUUiLuE at potatochowder.com> wrote: > On 2022-08-09 at 17:04:51 +0000, > "Schachner, Joseph (US)" wrote: > > > Why would this application *require* parallel programming? This could > > be done in one, single thread program. Call time to get time and save > > it as start_time. Keep a count of the number of 6 hour intervals, > > initialize it to 0. > > In theory, you are correct. > > In practice, [stuff] happens. What if your program crashes? Or the > computer crashes? Or there's a Python update? Or an OS update? Where > does all that pending data go, and how will you recover it after you've > addressed whatever happened? ? > > OTOH, once you start writing the pending data to a file, then it's an > extremely simple leap to multiple programs (rather than multiple > threads) for all kinds of good reasons. > > ? FWIW, I used to develop highly available systems, such as telephone > switches, which allow [stuff] to happen, and yet continue to function. > It's pretty cool to yank a board (yes, physically remove it, without > warning) from the system without [apparently] disrupting anything. Such > systems also allow for hardware, OS, and application upgrades, too > (IIRC, we were allowed a handful of seconds of downtime per year to meet > our availability requirements). That said, designing and building such > a system for the sakes of simplicity and convenience of the application > we're talking about here would make a pretty good definition of > "overkill." > -- > https://mail.python.org/mailman/listinfo/python-list > From dieter at handshake.de Thu Aug 11 12:13:07 2022 From: dieter at handshake.de (Dieter Maurer) Date: Thu, 11 Aug 2022 18:13:07 +0200 Subject: Parallel(?) programming with python In-Reply-To: References: <25331.60368.319662.710495@ixdm.fritz.box> Message-ID: <25333.10899.734244.696128@ixdm.fritz.box> Dennis Lee Bieber wrote at 2022-8-10 14:19 -0400: >On Wed, 10 Aug 2022 19:33:04 +0200, "Dieter Maurer" > ... >>You could also use the `sched` module from Python's library. > > Time to really read the library reference manual again... > > Though if I read this correctly, a long running action /will/ delay >others -- which could mean the (FFT) process could block collecting new >1-second readings while it is active. It also is "one-shot" on the >scheduled actions, meaning those actions still have to reschedule >themselves for the next time period. Both true. With `multiprocessing`, you can delegate long running activity to a separate process. From avi.e.gross at gmail.com Sun Aug 14 21:33:38 2022 From: avi.e.gross at gmail.com (avi.e.gross at gmail.com) Date: Sun, 14 Aug 2022 21:33:38 -0400 Subject: [Tutor] (no subject) References: Message-ID: <00b401d8b047$0bb9c440$232d4cc0$@gmail.com> How long? Not fibbing but infinite is infinite and I simply so not have the time. This is so such an EASY question that you need to show some work to interest us. You can do this in ANY programming language so explain if there is a reason you ask here or ... The real question is what you want. Do you want an algorithm, perhaps in a function, that returns the first N numbers in the sequence, or one that can start with an alternate sequences than the usual 0/1 or perhaps do you want a generator that will return one number at a time infinitely, or until the world ends, or someone pulls a power cord, whichever is sooner? -----Original Message----- From: Tutor On Behalf Of Phindile Julia Sent: Sunday, August 14, 2022 12:49 PM To: tutor at python.org Subject: [Tutor] (no subject) Hey how to create a Fibonacci list? _______________________________________________ Tutor maillist - Tutor at python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor From torriem at gmail.com Sun Aug 14 21:35:54 2022 From: torriem at gmail.com (Michael Torrie) Date: Sun, 14 Aug 2022 19:35:54 -0600 Subject: Conecting to MySQL In-Reply-To: References: Message-ID: <4085ab86-3b52-aa59-89cd-a913e10d7765@gmail.com> On 8/8/22 19:26, Guilherme Campos wrote: > Hello folks, > > trying to connect to MYSQL it appears the error msg below: > InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' > (111 Connection refused) > [image: conexao.png] > How can i fix that.? MySQL can listen on a local unix socket (named pipe in Windows), an internet TCP/IP port, or both. If your MySQL is running, it could be listening on the local socket or named port, which has a different url than localhost:3306. MySQL can be configured to also listen on a TCP/IP port, which is what you code is apparently expecting. Although the fact that your MySQL Workbench cannot connect either suggests that MySQL is not running at all. Configuring MySQL is a bit beyond the scope of this list, although I'm sure there are people here who know how to do it. What OS are you using? From owahjonathan at gmail.com Sat Aug 13 07:55:17 2022 From: owahjonathan at gmail.com (Jonathan Owah) Date: Sat, 13 Aug 2022 12:55:17 +0100 Subject: Persistent Error: Python was not found Message-ID: Good day, Great job on making Python easily accessible. I'm using a Windows 10, 64gb HP EliteBook. I've been trying to configure my laptop to run python scripts. This is the error I keep getting: Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. Everything I've tried has failed. I've uninstalled and reinstalled I've added to path, both user and system path,manually and from fresh installation I've downloaded from Microsoft Store I've gone to manage app aliases and switched off I've used Git Bash, Powershell, cmd I'm able to check my python version: 3.10.6. I can't do anything else and it's really frustrating. I've been at it for days, I don't know what else to do. Thanks in advance for your help. Regards From gorevaradv at gmail.com Sat Aug 13 11:32:19 2022 From: gorevaradv at gmail.com (Varad Gore) Date: Sat, 13 Aug 2022 08:32:19 -0700 (PDT) Subject: Python getting problem of installing pyqt5 Message-ID: Collecting pyqt5 Using cached PyQt5-5.15.7-cp37-abi3-win_amd64.whl (6.8 MB) Requirement already satisfied: PyQt5-Qt5>=5.15.0 in c:\users\gorev\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from pyqt5) (5.15.2) Requirement already satisfied: PyQt5-sip<13,>=12.11 in c:\users\gorev\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from pyqt5) (12.11.0) Installing collected packages: pyqt5 WARNING: The scripts pylupdate5.exe, pyrcc5.exe and pyuic5.exe are installed in 'C:\Users\gorev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed pyqt5-5.15.7 (venv) PS C:\Users\gorev\OneDrive\Desktop\Medidost> ^C (venv) PS C:\Users\gorev\OneDrive\Desktop\Medidost> pip install pyqt5-tools Collecting pyqt5-tools Using cached pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB) Collecting pyqt5==5.15.4 Using cached PyQt5-5.15.4.tar.gz (3.3 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error ? Preparing metadata (pyproject.toml) did not run successfully. ? exit code: 1 ??> [29 lines of output] Traceback (most recent call last): File "C:\Users\gorev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 156, in prepare_metadata_for_build_wheel hook = backend.prepare_metadata_for_build_wheel AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\gorev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in main() File "C:\Users\gorev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "C:\Users\gorev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 160, in prepare_metadata_for_build_wheel whl_basename = backend.build_wheel(metadata_directory, config_settings) File "C:\Users\gorev\AppData\Local\Temp\pip-build-env-tp5amvi7\overlay\Lib\site-packages\sipbuild\api.py", line 46, in build_wheel project = AbstractProject.bootstrap('wheel', File "C:\Users\gorev\AppData\Local\Temp\pip-build-env-tp5amvi7\overlay\Lib\site-packages\sipbuild\abstract_project.py", line 87, in bootstrap project.setup(pyproject, tool, tool_description) File "C:\Users\gorev\AppData\Local\Temp\pip-build-env-tp5amvi7\overlay\Lib\site-packages\sipbuild\project.py", line 584, in setup self.apply_user_defaults(tool) File "C:\Users\gorev\AppData\Local\Temp\pip-install-gufhuvvi\pyqt5_1a911aba5155486d9ea117814aa4a43e\project.py", line 63, in apply_user_defaults super().apply_user_defaults(tool) File "C:\Users\gorev\AppData\Local\Temp\pip-build-env-tp5amvi7\overlay\Lib\site-packages\pyqtbuild\project.py", line 70, in apply_user_defaults super().apply_user_defaults(tool) File "C:\Users\gorev\AppData\Local\Temp\pip-build-env-tp5amvi7\overlay\Lib\site-packages\sipbuild\project.py", line 236, in apply_user_defaults self.builder.apply_user_defaults(tool) File "C:\Users\gorev\AppData\Local\Temp\pip-build-env-tp5amvi7\overlay\Lib\site-packages\pyqtbuild\builder.py", line 67, in apply_user_defaults raise PyProjectOptionException('qmake', sipbuild.pyproject.PyProjectOptionException [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed ? Encountered error while generating package metadata. ??> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. From miked at dewhirst.com.au Mon Aug 15 00:38:25 2022 From: miked at dewhirst.com.au (Mike Dewhirst) Date: Mon, 15 Aug 2022 14:38:25 +1000 Subject: Persistent Error: Python was not found In-Reply-To: References: Message-ID: Jonathan This is what I would do ... 1.??? Download Python from python.org not Microsoft 2.??? Install as an expert or custom install to C:\Python310 rather than C:\Program files 3.??? Ignore this point - I was going to mention VirtualEnv which comes later for software development and thereafter you don't need to put Python on the Windows path. As I said, ignore this point. 4.??? Add C:\Python310\Scripts to the path (system or user) 5.??? Add C:\Python310 to the path after C:\Python310\Scripts 6.??? Open a cmd prompt and enter python to prove it starts then quit. Exit the cmd window 7.??? Create a directory in the root of your user profile (C:\Users\Jonathan ??) called pythontest 8.??? Save 'print("hello world")' in a text file called hello.py in the above directory 9.??? Open a cmd prompt and type > python C:\Users\Jonathan\pythontest\hello.py Should work. If you want to execute a python script without first opening a cmd prompt, you need a bat file or shortcut which contains the command line you want executed. Give that a double-click and it should also work. If Python is on the path you don't need to specify where it is. You do need to tell Python what you want it to execute. It is possible that you can associate .py files with Python but that would be a step too far for me. Good luck M On 13/08/2022 9:55 pm, Jonathan Owah wrote: > Good day, > Great job on making Python easily accessible. > > I'm using a Windows 10, 64gb HP EliteBook. > > I've been trying to configure my laptop to run python scripts. > This is the error I keep getting: > Python was not found; run without arguments to install from the Microsoft > Store, or disable this shortcut from Settings > Manage App Execution > Aliases. > > Everything I've tried has failed. > I've uninstalled and reinstalled > I've added to path, both user and system path,manually and from fresh > installation > I've downloaded from Microsoft Store > I've gone to manage app aliases and switched off > I've used Git Bash, Powershell, cmd > > I'm able to check my python version: 3.10.6. > > I can't do anything else and it's really frustrating. > > I've been at it for days, I don't know what else to do. > > Thanks in advance for your help. > > Regards -- Signed email is an absolute defence against phishing. This email has been signed with my private key. If you import my public key you can automatically decrypt my signature and be sure it came from me. Just ask and I'll send it to you. Your email software can handle signing. -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 495 bytes Desc: OpenPGP digital signature URL: From barry at barrys-emacs.org Mon Aug 15 02:51:53 2022 From: barry at barrys-emacs.org (Barry) Date: Mon, 15 Aug 2022 07:51:53 +0100 Subject: Persistent Error: Python was not found In-Reply-To: References: Message-ID: > On 15 Aug 2022, at 04:10, Jonathan Owah wrote: > > ?Good day, > Great job on making Python easily accessible. Try using the python launcher py.exe. It is documented here https://docs.python.org/3/using/windows.html#python-launcher-for-windows That page documents lots of other things that you may need to know about on windows. Barry > > I'm using a Windows 10, 64gb HP EliteBook. > > I've been trying to configure my laptop to run python scripts. > This is the error I keep getting: > Python was not found; run without arguments to install from the Microsoft > Store, or disable this shortcut from Settings > Manage App Execution > Aliases. > > Everything I've tried has failed. > I've uninstalled and reinstalled > I've added to path, both user and system path,manually and from fresh > installation > I've downloaded from Microsoft Store > I've gone to manage app aliases and switched off > I've used Git Bash, Powershell, cmd > > I'm able to check my python version: 3.10.6. > > I can't do anything else and it's really frustrating. > > I've been at it for days, I don't know what else to do. > > Thanks in advance for your help. > > Regards > -- > https://mail.python.org/mailman/listinfo/python-list > From eryksun at gmail.com Mon Aug 15 03:14:30 2022 From: eryksun at gmail.com (Eryk Sun) Date: Mon, 15 Aug 2022 02:14:30 -0500 Subject: Persistent Error: Python was not found In-Reply-To: References: Message-ID: On 8/13/22, Jonathan Owah wrote: > > I've been trying to configure my laptop to run python scripts. > This is the error I keep getting: > Python was not found; run without arguments to install from the Microsoft > Store, or disable this shortcut from Settings > Manage App Execution > Aliases. If you keep seeing this message, then the shell is finding and running Microsoft's default "python.exe" redirector app execution alias that's located in "%LocalAppData%\Microsoft\WindowsApps". By default, this directory is set at the beginning of the user "Path" value in the registry and thus takes precedence (but not over the system "Path"). Confirm this by running `where.exe python`. An app execution alias is a special type of filesystem symbolic link to a store app's executable. These aliases are created in a user's "%LocalAppData%\Microsoft\WindowsApps" directory. Store apps themselves are usually installed in "%ProgramFiles%\WindowsApps", which is a system managed directory that even administrators can't easily modify (and shouldn't modify). Each user on a system has their own set of installed store apps, even though the apps are installed only once at the system level. By default, Windows creates "python.exe" and "python3.exe" aliases for the "App Installer" PythonRedirector app. In the alias manager, these two will be clearly listed as aliases for "App Installer". If you run this redirector app with one or more command-line arguments, it will print the above quoted message to the console. If the redirector app is run without arguments, it will open the Microsoft Store to install the latest version of the Python store app distribution. Currently that means Python 3.10. In my experience, the app execution alias manager component of Windows is unreliable. A disabled alias might still exist in "%LocalAppData%\Microsoft\WindowsApps", or an old alias might be left in place when an app is installed. Once the real Python store app is installed, go back into the alias manager and toggle the "python.exe" and "python3.exe" aliases off and back on. If that doesn't resolve the problem, manually delete the "python.exe" and "python3.exe" aliases from "%LocalAppData%\Microsoft\WindowsApps". Then toggle them off and on again in the alias manager. Hopefully they'll be created to correctly alias the real Python app instead of the "App Installer" redirector. From owahjonathan at gmail.com Mon Aug 15 05:11:08 2022 From: owahjonathan at gmail.com (Jonathan Owah) Date: Mon, 15 Aug 2022 10:11:08 +0100 Subject: Persistent Error: Python was not found In-Reply-To: References: Message-ID: Thank you so much for your assistance . The fault was actually mine: I was running a command with python3, instead of just python. python3 works for Mac, but not Windows. I'm fairly new to Python so I was just following along a tutorial, and I didn't take note of the fact that the command didn't work because the tutorial was done on a MacBook, while I'm using a Windows device. Thanks for your help, Regards On Mon, Aug 15, 2022 at 8:14 AM Eryk Sun wrote: > On 8/13/22, Jonathan Owah wrote: > > > > I've been trying to configure my laptop to run python scripts. > > This is the error I keep getting: > > Python was not found; run without arguments to install from the Microsoft > > Store, or disable this shortcut from Settings > Manage App Execution > > Aliases. > > If you keep seeing this message, then the shell is finding and running > Microsoft's default "python.exe" redirector app execution alias that's > located in "%LocalAppData%\Microsoft\WindowsApps". By default, this > directory is set at the beginning of the user "Path" value in the > registry and thus takes precedence (but not over the system "Path"). > Confirm this by running `where.exe python`. > > An app execution alias is a special type of filesystem symbolic link > to a store app's executable. These aliases are created in a user's > "%LocalAppData%\Microsoft\WindowsApps" directory. Store apps > themselves are usually installed in "%ProgramFiles%\WindowsApps", > which is a system managed directory that even administrators can't > easily modify (and shouldn't modify). Each user on a system has their > own set of installed store apps, even though the apps are installed > only once at the system level. > > By default, Windows creates "python.exe" and "python3.exe" aliases for > the "App Installer" PythonRedirector app. In the alias manager, these > two will be clearly listed as aliases for "App Installer". If you run > this redirector app with one or more command-line arguments, it will > print the above quoted message to the console. If the redirector app > is run without arguments, it will open the Microsoft Store to install > the latest version of the Python store app distribution. Currently > that means Python 3.10. > > In my experience, the app execution alias manager component of Windows > is unreliable. A disabled alias might still exist in > "%LocalAppData%\Microsoft\WindowsApps", or an old alias might be left > in place when an app is installed. Once the real Python store app is > installed, go back into the alias manager and toggle the "python.exe" > and "python3.exe" aliases off and back on. If that doesn't resolve the > problem, manually delete the "python.exe" and "python3.exe" aliases > from "%LocalAppData%\Microsoft\WindowsApps". Then toggle them off and > on again in the alias manager. Hopefully they'll be created to > correctly alias the real Python app instead of the "App Installer" > redirector. > From eryksun at gmail.com Mon Aug 15 05:41:21 2022 From: eryksun at gmail.com (Eryk Sun) Date: Mon, 15 Aug 2022 04:41:21 -0500 Subject: Persistent Error: Python was not found In-Reply-To: References: Message-ID: On 8/15/22, Jonathan Owah wrote: > Thank you so much for your assistance . > > The fault was actually mine: I was running a command > with python3, instead of just python. > python3 works for Mac, but not Windows. If the Python 3.10 store app is installed with all aliases enabled, then "python", "python3", and "python3.10" all work. The standard distribution from python.org, on the other hand, only has a "python" executable. From antoon.pardon at vub.be Mon Aug 15 08:56:07 2022 From: antoon.pardon at vub.be (Antoon Pardon) Date: Mon, 15 Aug 2022 14:56:07 +0200 Subject: Exclude 'None' from list comprehension of dicts In-Reply-To: <87czdf9r32.fsf@hornfels.zedat.fu-berlin.de> References: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> <137bc40d-4545-226b-44d0-4770dcd8fea6@vub.be> <87czdf9r32.fsf@hornfels.zedat.fu-berlin.de> Message-ID: Op 5/08/2022 om 07:50 schreef Loris Bennett: > Antoon Pardon writes: > >> Op 4/08/2022 om 13:51 schreef Loris Bennett: >>> Hi, >>> >>> I am constructing a list of dictionaries via the following list >>> comprehension: >>> >>> data = [get_job_efficiency_dict(job_id) for job_id in job_ids] >>> >>> However, >>> >>> get_job_efficiency_dict(job_id) >>> >>> uses 'subprocess.Popen' to run an external program and this can fail. >>> In this case, the dict should just be omitted from 'data'. >>> >>> I can have 'get_job_efficiency_dict' return 'None' and then run >>> >>> filtered_data = list(filter(None, data)) >>> >>> but is there a more elegant way? >> Just wondering, why don't you return an empty dictionary in case of a failure? >> In that case your list will be all dictionaries and empty ones will be processed >> fast enough. > When the list of dictionaries is processed, I would have to check each > element to see if it is empty. That strikes me as being less efficient > than filtering out the empty dictionaries in one go, although obviously > one would need to benchmark that. I may be missing something but why would you have to check each element to see if it is empty? What would go wrong if you just treated empty dictionaries the same as non-empty directories? -- Antoon Pardon. From gvanem at yahoo.no Mon Aug 15 07:58:42 2022 From: gvanem at yahoo.no (Gisle Vanem) Date: Mon, 15 Aug 2022 13:58:42 +0200 Subject: Persistent Error: Python was not found In-Reply-To: References: Message-ID: <5a38088c-9244-b4f0-0fa1-aabaed496824@yahoo.no> Eryk Sun wrote: > If the redirector app > is run without arguments, it will open the Microsoft Store to install > the latest version of the Python store app distribution. Currently > that means Python 3.10. That is true with cmd. But with a shell like 4NT, I get: c:\> "%LocalAppData%\Microsoft\WindowsApps\python.exe" 4NT: (Sys) No access to the file. "C:\Users\gvane\AppData\Local\Microsoft\WindowsApps\python.exe" No matter what I do with this "App Alias" setting. What a broken and confusing design this AppX design is. -- --gv From wlfraed at ix.netcom.com Mon Aug 15 10:27:56 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 15 Aug 2022 10:27:56 -0400 Subject: Persistent Error: Python was not found References: Message-ID: <2olkfhpkjaq29lffkb37su2pvsp6n1tfdj@4ax.com> On Mon, 15 Aug 2022 14:38:25 +1000, Mike Dewhirst declaimed the following: >If you want to execute a python script without first opening a cmd >prompt, you need a bat file or shortcut which contains the command line >you want executed. Give that a double-click and it should also work. > I've never had to do that... But I have file associations set up so that .py is considered to be an executable file. Just double-clicking on the file will run it. The problem is that it will open a command shell, run, and then close the command shell UNLESS one explicitly codes some sort of "hold" at the end of the program jnk = input("Press return to exit") .pyw extension does not open the command shell -- but is meant for programs that use one of the various GUI frameworks, which is probably more than the new-comer is ready to attack. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From andrea.croci at gmx.de Mon Aug 15 02:59:06 2022 From: andrea.croci at gmx.de (Andreas Croci) Date: Mon, 15 Aug 2022 08:59:06 +0200 Subject: Parallel(?) programming with python References: Message-ID: I would like to thank everybody who answered my question. The insight was very informative. This seems to be one of the few newsgroups still alive and kicking, with a lot of knowledgeable people taking the time to help others. I like how quick and easy it is to post questions and receive answers here as compared to web-based forums (although there are some disadvantages too). I'm implementing some of the ideas received here and I will surely have other questions as I go. But the project will take a long time because I'm doing this as a hobby during my vacation, that are unfortunately about to end. Thanks again, Community. On 08.08.22 12:47, Andreas Croci wrote: > tI would like to write a program, that reads from the network a fixed > amount of bytes and appends them to a list. This should happen once a > second. > > Another part of the program should take the list, as it has been filled > so far, every 6 hours or so, and do some computations on the data (a FFT). > > Every so often (say once a week) the list should be saved to a file, > shorthened in the front by so many items, and filled further with the > data coming fom the network. After the first saving of the whole list, > only the new part (the data that have come since the last saving) should > be appended to the file. A timestamp is in the data, so it's easy to say > what is new and what was already there. > > I'm not sure how to do this properly: can I write a part of a program > that keeps doing its job (appending data to the list once every second) > while another part computes something on the data of the same list, > ignoring the new data being written? > > Basically the question boils down to wether it is possible to have parts > of a program (could be functions) that keep doing their job while other > parts do something else on the same data, and what is the best way to do > this. From eryksun at gmail.com Mon Aug 15 12:35:07 2022 From: eryksun at gmail.com (Eryk Sun) Date: Mon, 15 Aug 2022 11:35:07 -0500 Subject: Persistent Error: Python was not found In-Reply-To: <5a38088c-9244-b4f0-0fa1-aabaed496824@yahoo.no> References: <5a38088c-9244-b4f0-0fa1-aabaed496824@yahoo.no> Message-ID: On 8/15/22, Gisle Vanem via Python-list wrote: > Eryk Sun wrote: > >> If the redirector app >> is run without arguments, it will open the Microsoft Store to install >> the latest version of the Python store app distribution. Currently >> that means Python 3.10. > > That is true with cmd. But with a shell like 4NT, I get: > c:\> "%LocalAppData%\Microsoft\WindowsApps\python.exe" > 4NT: (Sys) No access to the file. > "C:\Users\gvane\AppData\Local\Microsoft\WindowsApps\python.exe" > > No matter what I do with this "App Alias" setting. > What a broken and confusing design this AppX design is. An app execution alias is a reparse point with the tag IO_REPARSE_TAG_APPEXECLINK (0x8000001B). Neither the I/O manager no any driver in the kernel supports this type of reparse point. For better or worse, this is intentional. As such, if CreateFileW() is called on an alias without using the flag FILE_FLAG_OPEN_REPARSE_POINT, the attempt to traverse the link fails with ERROR_CANT_ACCESS_FILE (1920). Note that Python's os.stat() was updated to open the reparse point directly in this case instead of failing. But a lot of applications, in particular non-Microsoft shells such as MSYS bash (and apparently 4NT) haven't been updated similarly. Even if the link could be traversed, the target file under "%ProgramFiles%\WindowsApps" doesn't grant execute access to users unless they have an access token that includes a WIN://SYSAPPID attribute that corresponds to the executed app. How this works in practice when executing an app is that CreateProcessW() handles ERROR_CANT_ACCESS_FILE by opening the reparse point, reading the relevant app information, and creating a custom access token that allows it to execute the app directly via the internal equivalent of CreateProcessAsUserW(). From eryksun at gmail.com Mon Aug 15 12:46:50 2022 From: eryksun at gmail.com (Eryk Sun) Date: Mon, 15 Aug 2022 11:46:50 -0500 Subject: Persistent Error: Python was not found In-Reply-To: <2olkfhpkjaq29lffkb37su2pvsp6n1tfdj@4ax.com> References: <2olkfhpkjaq29lffkb37su2pvsp6n1tfdj@4ax.com> Message-ID: On 8/15/22, Dennis Lee Bieber wrote: > > Just double-clicking on the file will run it. The problem is that it > will open a command shell, run, and then close the command shell UNLESS one > explicitly codes some sort of "hold" at the end of the program The console window is a terminal, not a shell. If an application is flagged as a console app, as is "python.exe", and the process doesn't inherit a console, the initialization code in kernelbase.dll allocates a new console session. This could be implemented by the classic conhost.exe host, or, in Windows 11, by an openconsole.exe session that's associated with a tab in Windows Terminal. If it's the latter, Terminal can be configured to keep a tab open after the console session has ended. The tab will display the exit status of the process that allocated the console session. From david at boomer.org Mon Aug 15 12:30:41 2022 From: david at boomer.org (David at Booomer) Date: Mon, 15 Aug 2022 10:30:41 -0600 Subject: Problem using cx_Freeze In-Reply-To: References: Message-ID: I?m trying to use cx_Freeze (https://pypi.org/project/cx-Freeze/) in a python app but running into an error message: AttributeError: module 'cx_Freeze' has no attribute ?BdistDMG? I?m using Anaconda and error appears with the import command: from cx_Freeze import * From the terminal the command: python setup.py build gives much the same error. I believe there is an issue specifying the output file name but don?t know how to resolve it. Any suggestions, thanks. David From mats at wichmann.us Mon Aug 15 14:28:32 2022 From: mats at wichmann.us (Mats Wichmann) Date: Mon, 15 Aug 2022 12:28:32 -0600 Subject: Python getting problem of installing pyqt5 In-Reply-To: References: Message-ID: <9c14d39b-5544-b7cd-1013-c765adfc09ff@wichmann.us> On 8/13/22 09:32, Varad Gore wrote: Looks like you have a version mismatch problem. > Collecting pyqt5 > Using cached PyQt5-5.15.7-cp37-abi3-win_amd64.whl (6.8 MB) > Requirement already satisfied: PyQt5-Qt5>=5.15.0 in c:\users\gorev\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from pyqt5) (5.15.2) > Requirement already satisfied: PyQt5-sip<13,>=12.11 in c:\users\gorev\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from pyqt5) (12.11.0) > Installing collected packages: pyqt5 > WARNING: The scripts pylupdate5.exe, pyrcc5.exe and pyuic5.exe are installed in 'C:\Users\gorev\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts' which is not on PATH. > Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. > Successfully installed pyqt5-5.15.7 So far, so good... but then it goes bad. > (venv) PS C:\Users\gorev\OneDrive\Desktop\Medidost> ^C > (venv) PS C:\Users\gorev\OneDrive\Desktop\Medidost> pip install pyqt5-tools > Collecting pyqt5-tools > Using cached pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB) > Collecting pyqt5==5.15.4 > Using cached PyQt5-5.15.4.tar.gz (3.3 MB) > Installing build dependencies ... done > Getting requirements to build wheel ... done > Preparing metadata (pyproject.toml) ... error > error: subprocess-exited-with-error > > ? Preparing metadata (pyproject.toml) did not run successfully. This apparently depends on a *different* version of pyqt5 which does not have a compatible binary (compiled) wheel available, so the installer process is going to try to build it for you. This rarely works on Windows - you usually have to have some very precise setup - that is, you have to be *planning* to build it, the convenience build-because-didn't-find-wheel is very likely doomed to failure for anything complex. The pyqt5-tools package has not been updated for a year now, several drops of pyqt5 have happened since, according to the history on pypi.org. I'm assuming -tools are pnned to the same version of pyqt5, but this is only a guess, could be some other mismatch. Looks like there's an issue filed on this: https://github.com/altendky/pyqt-tools/issues/106 From wlfraed at ix.netcom.com Mon Aug 15 16:21:05 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 15 Aug 2022 16:21:05 -0400 Subject: Python getting problem of installing pyqt5 References: Message-ID: On Sat, 13 Aug 2022 08:32:19 -0700 (PDT), Varad Gore declaimed the following: >Collecting pyqt5 > Using cached PyQt5-5.15.7-cp37-abi3-win_amd64.whl (6.8 MB) Where did this one come from? The "cp37" seems to imply it is a Python 3.7 variant. You also didn't include the command line that started this sequence... >(venv) PS C:\Users\gorev\OneDrive\Desktop\Medidost> ^C ... was it also run from inside the virtual environment? >(venv) PS C:\Users\gorev\OneDrive\Desktop\Medidost> pip install pyqt5-tools Personally, anytime I see OneDrive involved, my first thought is to blame it (It plays hob with multi-file relational databases, such as Visual FoxPro used by the TMG genealogy program -- VFP opens/closes table files (there are three per table) on an as-needed scheme; OneDrive sees a modified file and locks it while synching it to the cloud -- and that blocks VFP from being able to do the next update, and often causing corruption of the database when the three table files become unsynchronized). However... as a test (note: I have Python (an older ActiveState build) installed "for all users", and not in a user specific install. C:\Users\Wulfraed>pip install pyqt5_tools Collecting pyqt5_tools Downloading pyqt5_tools-5.15.4.3.2-py3-none-any.whl (29 kB) Collecting pyqt5-plugins<5.15.4.3,>=5.15.4.2.2 Downloading pyqt5_plugins-5.15.4.2.2-cp38-cp38-win_amd64.whl (67 kB) |????????????????????????????????| 67 kB 988 kB/s Collecting python-dotenv Downloading python_dotenv-0.20.0-py3-none-any.whl (17 kB) Collecting pyqt5==5.15.4 Downloading PyQt5-5.15.4-cp36.cp37.cp38.cp39-none-win_amd64.whl (6.8 MB) |????????????????????????????????| 6.8 MB 541 kB/s >>>NOTE the file name for PyQt5 Requirement already satisfied: click in c:\python38\lib\site-packages (from pyqt5_tools) (7.1.2) Collecting qt5-tools<5.15.2.2,>=5.15.2.1.2 Downloading qt5_tools-5.15.2.1.2-py3-none-any.whl (13 kB) Collecting PyQt5-Qt5>=5.15 Downloading PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl (50.1 MB) |????????????????????????????????| 50.1 MB 25 kB/s Requirement already satisfied: PyQt5-sip<13,>=12.8 in c:\python38\lib\site-packages (from pyqt5==5.15.4->pyqt5_tools) (12.8.1) Collecting qt5-applications<5.15.2.3,>=5.15.2.2.2 Downloading qt5_applications-5.15.2.2.2-py3-none-win_amd64.whl (60.9 MB) |????????????????????????????????| 60.9 MB 5.5 kB/s Installing collected packages: PyQt5-Qt5, pyqt5, qt5-applications, qt5-tools, pyqt5-plugins, python-dotenv, pyqt5-tools Attempting uninstall: pyqt5 Found existing installation: PyQt5 5.15.1 Uninstalling PyQt5-5.15.1: Successfully uninstalled PyQt5-5.15.1 Successfully installed PyQt5-Qt5-5.15.2 pyqt5-5.15.4 pyqt5-plugins-5.15.4.2.2 pyqt5-tools-5.15.4.3.2 python-dotenv-0.20.0 qt5-applications-5.15.2.2.2 qt5-tools-5.15.2.1.2 C:\Users\Wulfraed> -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From jschwar at sbcglobal.net Mon Aug 15 17:45:39 2022 From: jschwar at sbcglobal.net (jschwar at sbcglobal.net) Date: Mon, 15 Aug 2022 16:45:39 -0500 Subject: Problem using cx_Freeze In-Reply-To: References: Message-ID: <000601d8b0f0$5d4b5f90$17e21eb0$@sbcglobal.net> I see a class called BdistDMG in the module called bdist_mac.py. Did you try importing that from cx_freeze? -----Original Message----- From: Python-list On Behalf Of David at Booomer Sent: Monday, August 15, 2022 11:31 AM To: python-list at python.org Subject: Problem using cx_Freeze I?m trying to use cx_Freeze (https://pypi.org/project/cx-Freeze/) in a python app but running into an error message: AttributeError: module 'cx_Freeze' has no attribute ?BdistDMG? I?m using Anaconda and error appears with the import command: from cx_Freeze import * From the terminal the command: python setup.py build gives much the same error. I believe there is an issue specifying the output file name but don?t know how to resolve it. Any suggestions, thanks. David -- https://mail.python.org/mailman/listinfo/python-list From PythonList at DancesWithMice.info Mon Aug 15 18:20:29 2022 From: PythonList at DancesWithMice.info (dn) Date: Tue, 16 Aug 2022 10:20:29 +1200 Subject: Exclude 'None' from list comprehension of dicts In-Reply-To: References: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> <137bc40d-4545-226b-44d0-4770dcd8fea6@vub.be> <87czdf9r32.fsf@hornfels.zedat.fu-berlin.de> Message-ID: <9ce76cf6-0678-439d-3434-26e3a4d40aa3@DancesWithMice.info> On 16/08/2022 00.56, Antoon Pardon wrote: > Op 5/08/2022 om 07:50 schreef Loris Bennett: >> Antoon Pardon? writes: >> >>> Op 4/08/2022 om 13:51 schreef Loris Bennett: >>>> Hi, >>>> >>>> I am constructing a list of dictionaries via the following list >>>> comprehension: >>>> >>>> ??? data = [get_job_efficiency_dict(job_id) for job_id in job_ids] >>>> >>>> However, >>>> >>>> ??? get_job_efficiency_dict(job_id) >>>> >>>> uses 'subprocess.Popen' to run an external program and this can fail. >>>> In this case, the dict should just be omitted from 'data'. >>>> >>>> I can have 'get_job_efficiency_dict' return 'None' and then run >>>> >>>> ??? filtered_data = list(filter(None, data)) >>>> >>>> but is there a more elegant way? >>> Just wondering, why don't you return an empty dictionary in case of a >>> failure? >>> In that case your list will be all dictionaries and empty ones will >>> be processed >>> fast enough. >> When the list of dictionaries is processed, I would have to check each >> element to see if it is empty.? That strikes me as being less efficient >> than filtering out the empty dictionaries in one go, although obviously >> one would need to benchmark that. > > I may be missing something but why would you have to check each element > to see if it is empty? What would go wrong if you just treated empty > dictionaries the same as non-empty directories? 'Truthiness':- >>> bool( {} ) False >>> bool( { "a":1 } ) True -- Regards, =dn From jschwar at sbcglobal.net Mon Aug 15 19:51:02 2022 From: jschwar at sbcglobal.net (Jim Schwartz) Date: Mon, 15 Aug 2022 18:51:02 -0500 Subject: Problem using cx_Freeze In-Reply-To: References: Message-ID: <1D0DEA52-E8D7-42EF-8CB5-07EADDB1ED8A@sbcglobal.net> This link covers how to use BDist_dmg. https://cx-freeze.readthedocs.io/en/latest/setup_script.html Sent from my iPhone > On Aug 15, 2022, at 12:11 PM, David at Booomer wrote: > > ?I?m trying to use cx_Freeze (https://pypi.org/project/cx-Freeze/) in a python app but running into an error message: > > AttributeError: module 'cx_Freeze' has no attribute ?BdistDMG? > > I?m using Anaconda and error appears with the import command: from cx_Freeze import * > > From the terminal the command: python setup.py build gives much the same error. > > I believe there is an issue specifying the output file name but don?t know how to resolve it. > > Any suggestions, thanks. David > > > -- > https://mail.python.org/mailman/listinfo/python-list From david at boomer.org Mon Aug 15 20:00:48 2022 From: david at boomer.org (David at Booomer) Date: Mon, 15 Aug 2022 18:00:48 -0600 Subject: Problem using cx_Freeze In-Reply-To: <1D0DEA52-E8D7-42EF-8CB5-07EADDB1ED8A@sbcglobal.net> References: <1D0DEA52-E8D7-42EF-8CB5-07EADDB1ED8A@sbcglobal.net> Message-ID: Hi Jim Thanks for your suggestions. I changed from cx_Freeze import * to from cx_Freeze import setup, Executable And no longer get the BdistDMG error ? I had found the page https://cx-freeze.readthedocs.io/en/latest/setup_script.html But hadn?t tried the setup, Executable option in the from statement ? However I now get an error init() takes from 2 to 12 positional arguments but 14 were given I found a couple instances of init in two .py files that were part of the whole. One .py file def __init__(self): Another .py file class Aboutwindow(QtGui.QMainWindow, Ui_Aboutwindow): def __init__(self,parent=None): QtGui.QMainWindow.__init__(self,parent) ? class Main(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) When searching for this error the answers found suggested including self in the init parameter list but the code already has self. Thanks, David > On Aug 15, 2022, at 5:51 PM, Jim Schwartz wrote: > > This link covers how to use BDist_dmg. > > https://cx-freeze.readthedocs.io/en/latest/setup_script.html > > Sent from my iPhone > >> On Aug 15, 2022, at 12:11 PM, David at Booomer wrote: >> >> ?I?m trying to use cx_Freeze (https://pypi.org/project/cx-Freeze/) in a python app but running into an error message: >> >> AttributeError: module 'cx_Freeze' has no attribute ?BdistDMG? >> >> I?m using Anaconda and error appears with the import command: from cx_Freeze import * >> >> From the terminal the command: python setup.py build gives much the same error. >> >> I believe there is an issue specifying the output file name but don?t know how to resolve it. >> >> Any suggestions, thanks. David >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list From wlfraed at ix.netcom.com Mon Aug 15 18:45:05 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 15 Aug 2022 18:45:05 -0400 Subject: Problem using cx_Freeze References: Message-ID: On Mon, 15 Aug 2022 10:30:41 -0600, David at Booomer declaimed the following: >I?m trying to use cx_Freeze (https://pypi.org/project/cx-Freeze/) in a python app but running into an error message: > >AttributeError: module 'cx_Freeze' has no attribute ?BdistDMG? What operating system? BdistDMG appears to be a Macintosh OS module -- something to do with disk images https://cx-freeze.readthedocs.io/en/latest/setup_script.html """ On Windows, you can build a simple installer containing all the files cx_Freeze includes for your application, by running the setup script as: python setup.py bdist_msi On Mac OS X, you can use bdist_dmg to build a Mac disk image. """ Note the command syntax and last line... -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From wlfraed at ix.netcom.com Mon Aug 15 22:18:54 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 15 Aug 2022 22:18:54 -0400 Subject: Problem using cx_Freeze References: <1D0DEA52-E8D7-42EF-8CB5-07EADDB1ED8A@sbcglobal.net> Message-ID: On Mon, 15 Aug 2022 18:00:48 -0600, David at Booomer declaimed the following: >However I now get an error > >init() takes from 2 to 12 positional arguments but 14 were given > >I found a couple instances of init in two .py files that were part of the whole. > >One .py file >def __init__(self): > Please cut&paste the TEXT of the console where the errors are displayed -- don't paraphrase! init() is NOT the same as __init__() WHAT "One .py file"? This is a meaningless bit of information. The most likely __init__() involved is the one where cx_Freeze.Executable is instantiated. https://cx-freeze.readthedocs.io/en/latest/setup_script.html#cx-freeze-executable shows 11 parameters (and "self" would make the 12th). -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From antoon.pardon at vub.be Tue Aug 16 15:31:56 2022 From: antoon.pardon at vub.be (Antoon Pardon) Date: Tue, 16 Aug 2022 21:31:56 +0200 Subject: Exclude 'None' from list comprehension of dicts In-Reply-To: <9ce76cf6-0678-439d-3434-26e3a4d40aa3@DancesWithMice.info> References: <871qtwkz0j.fsf@hornfels.zedat.fu-berlin.de> <137bc40d-4545-226b-44d0-4770dcd8fea6@vub.be> <87czdf9r32.fsf@hornfels.zedat.fu-berlin.de> <9ce76cf6-0678-439d-3434-26e3a4d40aa3@DancesWithMice.info> Message-ID: <95d9a247-42e2-f5b8-6df1-b5fc70b79a97@vub.be> Op 16/08/2022 om 00:20 schreef dn: > On 16/08/2022 00.56, Antoon Pardon wrote: >> Op 5/08/2022 om 07:50 schreef Loris Bennett: >>> Antoon Pardon ? writes: >>> >>>> Op 4/08/2022 om 13:51 schreef Loris Bennett: >>>>> Hi, >>>>> >>>>> I am constructing a list of dictionaries via the following list >>>>> comprehension: >>>>> >>>>> ??? data = [get_job_efficiency_dict(job_id) for job_id in job_ids] >>>>> >>>>> However, >>>>> >>>>> ??? get_job_efficiency_dict(job_id) >>>>> >>>>> uses 'subprocess.Popen' to run an external program and this can fail. >>>>> In this case, the dict should just be omitted from 'data'. >>>>> >>>>> I can have 'get_job_efficiency_dict' return 'None' and then run >>>>> >>>>> ??? filtered_data = list(filter(None, data)) >>>>> >>>>> but is there a more elegant way? >>>> Just wondering, why don't you return an empty dictionary in case of a >>>> failure? >>>> In that case your list will be all dictionaries and empty ones will >>>> be processed >>>> fast enough. >>> When the list of dictionaries is processed, I would have to check each >>> element to see if it is empty.? That strikes me as being less efficient >>> than filtering out the empty dictionaries in one go, although obviously >>> one would need to benchmark that. >> I may be missing something but why would you have to check each element >> to see if it is empty? What would go wrong if you just treated empty >> dictionaries the same as non-empty directories? > 'Truthiness':- In what way is that relevant in this case? -- Antoon Pardon From drsalists at gmail.com Tue Aug 16 17:03:42 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Tue, 16 Aug 2022 14:03:42 -0700 Subject: setup.py + cython == chicken and the egg problem Message-ID: Hi folks. I'm attempting to package up a python package that uses Cython. Rather than build binaries for everything under the sun, I've been focusing on including the .pyx file and running cython on it at install time. This requires a C compiler, but I'm OK with that. However, when I try to install the package from test.pypi.org, I get: $ python3 -m pip install -i https://test.pypi.org/simple/ pyx-treap below cmd output started 2022 Tue Aug 16 01:55:16 PM PDT Looking in indexes: https://test.pypi.org/simple/ Collecting pyx-treap Downloading https://test-files.pythonhosted.org/packages/3a/41/af5360934adccfc086a39e1f720323895144b53454ff6dacc0f06267db55/pyx_treap-2.0.15.tar.gz (125 kB) ???????????????????????????????????????????????????????????????????????????????? 125.9/125.9 kB 1.9 MB/s eta 0:00:00 Installing build dependencies ... error error: subprocess-exited-with-error ?? pip subprocess to install build dependencies did not run successfully. ?? exit code: 1 ????> [3 lines of output] Looking in indexes: https://test.pypi.org/simple/ ERROR: Could not find a version that satisfies the requirement setuptools (from versions: none) ERROR: No matching distribution found for setuptools [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error ?? pip subprocess to install build dependencies did not run successfully. ?? exit code: 1 ????> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. But I analyzed the pip install with strace, and found no interesting exec's, and no interesting "= E" patterns. I've tried quite an assortment of things to get past this, including most of those at: https://stackoverflow.com/questions/4996589/in-setup-py-or-pip-requirements-file-how-to-control-order-of-installing-package Except the one at: https://stackoverflow.com/a/54269307/1084684 ...because I was having a "there must be a better way" reaction to it. /Is/ there a better way? There're all these newer ways of doing packaging - surely one of them addresses this problem? The code I'm trying to package is at: https://stromberg.dnsalias.org/svn/treap/trunk/cython BTW, the pure python version works fine, and the cython version works too as long as you preinstall cython - but I don't want users to have to know that :) Thanks! From rosuav at gmail.com Tue Aug 16 17:07:38 2022 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 17 Aug 2022 07:07:38 +1000 Subject: setup.py + cython == chicken and the egg problem In-Reply-To: References: Message-ID: On Wed, 17 Aug 2022 at 07:05, Dan Stromberg wrote: > > Hi folks. > > I'm attempting to package up a python package that uses Cython. > > Rather than build binaries for everything under the sun, I've been focusing > on including the .pyx file and running cython on it at install time. This > requires a C compiler, but I'm OK with that. > Is keeping the cythonized file an option? That would still require a C compiler, but wouldn't require Cython. ChrisA From drsalists at gmail.com Tue Aug 16 17:21:25 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Tue, 16 Aug 2022 14:21:25 -0700 Subject: setup.py + cython == chicken and the egg problem In-Reply-To: References: Message-ID: On Tue, Aug 16, 2022 at 2:08 PM Chris Angelico wrote: > On Wed, 17 Aug 2022 at 07:05, Dan Stromberg wrote: > > > > Hi folks. > > > > I'm attempting to package up a python package that uses Cython. > > > > Rather than build binaries for everything under the sun, I've been > focusing > > on including the .pyx file and running cython on it at install time. > This > > requires a C compiler, but I'm OK with that. > > > > Is keeping the cythonized file an option? That would still require a C > compiler, but wouldn't require Cython. > > ChrisA > That comes under "one of the many things I tried"; it seemed like some of the code in the .c was tailored to the specific version of python it was being installed on or something. But if someone has seen this work well, I'm more than open to trying it again. From charan9182749076 at gmail.com Wed Aug 17 06:54:03 2022 From: charan9182749076 at gmail.com (i am unable to use python ) Date: Wed, 17 Aug 2022 16:24:03 +0530 Subject: not able to use python Message-ID: <8728ABB4-CA54-4208-B48B-BE8E30F704C7@hxcore.ol> ? ? Sent from [1]Mail for Windows ? References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 From auriocus at gmx.de Wed Aug 17 01:45:49 2022 From: auriocus at gmx.de (Christian Gollwitzer) Date: Wed, 17 Aug 2022 07:45:49 +0200 Subject: setup.py + cython == chicken and the egg problem In-Reply-To: References: Message-ID: Am 16.08.22 um 23:03 schrieb Dan Stromberg: > I'm attempting to package up a python package that uses Cython. > > Rather than build binaries for everything under the sun, I've been focusing > on including the .pyx file and running cython on it at install time. This > requires a C compiler, but I'm OK with that. > > However, when I try to install the package from test.pypi.org, I get: > $ python3 -m pip install -i https://test.pypi.org/simple/ pyx-treap > below cmd output started 2022 Tue Aug 16 01:55:16 PM PDT > Looking in indexes: https://test.pypi.org/simple/ > Collecting pyx-treap > Downloading > https://test-files.pythonhosted.org/packages/3a/41/af5360934adccfc086a39e1f720323895144b53454ff6dacc0f06267db55/pyx_treap-2.0.15.tar.gz > (125 kB) > > ???????????????????????????????????????????????????????????????????????????????? > 125.9/125.9 kB 1.9 MB/s eta 0:00:00 > Installing build dependencies ... error > error: subprocess-exited-with-error > > ?? pip subprocess to install build dependencies did not run successfully. > ?? exit code: 1 > ????> [3 lines of output] > Looking in indexes: https://test.pypi.org/simple/ > ERROR: Could not find a version that satisfies the requirement > setuptools (from versions: none) > ERROR: No matching distribution found for setuptools > [end of output] > > note: This error originates from a subprocess, and is likely not a > problem with pip. > error: subprocess-exited-with-error I looked at your code and I think you are trying too hard. As far as I understand, you need Cython to be installed before the build process begins. Your entry in pyproject.toml should take care of that. But you also have these lines in your setup.py subprocess.check_call('%s -m pip install cython' % (sys.executable, ), shell=True) subprocess.check_call('%s -m cython pyx_treap.pyx' % (sys.executable, ), shell=True) The first one calls out to pip while pip is already running, I'm not sure that this will work, but judging from the error message it is looking for the requirements also from test.pypi. Maybe this is the reason that it fails (the error message says that it can't find setuptools). So jut delete this line and it might already work The second line, which compiles the Cython code, also runs *at every invocation of setup.py*, even if you'd do just python3 setup.py --help It may still work, but the correct way to do it is to create a build extension for setuptools. In my project you can see this here: https://github.com/j-from-b/CDEF/blob/main/setup.py#L88 OTOH, I would be surprised if Cython did not have this already, indeed you imported cythonize from Cython.Build. So maybe just deleting these two lines and it might work? Christian From shailajapatil45 at gmail.com Wed Aug 17 04:05:19 2022 From: shailajapatil45 at gmail.com (Coder) Date: Wed, 17 Aug 2022 01:05:19 -0700 (PDT) Subject: Getting an Error TypeError: unsupported operand type(s) for -=: 'Retry' and 'int' Message-ID: sudo pip install pyro4 Collecting pyro4 Downloading https://files.pythonhosted.org/packages/70/e3/8c4e0d24b46fbf02e6b2dc2da5d18f0c73cfd343a1fb01ae64c788c20e56/Pyro4-4.82-py2.py3-none-any.whl (89kB) 100% |????????????????????????????????| 92kB 7.3MB/s Collecting selectors34; python_version < "3.4" (from pyro4) Downloading https://files.pythonhosted.org/packages/13/25/4f4fa70ab23ad6263fe59cedf9dcd3ef71aa7f99c556c5e4c6435829e22d/selectors34-1.2-py2.py3-none-any.whl Collecting serpent<1.30,>=1.27; python_version < "3.2" (from pyro4) Exception: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 209, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 328, in run wb.build(autobuilding=True) File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 748, in build self.requirement_set.prepare_files(self.finder) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 360, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 512, in _prepare_file finder, self.upgrade, require_hashes) File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 273, in populate_link self.link = finder.find_requirement(self, upgrade) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 442, in find_requirement all_candidates = self.find_all_candidates(req.name) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 400, in find_all_candidates for page in self._get_pages(url_locations, project_name): File "/usr/lib/python2.7/dist-packages/pip/index.py", line 545, in _get_pages page = self._get_page(location) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 648, in _get_page return HTMLPage.get_page(link, session=self.session) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 757, in get_page "Cache-Control": "max-age=600", File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 492, in get return self.request('GET', url, **kwargs) File "/usr/lib/python2.7/dist-packages/pip/download.py", line 378, in request return super(PipSession, self).request(method, url, *args, **kwargs) File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 480, in request resp = self.send(prep, **send_kwargs) File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/sessions.py", line 588, in send r = adapter.send(request, **kwargs) File "/usr/share/python-wheels/CacheControl-0.11.5-py2.py3-none-any.whl/cachecontrol/adapter.py", line 46, in send resp = super(CacheControlAdapter, self).send(request, **kw) File "/usr/share/python-wheels/requests-2.9.1-py2.py3-none-any.whl/requests/adapters.py", line 376, in send timeout=timeout File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 610, in urlopen _stacktrace=sys.exc_info()[2]) File "/usr/share/python-wheels/urllib3-1.13.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 238, in increment total -= 1 TypeError: unsupported operand type(s) for -=: 'Retry' and 'int' You are using pip version 8.1.1, however version 22.2.2 is available. You should consider upgrading via the 'pip install --upgrade pip' command. I tried removing pip and reinstalling it again. still facing same issue. From toby at tobiah.org Wed Aug 17 11:18:57 2022 From: toby at tobiah.org (Tobiah) Date: Wed, 17 Aug 2022 08:18:57 -0700 Subject: UTF-8 and latin1 Message-ID: I get data from various sources; client emails, spreadsheets, and data from web applications. I find that I can do some_string.decode('latin1') to get unicode that I can use with xlsxwriter, or put in the header of a web page to display European characters correctly. But normally UTF-8 is recommended as the encoding to use today. latin1 works correctly more often when I am using data from the wild. It's frustrating that I have to play a guessing game to figure out how to use incoming text. I'm just wondering if there are any thoughts. What if we just globally decided to use utf-8? Could that ever happen? From jon+usenet at unequivocal.eu Wed Aug 17 11:48:53 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Wed, 17 Aug 2022 15:48:53 -0000 (UTC) Subject: UTF-8 and latin1 References: Message-ID: On 2022-08-17, Tobiah wrote: > I get data from various sources; client emails, spreadsheets, and > data from web applications. I find that I can do some_string.decode('latin1') > to get unicode that I can use with xlsxwriter, > or put in the header of a web page to display > European characters correctly. But normally UTF-8 is recommended as > the encoding to use today. latin1 works correctly more often when I > am using data from the wild. It's frustrating that I have to play > a guessing game to figure out how to use incoming text. I'm just wondering > if there are any thoughts. What if we just globally decided to use utf-8? > Could that ever happen? That has already been decided, as much as it ever can be. UTF-8 is essentially always the correct encoding to use on output, and almost always the correct encoding to assume on input absent any explicit indication of another encoding. (e.g. the HTML "standard" says that all HTML files must be UTF-8.) If you are finding that your specific sources are often encoded with latin-1 instead then you could always try something like: try: text = data.decode('utf-8') except UnicodeDecodeError: text = data.decode('latin-1') (I think latin-1 text will almost always fail to be decoded as utf-8, so this would work fairly reliably assuming those are the only two encodings you see.) Or you could use something fancy like https://pypi.org/project/chardet/ From ikorot01 at gmail.com Wed Aug 17 13:35:28 2022 From: ikorot01 at gmail.com (Igor Korot) Date: Wed, 17 Aug 2022 12:35:28 -0500 Subject: not able to use python In-Reply-To: <8728ABB4-CA54-4208-B48B-BE8E30F704C7@hxcore.ol> References: <8728ABB4-CA54-4208-B48B-BE8E30F704C7@hxcore.ol> Message-ID: Hi, On Wed, Aug 17, 2022 at 12:20 PM i am unable to use python wrote: > > AND I"M UNABLE TO SEE ANYTHING IN YOUR MESSAGE... THANK YOU. > > > > Sent from [1]Mail for Windows > > > > References > > Visible links > 1. https://go.microsoft.com/fwlink/?LinkId=550986 > -- > https://mail.python.org/mailman/listinfo/python-list From dieter at handshake.de Wed Aug 17 13:43:15 2022 From: dieter at handshake.de (Dieter Maurer) Date: Wed, 17 Aug 2022 19:43:15 +0200 Subject: setup.py + cython == chicken and the egg problem In-Reply-To: References: Message-ID: <25341.10419.847158.745024@ixdm.fritz.box> Dan Stromberg wrote at 2022-8-16 14:03 -0700: > ... >I'm attempting to package up a python package that uses Cython. > ... > Installing build dependencies ... error > error: subprocess-exited-with-error > > ?? pip subprocess to install build dependencies did not run successfully. > ?? exit code: 1 > ????> [3 lines of output] > Looking in indexes: https://test.pypi.org/simple/ > ERROR: Could not find a version that satisfies the requirement >setuptools (from versions: none) > ERROR: No matching distribution found for setuptools The message tells you that there is a `setuptools` problem. I would start to locate all `setuptools` requirement locations. I am using `cython` for the package `dm.xmlsec.binding`. I have not observed nor heard of a problem similar to yours (but I have never tried `test.pypi.org`). From david at boomer.org Wed Aug 17 14:09:14 2022 From: david at boomer.org (David at Booomer) Date: Wed, 17 Aug 2022 12:09:14 -0600 Subject: Problem using cx_Freeze In-Reply-To: References: Message-ID: Hi Dennis Thank you for your reply. I?m am trying to get LaTex-to-Speech (https://github.com/SGanesh19/LaTeX-to-Speech) to run as an accessibility aid, converting equations into speech. I haven?t used cx_Freeze before so stumbling somewhat. The error returned is File "/Users/duser/Documents/Win_ShareFolder/LaTeX-to-Speech-master/setup.py", line 9, in Executable( TypeError: __init__() takes from 2 to 12 positional arguments but 14 were given The setup.py file is currently import cx_Freeze # from cx_Freeze import * from cx_Freeze import setup, Executable setup( name="Latex2Speech", options = {'build_exe':{'packages':['gtts','pyglet','PyQt4']}}, executables=[ Executable( "prjui.py","Maiui.py","about.py","dict.py","geometry.py","getEquation.py", "gtrail.py","main.py","matchingstring.py","producelatex.py","readfile.py", "separete.py","speak.py", ) ] ) I am/was worried about the trailing ?,' after ',"speak.py?,? <- but deleting it or moving it after the ] didn?t help. Adding base = None also didn?t help. Searching for ?__init__(' in the 13 *.py files returned five lines in two files (algorithm.py and prjui.py). As mentioned searching for this error only produced mention of adding self which is in these lines already. Previously I had search for __init__() which returned no lines due to the closing ). I had visited the page you provided (https://cx-freeze.readthedocs.io/en/latest/setup_script.html#cx-freeze-executable) but didn?t noticed the 11 plus self as 12 arguments. Thanks again for any suggestions. David > From: Dennis Lee Bieber > Subject: Re: Problem using cx_Freeze > Date: August 15, 2022 at 8:18:54 PM MDT > To: python-list at python.org > > > On Mon, 15 Aug 2022 18:00:48 -0600, David at Booomer > declaimed the following: > > >> However I now get an error >> >> init() takes from 2 to 12 positional arguments but 14 were given >> >> I found a couple instances of init in two .py files that were part of the whole. >> >> One .py file >> def __init__(self): >> > > Please cut&paste the TEXT of the console where the errors are displayed > -- don't paraphrase! > > init() is NOT the same as __init__() > > WHAT "One .py file"? This is a meaningless bit of information. > > The most likely __init__() involved is the one where > cx_Freeze.Executable is instantiated. > https://cx-freeze.readthedocs.io/en/latest/setup_script.html#cx-freeze-executable > shows 11 parameters (and "self" would make the 12th). > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From dciprus at cisco.com Wed Aug 17 14:27:12 2022 From: dciprus at cisco.com (Dan Ciprus (dciprus)) Date: Wed, 17 Aug 2022 18:27:12 +0000 Subject: not able to use python In-Reply-To: References: <8728ABB4-CA54-4208-B48B-BE8E30F704C7@hxcore.ol> Message-ID: <20220817182709.wnjsjzujxenbvuac@carbon> Those people keep me on my toes every time I look at such a message :-/. On Wed, Aug 17, 2022 at 12:35:28PM -0500, Igor Korot wrote: >Hi, > >On Wed, Aug 17, 2022 at 12:20 PM i am unable to use python > wrote: >> >> > >AND I"M UNABLE TO SEE ANYTHING IN YOUR MESSAGE... > >THANK YOU. > >> >> >> >> Sent from [1]Mail for Windows >> >> >> >> References >> >> Visible links >> 1. https://go.microsoft.com/fwlink/?LinkId=550986 >> -- >> https://mail.python.org/mailman/listinfo/python-list >-- >https://mail.python.org/mailman/listinfo/python-list -- Daniel Ciprus .:|:.:|:. CONSULTING ENGINEER.CUSTOMER DELIVERY Cisco Systems Inc. dciprus at cisco.com tel: +1-703-484-0205 mob: +1-540-223-7098 [ curl -L http://git.io/unix ] -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: From toby at tobiah.org Wed Aug 17 13:55:11 2022 From: toby at tobiah.org (Tobiah) Date: Wed, 17 Aug 2022 10:55:11 -0700 Subject: UTF-8 and latin1 References: Message-ID: On 8/17/22 08:33, Stefan Ram wrote: > Tobiah writes: >> I get data from various sources; client emails, spreadsheets, and >> data from web applications. I find that I can do some_string.decode('latin1') > > Strings have no "decode" method. ("bytes" objects do.) I'm using 2.7. Maybe that's why. Toby From toby at tobiah.org Wed Aug 17 14:14:42 2022 From: toby at tobiah.org (Tobiah) Date: Wed, 17 Aug 2022 11:14:42 -0700 Subject: UTF-8 and latin1 References: Message-ID: > That has already been decided, as much as it ever can be. UTF-8 is > essentially always the correct encoding to use on output, and almost > always the correct encoding to assume on input absent any explicit > indication of another encoding. (e.g. the HTML "standard" says that > all HTML files must be UTF-8.) I got an email from a client with blast text that was in French with stuff like: Montr?al, Queb?c. latin1 did the trick. Also, whenever I get a spreadsheet from a client and save as .csv, or take browser data through PHP, it always seems to work with latin1, but not UTF-8. From wlfraed at ix.netcom.com Wed Aug 17 15:36:10 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Wed, 17 Aug 2022 15:36:10 -0400 Subject: Problem using cx_Freeze References: Message-ID: <0ufqfhlo3ptdec45p4dqq1i5einmsh5n3d@4ax.com> On Wed, 17 Aug 2022 12:09:14 -0600, David at Booomer declaimed the following: > executables=[ > Executable( > "prjui.py","Maiui.py","about.py","dict.py","geometry.py","getEquation.py", > "gtrail.py","main.py","matchingstring.py","producelatex.py","readfile.py", > "separete.py","speak.py", > ) > ] >) > You are defining a list "executables" with only ONE member... (and is that really how you spelled "separate"). >Searching for ?__init__(' in the 13 *.py files returned five lines in two files (algorithm.py and prjui.py). As mentioned searching for this error only produced mention of adding self which is in these lines already. Previously I had search for __init__() which returned no lines due to the closing ). > You are still searching the wrong place... The __init__() that is complaining is the one in cx_Freeze.Executable(). >I had visited the page you provided (https://cx-freeze.readthedocs.io/en/latest/setup_script.html#cx-freeze-executable) but didn?t noticed the 11 plus self as 12 arguments. Really? Please count (reformatted from cut&paste): """ argument name description #1 script the name of the file containing the script which is to be frozen #2 init_script the name of the initialization script that will be executed before the actual script is executed; this script is used to set up the environment for the executable; if a name is given without an absolute path the names of files in the initscripts subdirectory of the cx_Freeze package is searched #3 base the name of the base executable; if a name is given without an absolute path the names of files in the bases subdirectory of the cx_Freeze package is searched #4 target_name the name of the target executable; the default value is the name of the script; the extension is optional (automatically added on Windows); support for names with version; if specified a pathname, raise an error. #5 icon name of icon which should be included in the executable itself on Windows or placed in the target directory for other platforms (ignored in Microsoft Store Python app) #6 manifest name of manifest which should be included in the executable itself (Windows only - ignored by Python app from Microsoft Store) #7 uac-admin creates a manifest for an application that will request elevation (Windows only - ignored by Python app from Microsoft Store) #8 shortcut_name the name to give a shortcut for the executable when included in an MSI package (Windows only). #9 shortcut_dir the directory in which to place the shortcut when being installed by an MSI package; see the MSI Shortcut table documentation for more information on what values can be placed here (Windows only). #10 copyright the copyright value to include in the version resource associated with executable (Windows only). #11 trademarks the trademarks value to include in the version resource associated with the executable (Windows only). """ You are passing 13 .py file names. There are only two arguments that really want file names: script, and init_script. Most of the other arguments are either optional or Windows specific (#6-11). I suspect you need to pass JUST main.py or Maiui.py (based on casing) -- which ever is really the file you'd invoke to start the program running. I'd hope the freeze system then scans (recursively) that file to find anything imported, and include those in the final product. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From barry at barrys-emacs.org Wed Aug 17 16:18:52 2022 From: barry at barrys-emacs.org (Barry) Date: Wed, 17 Aug 2022 21:18:52 +0100 Subject: UTF-8 and latin1 In-Reply-To: References: Message-ID: > On 17 Aug 2022, at 18:30, Jon Ribbens via Python-list wrote: > > ?On 2022-08-17, Tobiah wrote: >> I get data from various sources; client emails, spreadsheets, and >> data from web applications. I find that I can do some_string.decode('latin1') >> to get unicode that I can use with xlsxwriter, >> or put in the header of a web page to display >> European characters correctly. But normally UTF-8 is recommended as >> the encoding to use today. latin1 works correctly more often when I >> am using data from the wild. It's frustrating that I have to play >> a guessing game to figure out how to use incoming text. I'm just wondering >> if there are any thoughts. What if we just globally decided to use utf-8? >> Could that ever happen? > > That has already been decided, as much as it ever can be. UTF-8 is > essentially always the correct encoding to use on output, and almost > always the correct encoding to assume on input absent any explicit > indication of another encoding. (e.g. the HTML "standard" says that > all HTML files must be UTF-8.) > > If you are finding that your specific sources are often encoded with > latin-1 instead then you could always try something like: > > try: > text = data.decode('utf-8') > except UnicodeDecodeError: > text = data.decode('latin-1') > > (I think latin-1 text will almost always fail to be decoded as utf-8, > so this would work fairly reliably assuming those are the only two > encodings you see.) Only if a reserved byte is used in the string. It will often work in either. For web pages it cannot be assumed that markup saying it?s utf-8 is correct. Many pages are I fact cp1252. Usually you find out because of a smart quote that is 0xa0 is cp1252 and illegal in utf-8. Barry > > Or you could use something fancy like https://pypi.org/project/chardet/ > > -- > https://mail.python.org/mailman/listinfo/python-list > From drsalists at gmail.com Wed Aug 17 16:58:57 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Wed, 17 Aug 2022 13:58:57 -0700 Subject: setup.py + cython == chicken and the egg problem In-Reply-To: References: Message-ID: On Wed, Aug 17, 2022 at 10:20 AM Christian Gollwitzer wrote: > Am 16.08.22 um 23:03 schrieb Dan Stromberg: > > I'm attempting to package up a python package that uses Cython. > > > > Rather than build binaries for everything under the sun, I've been > focusing > > on including the .pyx file and running cython on it at install time. > This > > requires a C compiler, but I'm OK with that. > > > > However, when I try to install the package from test.pypi.org, I get: > > $ python3 -m pip install -i https://test.pypi.org/simple/ pyx-treap > > below cmd output started 2022 Tue Aug 16 01:55:16 PM PDT > > Looking in indexes: https://test.pypi.org/simple/ > > Collecting pyx-treap > > Downloading > > > https://test-files.pythonhosted.org/packages/3a/41/af5360934adccfc086a39e1f720323895144b53454ff6dacc0f06267db55/pyx_treap-2.0.15.tar.gz > > (125 kB) > > > > > ???????????????????????????????????????????????????????????????????????????????? > > 125.9/125.9 kB 1.9 MB/s eta 0:00:00 > > Installing build dependencies ... error > > error: subprocess-exited-with-error > > > > ?? pip subprocess to install build dependencies did not run > successfully. > > ?? exit code: 1 > > ????> [3 lines of output] > > Looking in indexes: https://test.pypi.org/simple/ > > ERROR: Could not find a version that satisfies the requirement > > setuptools (from versions: none) > > ERROR: No matching distribution found for setuptools > > [end of output] > > > > note: This error originates from a subprocess, and is likely not a > > problem with pip. > > error: subprocess-exited-with-error > > > I looked at your code and I think you are trying too hard. As far as I > understand, you need Cython to be installed before the build process > begins. Your entry in pyproject.toml should take care of that. > But you also have these lines in your setup.py > > subprocess.check_call('%s -m pip install cython' % (sys.executable, ), > shell=True) > subprocess.check_call('%s -m cython pyx_treap.pyx' % (sys.executable, ), > shell=True) > > The first one calls out to pip while pip is already running, I'm not > sure that this will work, but judging from the error message it is > looking for the requirements also from test.pypi. Maybe this is the > reason that it fails (the error message says that it can't find > setuptools). So jut delete this line and it might already work > > The second line, which compiles the Cython code, also runs *at every > invocation of setup.py*, even if you'd do just > > python3 setup.py --help > > It may still work, but the correct way to do it is to create a build > extension for setuptools. In my project you can see this here: > > https://github.com/j-from-b/CDEF/blob/main/setup.py#L88 > > OTOH, I would be surprised if Cython did not have this already, indeed > you imported cythonize from Cython.Build. So maybe just deleting these > two lines and it might work? > I commented out those too lines, but I'm still getting errors. They seem to stem from: $ "/home/dstromberg/venv/pyx-treap-testing/bin/python3", ["/home/dstromberg/venv/pyx-treap-testing/bin/python3", "/home/dstromberg/venv/pyx-treap-testing/lib/python3.9/site-packages/pip/__pip-runner__.py", "install", "--ignore-installed", "--no-user", "--prefix", "/tmp/pip-build-env-9_ivrsb6/overlay", "--no-warn-script-location", "--no-binary", ":none:", "--only-binary", ":none:", "-i", " https://test.pypi.org/simple/", "--", "setuptools >= 44.1.1", "wheel", "Cython"] "/home/dstromberg/venv/pyx-treap-testing/bin/python3" "/home/dstromberg/venv/pyx-treap-testing/lib/python3.9/site-packages/pip/__pip-runner__.py" "install" "--ignore-installed" "--no-user" "--prefix" "/tmp/pip-build-env-9_ivrsb6/overlay" "--no-warn-script-location" "--no-binary" ":none:" "--only-binary" ":none:" "-i" " https://test.pypi.org/simple/" "--" "setuptools >= 44.1.1" "wheel" "Cython" Looking in indexes: https://test.pypi.org/simple/ ERROR: Could not find a version that satisfies the requirement setuptools>=44.1.1 (from versions: none) ERROR: No matching distribution found for setuptools>=44.1.1 I copied that out of an strace. That's likely related to my pyproject.toml: $ cat pyproject.toml below cmd output started 2022 Wed Aug 17 01:57:09 PM PDT [build-system] requires = ["setuptools >= 44.1.1", "wheel", "Cython"] build-backend = "setuptools.build_meta" Any other suggestions folks? From PythonList at DancesWithMice.info Wed Aug 17 16:53:17 2022 From: PythonList at DancesWithMice.info (dn) Date: Thu, 18 Aug 2022 08:53:17 +1200 Subject: UTF-8 and latin1 In-Reply-To: References: Message-ID: <25fc2688-ab5c-ab7a-8466-f672480ae87c@DancesWithMice.info> On 18/08/2022 03.33, Stefan Ram wrote: > Tobiah writes: >> I get data from various sources; client emails, spreadsheets, and >> data from web applications. I find that I can do some_string.decode('latin1') > > Strings have no "decode" method. ("bytes" objects do.) > >> to get unicode that I can use with xlsxwriter, >> or put in the header of a web page to display >> European characters correctly. > > |You should always use the UTF-8 character encoding. (Remember > |that this means you also need to save your content as UTF-8.) > World Wide Web Consortium (W3C) (2014) > >> am using data from the wild. It's frustrating that I have to play >> a guessing game to figure out how to use incoming text. I'm just wondering > > You can let Python guess the encoding of a file. > > def encoding_of( name ): > path = pathlib.Path( name ) > for encoding in( "utf_8", "cp1252", "latin_1" ): > try: > with path.open( encoding=encoding, errors="strict" )as file: > text = file.read() > return encoding > except UnicodeDecodeError: > pass > return None > >> if there are any thoughts. What if we just globally decided to use utf-8? >> Could that ever happen? > > That decisions has been made long ago. Unfortunately, much of our data was collected long before then - and as we've discovered, the OP is still living in Python 2 times. What about if the path "name" (above) is not in utf-8? eg the OP's Montr?al in Latin1, as Montr?al.txt or Montr?al.rpt -- Regards, =dn From hjp-python at hjp.at Wed Aug 17 17:17:27 2022 From: hjp-python at hjp.at (Peter J. Holzer) Date: Wed, 17 Aug 2022 23:17:27 +0200 Subject: Problem using cx_Freeze In-Reply-To: References: Message-ID: <20220817211727.3jad6yukog4vrz4g@hjp.at> On 2022-08-17 12:09:14 -0600, David at Booomer wrote: > Executable( > "prjui.py","Maiui.py","about.py","dict.py","geometry.py","getEquation.py", > "gtrail.py","main.py","matchingstring.py","producelatex.py","readfile.py", > "separete.py","speak.py", > ) [...] > I am/was worried about the trailing ?,' after ',"speak.py?,? <- but > deleting it or moving it after the ] didn?t help. This has nothing to do with your problem but: Python allows a trailing comma in any comma-separated list of values. It will just be ignored. This is really common in modern programming languages (read: programming languages younger than 30 years or so), because it makes it much more convenient to extend/shorten/reorder a list. Otherwise you alway have to remember add or remove a comma in the right place. (Some people (especially SQL programmers for some reason) resorted to put the comma at the start of each line to get around this, which is really ugly.) hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From drsalists at gmail.com Wed Aug 17 18:05:35 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Wed, 17 Aug 2022 15:05:35 -0700 Subject: setup.py + cython == chicken and the egg problem In-Reply-To: References: Message-ID: On Wed, Aug 17, 2022 at 1:58 PM Dan Stromberg wrote: > On Wed, Aug 17, 2022 at 10:20 AM Christian Gollwitzer > wrote: > >> Am 16.08.22 um 23:03 schrieb Dan Stromberg: >> > I'm attempting to package up a python package that uses Cython. >> > >> > Rather than build binaries for everything under the sun, I've been >> focusing >> > on including the .pyx file and running cython on it at install time. >> This >> > requires a C compiler, but I'm OK with that. >> > >> > However, when I try to install the package from test.pypi.org, I get: >> > $ python3 -m pip install -i https://test.pypi.org/simple/ pyx-treap >> > below cmd output started 2022 Tue Aug 16 01:55:16 PM PDT >> > Looking in indexes: https://test.pypi.org/simple/ >> > Collecting pyx-treap >> > Downloading >> > >> https://test-files.pythonhosted.org/packages/3a/41/af5360934adccfc086a39e1f720323895144b53454ff6dacc0f06267db55/pyx_treap-2.0.15.tar.gz >> > (125 kB) >> > >> > >> ???????????????????????????????????????????????????????????????????????????????? >> > 125.9/125.9 kB 1.9 MB/s eta 0:00:00 >> > Installing build dependencies ... error >> > error: subprocess-exited-with-error >> > >> > ?? pip subprocess to install build dependencies did not run >> successfully. >> > ?? exit code: 1 >> > ????> [3 lines of output] >> > Looking in indexes: https://test.pypi.org/simple/ >> > ERROR: Could not find a version that satisfies the requirement >> > setuptools (from versions: none) >> > ERROR: No matching distribution found for setuptools >> > [end of output] >> > >> > note: This error originates from a subprocess, and is likely not a >> > problem with pip. >> > error: subprocess-exited-with-error >> >> >> I looked at your code and I think you are trying too hard. As far as I >> understand, you need Cython to be installed before the build process >> begins. Your entry in pyproject.toml should take care of that. >> But you also have these lines in your setup.py >> >> subprocess.check_call('%s -m pip install cython' % (sys.executable, ), >> shell=True) >> subprocess.check_call('%s -m cython pyx_treap.pyx' % (sys.executable, ), >> shell=True) >> >> The first one calls out to pip while pip is already running, I'm not >> sure that this will work, but judging from the error message it is >> looking for the requirements also from test.pypi. Maybe this is the >> reason that it fails (the error message says that it can't find >> setuptools). So jut delete this line and it might already work >> >> The second line, which compiles the Cython code, also runs *at every >> invocation of setup.py*, even if you'd do just >> >> python3 setup.py --help >> >> It may still work, but the correct way to do it is to create a build >> extension for setuptools. In my project you can see this here: >> >> https://github.com/j-from-b/CDEF/blob/main/setup.py#L88 >> >> OTOH, I would be surprised if Cython did not have this already, indeed >> you imported cythonize from Cython.Build. So maybe just deleting these >> two lines and it might work? >> > > I commented out those too lines, but I'm still getting errors. They seem > to stem from: > $ "/home/dstromberg/venv/pyx-treap-testing/bin/python3", > ["/home/dstromberg/venv/pyx-treap-testing/bin/python3", > "/home/dstromberg/venv/pyx-treap-testing/lib/python3.9/site-packages/pip/__pip-runner__.py", > "install", "--ignore-installed", "--no-user", "--prefix", > "/tmp/pip-build-env-9_ivrsb6/overlay", "--no-warn-script-location", > "--no-binary", ":none:", "--only-binary", ":none:", "-i", " > https://test.pypi.org/simple/", "--", "setuptools >= 44.1.1", "wheel", > "Cython"] > "/home/dstromberg/venv/pyx-treap-testing/bin/python3" > "/home/dstromberg/venv/pyx-treap-testing/lib/python3.9/site-packages/pip/__pip-runner__.py" > "install" "--ignore-installed" "--no-user" "--prefix" > "/tmp/pip-build-env-9_ivrsb6/overlay" "--no-warn-script-location" > "--no-binary" ":none:" "--only-binary" ":none:" "-i" " > https://test.pypi.org/simple/" "--" "setuptools >= 44.1.1" "wheel" > "Cython" > Looking in indexes: https://test.pypi.org/simple/ > ERROR: Could not find a version that satisfies the requirement > setuptools>=44.1.1 (from versions: none) > ERROR: No matching distribution found for setuptools>=44.1.1 > > I copied that out of an strace. > > That's likely related to my pyproject.toml: > $ cat pyproject.toml > below cmd output started 2022 Wed Aug 17 01:57:09 PM PDT > [build-system] > requires = ["setuptools >= 44.1.1", "wheel", "Cython"] > build-backend = "setuptools.build_meta" > > Any other suggestions folks? > I don't know why, but if I delete the --ignore-installed option, I don't get the error: $ "/home/dstromberg/venv/pyx-treap-testing/bin/python3" "/home/dstromberg/venv/pyx-treap-testing/lib/python3.9/site-packages/pip/__pip-runner__.py" "install" "--ignore-installed" "--prefix" "/tmp/pip-build-env-9_ivrsb6/overlay" "-i" "https://test.pypi.org/simple/" "--" "setuptools>=44.1.1" below cmd output started 2022 Wed Aug 17 02:56:24 PM PDT Looking in indexes: https://test.pypi.org/simple/ ERROR: Could not find a version that satisfies the requirement setuptools>=44.1.1 (from versions: none) ERROR: No matching distribution found for setuptools>=44.1.1 (setuptools-investigation) above cmd output done 2022 Wed Aug 17 02:56:24 PM PDT dstromberg at tp-mini-c:~ x86_64-pc-linux-gnu 2995 $ "/home/dstromberg/venv/pyx-treap-testing/bin/python3" "/home/dstromberg/venv/pyx-treap-testing/lib/python3.9/site-packages/pip/__pip-runner__.py" "install" "--prefix" "/tmp/pip-build-env-9_ivrsb6/overlay" "-i" " https://test.pypi.org/simple/" "--" "setuptools>=44.1.1" below cmd output started 2022 Wed Aug 17 02:56:35 PM PDT Looking in indexes: https://test.pypi.org/simple/ Requirement already satisfied: setuptools>=44.1.1 in ./venv/pyx-treap-testing/lib/python3.9/site-packages (63.4.1) If I search for foo on pypi and testpypi, shouldn't I get foo before foo-bar and bar-foo? Because if I search for setuptools on pypi, I get setuptools as my first hit, but on testpypi, I don't see setuptools anywhere in the first page. That's perhaps significant if the search ordering is working as described above. ? From shereawsh at gmail.com Wed Aug 17 16:54:46 2022 From: shereawsh at gmail.com (Sherea Washington) Date: Wed, 17 Aug 2022 16:54:46 -0400 Subject: Fwd: install In-Reply-To: References: Message-ID: ---------- Forwarded message --------- From: Sherea Washington Date: Wed, Aug 17, 2022 at 4:41 PM Subject: install To: Hi I'm trying to install this. I have used all of these options below, but I can't anywhere. it keeps looping back to this when I click on the download. Please help. cell 843-364-2212 [image: image.png] From PythonList at DancesWithMice.info Wed Aug 17 18:29:26 2022 From: PythonList at DancesWithMice.info (dn) Date: Thu, 18 Aug 2022 10:29:26 +1200 Subject: Fwd: install In-Reply-To: References: Message-ID: <6f0ba4fa-5c5f-9de4-f601-2a0ed3bec5d9@DancesWithMice.info> On 18/08/2022 08.54, Sherea Washington wrote: > ---------- Forwarded message --------- > From: Sherea Washington > Date: Wed, Aug 17, 2022 at 4:41 PM > Subject: install > To: > > > Hi > > I'm trying to install this. I have used all of these options below, but I > can't anywhere. it keeps looping back to this when I click on the download. > Please help. cell 843-364-2212 > > [image: image.png] Welcome to the list. Sadly, no graphics are allowed. The cell number does not appear to include an international code. Please review the documentation: 4. Using Python on Windows https://docs.python.org/3/using/windows.html and advise if that does not solve the problem. -- Regards, =dn From drsalists at gmail.com Thu Aug 18 00:05:09 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Wed, 17 Aug 2022 21:05:09 -0700 Subject: setup.py + cython == chicken and the egg problem In-Reply-To: References: Message-ID: On Wed, Aug 17, 2022 at 3:05 PM Dan Stromberg wrote: > I commented out those too lines, but I'm still getting errors. They seem >> to stem from: >> $ "/home/dstromberg/venv/pyx-treap-testing/bin/python3", >> ["/home/dstromberg/venv/pyx-treap-testing/bin/python3", >> "/home/dstromberg/venv/pyx-treap-testing/lib/python3.9/site-packages/pip/__pip-runner__.py", >> "install", "--ignore-installed", "--no-user", "--prefix", >> "/tmp/pip-build-env-9_ivrsb6/overlay", "--no-warn-script-location", >> "--no-binary", ":none:", "--only-binary", ":none:", "-i", " >> https://test.pypi.org/simple/", "--", "setuptools >= 44.1.1", "wheel", >> "Cython"] >> "/home/dstromberg/venv/pyx-treap-testing/bin/python3" >> "/home/dstromberg/venv/pyx-treap-testing/lib/python3.9/site-packages/pip/__pip-runner__.py" >> "install" "--ignore-installed" "--no-user" "--prefix" >> "/tmp/pip-build-env-9_ivrsb6/overlay" "--no-warn-script-location" >> "--no-binary" ":none:" "--only-binary" ":none:" "-i" " >> https://test.pypi.org/simple/" "--" "setuptools >= 44.1.1" "wheel" >> "Cython" >> Looking in indexes: https://test.pypi.org/simple/ >> ERROR: Could not find a version that satisfies the requirement >> setuptools>=44.1.1 (from versions: none) >> ERROR: No matching distribution found for setuptools>=44.1.1 >> >> I copied that out of an strace. >> >> That's likely related to my pyproject.toml: >> $ cat pyproject.toml >> below cmd output started 2022 Wed Aug 17 01:57:09 PM PDT >> [build-system] >> requires = ["setuptools >= 44.1.1", "wheel", "Cython"] >> build-backend = "setuptools.build_meta" >> >> Any other suggestions folks? >> > > I don't know why, but if I delete the --ignore-installed option, I don't > get the error: > $ "/home/dstromberg/venv/pyx-treap-testing/bin/python3" > "/home/dstromberg/venv/pyx-treap-testing/lib/python3.9/site-packages/pip/__pip-runner__.py" > "install" "--ignore-installed" "--prefix" > "/tmp/pip-build-env-9_ivrsb6/overlay" "-i" "https://test.pypi.org/simple/" > "--" "setuptools>=44.1.1" > below cmd output started 2022 Wed Aug 17 02:56:24 PM PDT > Looking in indexes: https://test.pypi.org/simple/ > ERROR: Could not find a version that satisfies the requirement > setuptools>=44.1.1 (from versions: none) > ERROR: No matching distribution found for setuptools>=44.1.1 > (setuptools-investigation) above cmd output done 2022 Wed Aug 17 > 02:56:24 PM PDT > dstromberg at tp-mini-c:~ x86_64-pc-linux-gnu 2995 > > $ "/home/dstromberg/venv/pyx-treap-testing/bin/python3" > "/home/dstromberg/venv/pyx-treap-testing/lib/python3.9/site-packages/pip/__pip-runner__.py" > "install" "--prefix" "/tmp/pip-build-env-9_ivrsb6/overlay" "-i" " > https://test.pypi.org/simple/" "--" "setuptools>=44.1.1" > below cmd output started 2022 Wed Aug 17 02:56:35 PM PDT > Looking in indexes: https://test.pypi.org/simple/ > Requirement already satisfied: setuptools>=44.1.1 in > ./venv/pyx-treap-testing/lib/python3.9/site-packages (63.4.1) > > If I search for foo on pypi and testpypi, shouldn't I get foo before > foo-bar and bar-foo? > > Because if I search for setuptools on pypi, I get setuptools as my first > hit, but on testpypi, I don't see setuptools anywhere in the first page. > That's perhaps significant if the search ordering is working as described > above. > > ? > IOW, maybe testpypi doesn't have setuptools. Indeed, it doesn't appear to. Publishing and installing from the real pypi seems to be working. Thanks folks. From jon+usenet at unequivocal.eu Wed Aug 17 20:11:28 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Thu, 18 Aug 2022 00:11:28 -0000 (UTC) Subject: UTF-8 and latin1 References: Message-ID: On 2022-08-17, Tobiah wrote: >> That has already been decided, as much as it ever can be. UTF-8 is >> essentially always the correct encoding to use on output, and almost >> always the correct encoding to assume on input absent any explicit >> indication of another encoding. (e.g. the HTML "standard" says that >> all HTML files must be UTF-8.) > I got an email from a client with blast text that > was in French with stuff like: Montr?al, Queb?c. > latin1 did the trick. There's no accounting for the Qu?b?cois. They think they speak French. > Also, whenever I get a spreadsheet from a client and save as .csv, > or take browser data through PHP, it always seems to work with latin1, > but not UTF-8. That depends on how you "saved as .csv" and what you did with PHP. Generally speaking browser submisisons were/are supposed to be sent using the same encoding as the page, so if you're sending the page as "latin1" then you'll see that a fair amount I should think. If you send it as "utf-8" then you'll get 100% utf-8 back. From jon+usenet at unequivocal.eu Wed Aug 17 20:20:53 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Thu, 18 Aug 2022 00:20:53 -0000 (UTC) Subject: UTF-8 and latin1 References: Message-ID: On 2022-08-17, Barry wrote: >> On 17 Aug 2022, at 18:30, Jon Ribbens via Python-list wrote: >> On 2022-08-17, Tobiah wrote: >>> I get data from various sources; client emails, spreadsheets, and >>> data from web applications. I find that I can do some_string.decode('latin1') >>> to get unicode that I can use with xlsxwriter, >>> or put in the header of a web page to display >>> European characters correctly. But normally UTF-8 is recommended as >>> the encoding to use today. latin1 works correctly more often when I >>> am using data from the wild. It's frustrating that I have to play >>> a guessing game to figure out how to use incoming text. I'm just wondering >>> if there are any thoughts. What if we just globally decided to use utf-8? >>> Could that ever happen? >> >> That has already been decided, as much as it ever can be. UTF-8 is >> essentially always the correct encoding to use on output, and almost >> always the correct encoding to assume on input absent any explicit >> indication of another encoding. (e.g. the HTML "standard" says that >> all HTML files must be UTF-8.) >> >> If you are finding that your specific sources are often encoded with >> latin-1 instead then you could always try something like: >> >> try: >> text = data.decode('utf-8') >> except UnicodeDecodeError: >> text = data.decode('latin-1') >> >> (I think latin-1 text will almost always fail to be decoded as utf-8, >> so this would work fairly reliably assuming those are the only two >> encodings you see.) > > Only if a reserved byte is used in the string. > It will often work in either. Because it's actually ASCII and hence there's no difference between interpreting it as utf-8 or iso-8859-1? In which case, who cares? > For web pages it cannot be assumed that markup saying it?s utf-8 is > correct. Many pages are I fact cp1252. Usually you find out because > of a smart quote that is 0xa0 is cp1252 and illegal in utf-8. Hence what I said above. But if a source explicitly states an encoding and it's false then these days I see little need for sympathy. From toby at tobiah.org Thu Aug 18 10:45:09 2022 From: toby at tobiah.org (Tobiah) Date: Thu, 18 Aug 2022 07:45:09 -0700 Subject: UTF-8 and latin1 References: Message-ID: > Generally speaking browser submisisons were/are supposed to be sent > using the same encoding as the page, so if you're sending the page > as "latin1" then you'll see that a fair amount I should think. If you > send it as "utf-8" then you'll get 100% utf-8 back. The only trick I know is to use . Would that 'send' the post as utf-8? I always expected it had more to do with the way the user entered the characters. How do they by the way, enter things like Montr?al, Queb?c. When they enter that into a text box on a web page can we say it's in a particular encoding at that time? At submit time? From david at boomer.org Thu Aug 18 14:17:25 2022 From: david at boomer.org (David at Booomer) Date: Thu, 18 Aug 2022 12:17:25 -0600 Subject: Problem using cx_Freeze > auto-py-to-exe In-Reply-To: References: Message-ID: <2B29A26F-4863-4D69-8F66-B06EE837F3B1@boomer.org> From: Dennis Lee Bieber > > On Wed, 17 Aug 2022 12:09:14 -0600, David at Booomer > declaimed the following: > >> executables=[ >> Executable( >> "prjui.py","Maiui.py","about.py","dict.py","geometry.py","getEquation.py", >> "gtrail.py","main.py","matchingstring.py","producelatex.py","readfile.py", >> "separete.py","speak.py", >> ) >> ] >> ) >> > You are defining a list "executables" with only ONE member... (and is > that really how you spelled "separate"). Not my spelling, although I do have to be careful when typing that word. From before: "I?m trying to get LaTex-to-Speech (https://github.com/SGanesh19/LaTeX-to-Speech) to run as an accessibility aid, converting equations into speech. I haven?t used cx_Freeze before so stumbling somewhat." > >> Searching for ?__init__(' in the 13 *.py files returned five lines in two files (algorithm.py and prjui.py). As mentioned searching for this error only produced mention of adding self which is in these lines already. Previously I had search for __init__() which returned no lines due to the closing ). >> > You are still searching the wrong place... The __init__() that is > complaining is the one in cx_Freeze.Executable(). > >> I had visited the page you provided (https://cx-freeze.readthedocs.io/en/latest/setup_script.html#cx-freeze-executable) but didn?t noticed the 11 plus self as 12 arguments. > > Really? Please count (reformatted from cut&paste): I did count but hadn?t noticed this argument list before you mentioned it. However, I still don?t see any of these argument names in the Executable list or anywhere else. > """ > argument name description > > #1 > script the name of the file containing the script > which is to be frozen > > ... > > #11 > trademarks the trademarks value to include in the version > resource associated with the executable (Windows only). > """ > > You are passing 13 .py file names. There are only two arguments that > really want file names: script, and init_script. Most of the other > arguments are either optional or Windows specific (#6-11). > > I suspect you need to pass JUST main.py or Maiui.py (based on casing) > -- which ever is really the file you'd invoke to start the program running. > I'd hope the freeze system then scans (recursively) that file to find > anything imported, and include those in the final product. > I tried passing just main.py or one of the others that might be a starting point but just got ?NoneType has no len() I was hoping to use someone else?s code to turn Latex equations into Speech. Maybe easier to just narrated each equation to create an audio file. Thanks for your suggestions Dennis. This was the first time I saw the possibility of creating a python executable. Then I searched for ?python executable? and found auto-py-to-exe and pyinstaller which I must/might explore later. First tries ran into PyQt4 to PyQt5 conversions. Good start at https://towardsdatascience.com/how-to-easily-convert-a-python-script-to-an-executable-file-exe-4966e253c7e9 I might wait for the original author to respond to an issue I posted on GitHub. Thanks again. David > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ > ... > From: "Peter J. Holzer" > Subject: Re: Problem using cx_Freeze > Date: August 17, 2022 at 3:17:27 PM MDT > To: python-list at python.org > > On 2022-08-17 12:09:14 -0600, David at Booomer wrote: >> Executable( >> "prjui.py","Maiui.py","about.py","dict.py","geometry.py","getEquation.py", >> "gtrail.py","main.py","matchingstring.py","producelatex.py","readfile.py", >> "separete.py","speak.py", >> ) > [...] >> I am/was worried about the trailing ?,' after ',"speak.py?,? <- but >> deleting it or moving it after the ] didn?t help. > > This has nothing to do with your problem but: > > Python allows a trailing comma in any comma-separated list of values. It > will just be ignored. > > This is really common in modern programming languages (read: programming > languages younger than 30 years or so), because it makes it much more > convenient to extend/shorten/reorder a list. Otherwise you alway have to > remember add or remove a comma in the right place. (Some people > (especially SQL programmers for some reason) resorted to put the comma > at the start of each line to get around this, which is really ugly.) > > hp The trailing , does make commenting out arguments easier but unexpected coming from ?older? languages. ;-) Thanks, Peter ? David Bourne, Ph.D., Associate Professor C/T Skaggs School of Pharmacy and Pharmaceutical Sciences, Mail Stop C238 Aurora, CO 80045-2605 Email: david.bourne at ucdenver.edu or david at boomer.org CV: http://www.boomer.org/db/CV.pdf My books and apps: https://www.pharmpk.com/MyeBooks.html From rosuav at gmail.com Thu Aug 18 14:23:59 2022 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 19 Aug 2022 04:23:59 +1000 Subject: Problem using cx_Freeze > auto-py-to-exe In-Reply-To: <2B29A26F-4863-4D69-8F66-B06EE837F3B1@boomer.org> References: <2B29A26F-4863-4D69-8F66-B06EE837F3B1@boomer.org> Message-ID: On Fri, 19 Aug 2022 at 04:19, David at Booomer wrote: > > This is really common in modern programming languages (read: programming > > languages younger than 30 years or so), because it makes it much more > > convenient to extend/shorten/reorder a list. Otherwise you alway have to > > remember add or remove a comma in the right place. (Some people > > (especially SQL programmers for some reason) resorted to put the comma > > at the start of each line to get around this, which is really ugly.) > > > > hp > > The trailing , does make commenting out arguments easier but unexpected coming from ?older? languages. ;-) > It's one of the frustrations with JSON, since that format doesn't allow the trailing comma :) ChrisA From jon+usenet at unequivocal.eu Thu Aug 18 12:53:31 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Thu, 18 Aug 2022 16:53:31 -0000 (UTC) Subject: UTF-8 and latin1 References: Message-ID: On 2022-08-18, Tobiah wrote: >> Generally speaking browser submisisons were/are supposed to be sent >> using the same encoding as the page, so if you're sending the page >> as "latin1" then you'll see that a fair amount I should think. If you >> send it as "utf-8" then you'll get 100% utf-8 back. > > The only trick I know is to use . Would > that 'send' the post as utf-8? I always expected it had more > to do with the way the user entered the characters. How do > they by the way, enter things like Montr?al, Queb?c. When they > enter that into a text box on a web page can we say it's in > a particular encoding at that time? At submit time? You configure the web server to send: Content-Type: text/html; charset=... in the HTTP header when it serves HTML files. Another way is to put: or: in the section of your HTML document. The HTML "standard" nowadays says that you are only allowed to use the "utf-8" encoding, but if you use another encoding then browsers will generally use that as both the encoding to use when reading the HTML file and the encoding to use when submitting form data. From grant.b.edwards at gmail.com Thu Aug 18 15:03:47 2022 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 18 Aug 2022 12:03:47 -0700 (PDT) Subject: Problem using cx_Freeze > auto-py-to-exe References: <2B29A26F-4863-4D69-8F66-B06EE837F3B1@boomer.org> Message-ID: <62fe8d13.370a0220.6babc.5c8f@mx.google.com> On 2022-08-18, Chris Angelico wrote: > On Fri, 19 Aug 2022 at 04:19, David at Booomer wrote: > >> The trailing , does make commenting out arguments easier but >> unexpected coming from ?older? languages. ;-) > > It's one of the frustrations with JSON, since that format doesn't > allow the trailing comma :) Yep, that's a constant, low-level pain for all the C code I deal with which generates JSON. You'd think after 10+ years of maintaining code that outputs JSON, I wouldn't trip over that any longer... -- Grant From rosuav at gmail.com Thu Aug 18 16:59:21 2022 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 19 Aug 2022 06:59:21 +1000 Subject: Problem using cx_Freeze > auto-py-to-exe In-Reply-To: <62fe8d13.370a0220.6babc.5c8f@mx.google.com> References: <2B29A26F-4863-4D69-8F66-B06EE837F3B1@boomer.org> <62fe8d13.370a0220.6babc.5c8f@mx.google.com> Message-ID: On Fri, 19 Aug 2022 at 05:05, Grant Edwards wrote: > > On 2022-08-18, Chris Angelico wrote: > > On Fri, 19 Aug 2022 at 04:19, David at Booomer wrote: > > > >> The trailing , does make commenting out arguments easier but > >> unexpected coming from ?older? languages. ;-) > > > > It's one of the frustrations with JSON, since that format doesn't > > allow the trailing comma :) > > Yep, that's a constant, low-level pain for all the C code I deal with > which generates JSON. You'd think after 10+ years of maintaining code > that outputs JSON, I wouldn't trip over that any longer... > With some JSON files, I just cheat and define a shim at the end of arrays... https://raw.githubusercontent.com/Rosuav/MustardMine/master/template.json ChrisA From toby at tobiah.org Thu Aug 18 14:33:59 2022 From: toby at tobiah.org (Tobiah) Date: Thu, 18 Aug 2022 11:33:59 -0700 Subject: UTF-8 and latin1 References: Message-ID: > You configure the web server to send: > > Content-Type: text/html; charset=... > > in the HTTP header when it serves HTML files. So how does this break down? When a person enters Montr?al, Queb?c into a form field, what are they doing on the keyboard to make that happen? As the string sits there in the text box, is it latin1, or utf-8 or something else? How does the browser know what sort of data it has in that text box? From jon+usenet at unequivocal.eu Thu Aug 18 14:56:58 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Thu, 18 Aug 2022 18:56:58 -0000 (UTC) Subject: UTF-8 and latin1 References: Message-ID: On 2022-08-18, Tobiah wrote: >> You configure the web server to send: >> >> Content-Type: text/html; charset=... >> >> in the HTTP header when it serves HTML files. > > So how does this break down? When a person enters > Montr?al, Queb?c into a form field, what are they > doing on the keyboard to make that happen? It depends on what keybaord they have. Using a standard UK or US ("qwerty") keyboard and Windows you should be able to type "?" by holding down the 'Alt' key to the right of the spacebar, and typing 'e'. If they're using a French ("azerty") keyboard then I think they can enter it by holding 'shift' and typing '2'. > As the string sits there in the text box, is it latin1, or utf-8 > or something else? That depends on which browser you're using. I think it's quite likely it will use UTF-32 (i.e. fixed-width 32 bits per character). > How does the browser know what sort of data it has in that text box? It's a text box, so it knows it's text. From rosuav at gmail.com Thu Aug 18 18:20:16 2022 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 19 Aug 2022 08:20:16 +1000 Subject: UTF-8 and latin1 In-Reply-To: References: Message-ID: On Fri, 19 Aug 2022 at 08:15, Tobiah wrote: > > > You configure the web server to send: > > > > Content-Type: text/html; charset=... > > > > in the HTTP header when it serves HTML files. > > So how does this break down? When a person enters > Montr?al, Queb?c into a form field, what are they > doing on the keyboard to make that happen? As the > string sits there in the text box, is it latin1, or utf-8 > or something else? How does the browser know what > sort of data it has in that text box? > As it sits there in the text box, it is *a text string*. When it gets sent to the server, the encoding is defined by the browser (with reference to the server's specifications) and identified in a request header. The server should then receive that and interpret it as a text string. Encodings should ONLY be relevant when data is stored in files or transmitted across a network etc, and the rest of the time, just think in Unicode. Also - migrate to Python 3, your life will become a lot easier. ChrisA From subtitle.indo at gmail.com Thu Aug 18 20:00:04 2022 From: subtitle.indo at gmail.com (subin) Date: Fri, 19 Aug 2022 01:00:04 +0100 Subject: Problem using cx_Freeze In-Reply-To: <20220817211727.3jad6yukog4vrz4g@hjp.at> References: <20220817211727.3jad6yukog4vrz4g@hjp.at> Message-ID: Hope you had a good time. On Wed, Aug 17, 2022 at 10:19 PM Peter J. Holzer wrote: > On 2022-08-17 12:09:14 -0600, David at Booomer wrote: > > Executable( > > > "prjui.py","Maiui.py","about.py","dict.py","geometry.py","getEquation.py", > > > "gtrail.py","main.py","matchingstring.py","producelatex.py","readfile.py", > > "separete.py","speak.py", > > ) > [...] > > I am/was worried about the trailing ?,' after ',"speak.py?,? <- but > > deleting it or moving it after the ] didn?t help. > > This has nothing to do with your problem but: > > Python allows a trailing comma in any comma-separated list of values. It > will just be ignored. > > This is really common in modern programming languages (read: programming > languages younger than 30 years or so), because it makes it much more > convenient to extend/shorten/reorder a list. Otherwise you alway have to > remember add or remove a comma in the right place. (Some people > (especially SQL programmers for some reason) resorted to put the comma > at the start of each line to get around this, which is really ugly.) > > hp > > -- > _ | Peter J. Holzer | Story must make more sense than reality. > |_|_) | | > | | | hjp at hjp.at | -- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!" > -- > https://mail.python.org/mailman/listinfo/python-list > From grant.b.edwards at gmail.com Thu Aug 18 20:05:43 2022 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 18 Aug 2022 17:05:43 -0700 (PDT) Subject: Problem using cx_Freeze > auto-py-to-exe References: <2B29A26F-4863-4D69-8F66-B06EE837F3B1@boomer.org> <62fe8d13.370a0220.6babc.5c8f@mx.google.com> Message-ID: <62fed3d7.920a0220.9eb9d.1b96@mx.google.com> On 2022-08-18, Chris Angelico wrote: > On Fri, 19 Aug 2022 at 05:05, Grant Edwards wrote: >> On 2022-08-18, Chris Angelico wrote: >> >> > It's one of the frustrations with JSON, since that format doesn't >> > allow the trailing comma :) >> >> Yep, that's a constant, low-level pain for all the C code I deal with >> which generates JSON. You'd think after 10+ years of maintaining code >> that outputs JSON, I wouldn't trip over that any longer... > > With some JSON files, I just cheat and define a shim at the end of arrays... > > https://raw.githubusercontent.com/Rosuav/MustardMine/master/template.json That's OK if it's strictly internal. Almost all of the JSON data I work with is part of published APIs ? many of which are defined by industry consortiums or corporate-wide "standards". -- Grant From drsalists at gmail.com Thu Aug 18 20:33:30 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Thu, 18 Aug 2022 17:33:30 -0700 Subject: setup.py + cython == chicken and the egg problem In-Reply-To: References: Message-ID: On Tue, Aug 16, 2022 at 2:03 PM Dan Stromberg wrote: > Hi folks. > > I'm attempting to package up a python package that uses Cython. > > Rather than build binaries for everything under the sun, I've been > focusing on including the .pyx file and running cython on it at install > time. This requires a C compiler, but I'm OK with that. > > BTW, the pure python version works fine, and the cython version works too > as long as you preinstall cython - but I don't want users to have to know > that :) > For the actual chicken-and-egg problem, I'd needed to include my pyproject.toml in my MANIFEST.in, like: include pyx_treap.pyx pyx_treap.c pyproject.toml From rosuav at gmail.com Thu Aug 18 20:35:17 2022 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 19 Aug 2022 10:35:17 +1000 Subject: Problem using cx_Freeze > auto-py-to-exe In-Reply-To: <62fed3d7.920a0220.9eb9d.1b96@mx.google.com> References: <2B29A26F-4863-4D69-8F66-B06EE837F3B1@boomer.org> <62fe8d13.370a0220.6babc.5c8f@mx.google.com> <62fed3d7.920a0220.9eb9d.1b96@mx.google.com> Message-ID: On Fri, 19 Aug 2022 at 10:07, Grant Edwards wrote: > > On 2022-08-18, Chris Angelico wrote: > > On Fri, 19 Aug 2022 at 05:05, Grant Edwards wrote: > >> On 2022-08-18, Chris Angelico wrote: > >> > >> > It's one of the frustrations with JSON, since that format doesn't > >> > allow the trailing comma :) > >> > >> Yep, that's a constant, low-level pain for all the C code I deal with > >> which generates JSON. You'd think after 10+ years of maintaining code > >> that outputs JSON, I wouldn't trip over that any longer... > > > > With some JSON files, I just cheat and define a shim at the end of arrays... > > > > https://raw.githubusercontent.com/Rosuav/MustardMine/master/template.json > > That's OK if it's strictly internal. Almost all of the JSON data I > work with is part of published APIs ? many of which are defined by > industry consortiums or corporate-wide "standards". > That's an export/import format that I defined, so I mandated (a) that there's an empty-string key as a signature (on import, it can be anywhere, but on export, it's that final shim), and (b) all arrays are allowed to have an empty string at the end, which is ignored on import. Saves so much trouble. That particular export format is actually designed as a git-managed config file as well, which is why the line breaks are done the way they are (anything on a single line is intended to be added/removed as a single unit), which is why I definitely don't want the "add a comma to the previous line" deltas. "Strictly internal" is a subset of "protocols/standards that you are in control of". :) ChrisA From Daniel-ZX.Li at hotmail.com Fri Aug 19 04:39:43 2022 From: Daniel-ZX.Li at hotmail.com (Daniel Lee) Date: Fri, 19 Aug 2022 08:39:43 +0000 Subject: =?gb2312?B?u9i4tDogUHJvYmxlbSB1c2luZyBjeF9GcmVlemUgPiBhdXRvLXB5LXRvLWV4?= =?gb2312?Q?e?= In-Reply-To: References: <2B29A26F-4863-4D69-8F66-B06EE837F3B1@boomer.org> <62fe8d13.370a0220.6babc.5c8f@mx.google.com> <62fed3d7.920a0220.9eb9d.1b96@mx.google.com> Message-ID: Thank you so much, I really appreciate it. ???: Chris Angelico ????: 2022?8?19? 8:39 ???: python-list at python.org ??: Re: Problem using cx_Freeze > auto-py-to-exe On Fri, 19 Aug 2022 at 10:07, Grant Edwards wrote: > > On 2022-08-18, Chris Angelico wrote: > > On Fri, 19 Aug 2022 at 05:05, Grant Edwards wrote: > >> On 2022-08-18, Chris Angelico wrote: > >> > >> > It's one of the frustrations with JSON, since that format doesn't > >> > allow the trailing comma :) > >> > >> Yep, that's a constant, low-level pain for all the C code I deal with > >> which generates JSON. You'd think after 10+ years of maintaining code > >> that outputs JSON, I wouldn't trip over that any longer... > > > > With some JSON files, I just cheat and define a shim at the end of arrays... > > > > https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fraw.githubusercontent.com%2FRosuav%2FMustardMine%2Fmaster%2Ftemplate.json&data=05%7C01%7C%7Cc74e60f1d42f4904e66c08da817b37fa%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637964663486534639%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=W5LULRCXXGHodvem7CdscC9KZDrU7ONXbCAlIuBZ8Xg%3D&reserved=0 > > That's OK if it's strictly internal. Almost all of the JSON data I > work with is part of published APIs ? many of which are defined by > industry consortiums or corporate-wide "standards". > That's an export/import format that I defined, so I mandated (a) that there's an empty-string key as a signature (on import, it can be anywhere, but on export, it's that final shim), and (b) all arrays are allowed to have an empty string at the end, which is ignored on import. Saves so much trouble. That particular export format is actually designed as a git-managed config file as well, which is why the line breaks are done the way they are (anything on a single line is intended to be added/removed as a single unit), which is why I definitely don't want the "add a comma to the previous line" deltas. "Strictly internal" is a subset of "protocols/standards that you are in control of". :) ChrisA -- https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-list&data=05%7C01%7C%7Cc74e60f1d42f4904e66c08da817b37fa%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637964663486554552%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5nlih9a9slRg%2FWdtsS4IbskQKIKUTfj%2BqefVsWa0C4Q%3D&reserved=0 From Daniel-ZX.Li at hotmail.com Fri Aug 19 04:40:04 2022 From: Daniel-ZX.Li at hotmail.com (Daniel Lee) Date: Fri, 19 Aug 2022 08:40:04 +0000 Subject: =?gb2312?B?u9i4tDogc2V0dXAucHkgKyBjeXRob24gPT0gY2hpY2tlbiBhbmQgdGhlIGVn?= =?gb2312?Q?g_problem?= In-Reply-To: References: Message-ID: Thank you! ? Windows ????? ???: Dan Stromberg ????: 2022?8?19? 8:35 ???: Python List ??: Re: setup.py + cython == chicken and the egg problem On Tue, Aug 16, 2022 at 2:03 PM Dan Stromberg wrote: > Hi folks. > > I'm attempting to package up a python package that uses Cython. > > Rather than build binaries for everything under the sun, I've been > focusing on including the .pyx file and running cython on it at install > time. This requires a C compiler, but I'm OK with that. > > BTW, the pure python version works fine, and the cython version works too > as long as you preinstall cython - but I don't want users to have to know > that :) > For the actual chicken-and-egg problem, I'd needed to include my pyproject.toml in my MANIFEST.in, like: include pyx_treap.pyx pyx_treap.c pyproject.toml -- https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-list&data=05%7C01%7C%7C128ce386df164c9d8a3708da817ab65c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637964661300313663%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=FMteu3dpspfzD4WvRWjnEbeNSr9P0aXrrv467ueM86k%3D&reserved=0 From Daniel-ZX.Li at hotmail.com Fri Aug 19 04:40:25 2022 From: Daniel-ZX.Li at hotmail.com (Daniel Lee) Date: Fri, 19 Aug 2022 08:40:25 +0000 Subject: =?gb2312?B?u9i4tDogUHJvYmxlbSB1c2luZyBjeF9GcmVlemU=?= In-Reply-To: References: <20220817211727.3jad6yukog4vrz4g@hjp.at> Message-ID: Thank you! ???: subin ????: 2022?8?19? 8:02 ???: python-list at python.org ??: Re: Problem using cx_Freeze Hope you had a good time. On Wed, Aug 17, 2022 at 10:19 PM Peter J. Holzer wrote: > On 2022-08-17 12:09:14 -0600, David at Booomer wrote: > > Executable( > > > "prjui.py","Maiui.py","about.py","dict.py","geometry.py","getEquation.py", > > > "gtrail.py","main.py","matchingstring.py","producelatex.py","readfile.py", > > "separete.py","speak.py", > > ) > [...] > > I am/was worried about the trailing ?,' after ',"speak.py?,? <- but > > deleting it or moving it after the ] didn?t help. > > This has nothing to do with your problem but: > > Python allows a trailing comma in any comma-separated list of values. It > will just be ignored. > > This is really common in modern programming languages (read: programming > languages younger than 30 years or so), because it makes it much more > convenient to extend/shorten/reorder a list. Otherwise you alway have to > remember add or remove a comma in the right place. (Some people > (especially SQL programmers for some reason) resorted to put the comma > at the start of each line to get around this, which is really ugly.) > > hp > > -- > _ | Peter J. Holzer | Story must make more sense than reality. > |_|_) | | > | | | hjp at hjp.at | -- Charles Stross, "Creative writing > __/ | https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.hjp.at%2F&data=05%7C01%7C%7Cf1c5395d5c384d4337a308da81760b87%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637964641252805670%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2F8KY%2FjYyHLyPx3VNEXGW0yBOwwoNSOgjbqt6Z46AKHQ%3D&reserved=0 | challenge!" > -- > https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-list&data=05%7C01%7C%7Cf1c5395d5c384d4337a308da81760b87%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637964641252805670%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=SQPv4cUay6nBpvjcx7m9FGSfhZXBrwyQ72IdwWCpyCE%3D&reserved=0 > -- https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-list&data=05%7C01%7C%7Cf1c5395d5c384d4337a308da81760b87%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637964641252805670%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=SQPv4cUay6nBpvjcx7m9FGSfhZXBrwyQ72IdwWCpyCE%3D&reserved=0 From Daniel-ZX.Li at hotmail.com Fri Aug 19 04:40:50 2022 From: Daniel-ZX.Li at hotmail.com (Daniel Lee) Date: Fri, 19 Aug 2022 08:40:50 +0000 Subject: =?gb2312?B?u9i4tDogVVRGLTggYW5kIGxhdGluMQ==?= In-Reply-To: References: Message-ID: Thanks! ???: Stefan Ram ????: 2022?8?19? 6:23 ???: python-list at python.org ??: Re: UTF-8 and latin1 Tobiah writes: > When a person enters >Montr?al, Queb?c into a form field, what are they >doing on the keyboard to make that happen? Depends on the OS and its configuration. Some devices might not even have a keyboard as hardware. > As the >string sits there in the text box, is it latin1, or utf-8 >or something else? This is an internal implementation detail of the browser. > How does the browser know what >sort of data it has in that text box? This is an internal implementation details of the browser. You usually do not need to know these internal information about the browser in order to use it. -- https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-list&data=05%7C01%7C%7C242e3a7de5ba4183621b08da81684702%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637964582138805523%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HSG21e6Aj5pyf7m8e290Rv7tsMMfCGZptEU32iMbo1I%3D&reserved=0 From wlfraed at ix.netcom.com Thu Aug 18 21:38:55 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Thu, 18 Aug 2022 21:38:55 -0400 Subject: UTF-8 and latin1 References: Message-ID: <0uptfhhvu9deneso0bu9r4sg0tnc9piq5p@4ax.com> On Thu, 18 Aug 2022 11:33:59 -0700, Tobiah declaimed the following: > >So how does this break down? When a person enters >Montr?al, Queb?c into a form field, what are they >doing on the keyboard to make that happen? As the >string sits there in the text box, is it latin1, or utf-8 >or something else? How does the browser know what >sort of data it has in that text box? > If this were my ancient Amiga -- most of the accented characters in ISO-Latin-1 were entered by using one of the meta/alt keys simultaneously with one of five or six designated "dead keys" (in days of typewriters, a dead key was one that did not advance the carriage to the next character space). The dead key indicated which accent mark was to be applied to the subsequent "regular" character. On Windows, many of the characters might be entered using #### (where #### are keys on the numeric pad!) (such as 1254 => ?). As for what the browser receives? Unless the browser is asking for raw key codes and translating them internally to some encoding, it is likely receiving characters in whatever encoding has been defined for the computer/OS (Windows, most likely CP1252, which is a superset of latin-1 as I recall). Whether the browser then re-encodes that to UTF-8 is something I can't answer. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From wlfraed at ix.netcom.com Thu Aug 18 21:54:36 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Thu, 18 Aug 2022 21:54:36 -0400 Subject: Problem using cx_Freeze > auto-py-to-exe References: <2B29A26F-4863-4D69-8F66-B06EE837F3B1@boomer.org> Message-ID: On Thu, 18 Aug 2022 12:17:25 -0600, David at Booomer declaimed the following: > >I did count but hadn?t noticed this argument list before you mentioned it. However, I still don?t see any of these argument names in the Executable list or anywhere else. > It's your responsibility to provide them when you called Executable(). As I said, you are (were?) providing a whole bunch of .py files, which were being mapped to these arguments. >""" >argument name description > >#1 >script the name of the file containing the script >which is to be frozen > prjui.py >#2 >init_script the name of the initialization script that will >be executed before the actual script is executed; this script is used to >set up the environment for the executable; if a name is given without an >absolute path the names of files in the initscripts subdirectory of the >cx_Freeze package is searched > Maiui.py >#3 >base the name of the base executable; if a name is >given without an absolute path the names of files in the bases subdirectory >of the cx_Freeze package is searched > about.py >#4 >target_name the name of the target executable; the default >value is the name of the script; the extension is optional (automatically >added on Windows); support for names with version; if specified a pathname, >raise an error. > dict.py >#5 >icon name of icon which should be included in the >executable itself on Windows or placed in the target directory for other >platforms (ignored in Microsoft Store Python app) > geometry.py >#6 >manifest name of manifest which should be included in >the executable itself (Windows only - ignored by Python app from Microsoft >Store) > getEquation.py >#7 >uac-admin creates a manifest for an application that will >request elevation (Windows only - ignored by Python app from Microsoft >Store) > gtrail.py >#8 >shortcut_name the name to give a shortcut for the executable >when included in an MSI package (Windows only). > main.py >#9 >shortcut_dir the directory in which to place the >shortcut when being installed by an MSI package; see the MSI Shortcut table >documentation for more information on what values can be placed here >(Windows only). matchingstring.py >#10 >copyright the copyright value to include in the version >resource associated with executable (Windows only). > producelatex.py >#11 >trademarks the trademarks value to include in the version >resource associated with the executable (Windows only). readfile.py and separete.py speak.py are not mapped to anything, hence the too-many arguments error. >""" As you can see, a lot of those don't even fit with the data type of the argument. > >I tried passing just main.py or one of the others that might be a starting point but just got ?NoneType has no len() What did the traceback say? Just reporting the last line message is meaningless. >Then I searched for ?python executable? and found auto-py-to-exe and pyinstaller which I must/might explore later. First tries ran into PyQt4 to PyQt5 conversions. Good start at https://towardsdatascience.com/how-to-easily-convert-a-python-script-to-an-executable-file-exe-4966e253c7e9 > Note that pretty much all such python->executable scheme is just making an archive of the required Python source files, and packaging the core of the Python interpreter is such a way that running this archive is simply extracting the source files and running the packaged Python interpreter with them. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From rosuav at gmail.com Fri Aug 19 14:30:17 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 20 Aug 2022 04:30:17 +1000 Subject: Mutating an HTML file with BeautifulSoup Message-ID: What's the best way to precisely reconstruct an HTML file after parsing it with BeautifulSoup? Using the Alice example from the BS4 docs: >>> html_doc = """The Dormouse's story

The Dormouse's story

Once upon a time there were three little sisters; and their names were Elsie, Lacie and Tillie; and they lived at the bottom of a well.

...

""" >>> print(soup) The Dormouse's story

The Dormouse's story

Once upon a time there were three little sisters; and their names were Elsie, Lacie and Tillie; and they lived at the bottom of a well.

...

>>> Note two distinct changes: firstly, whitespace has been removed, and secondly, attributes are reordered (I think alphabetically). There are other canonicalizations being done, too. I'm trying to make some automated changes to a huge number of HTML files, with minimal diffs so they're easy to validate. That means that spurious changes like these are very much unwanted. Is there a way to get BS4 to reconstruct the original precisely? The mutation itself would be things like finding an anchor tag and changing its href attribute. Fairly simple changes, but might alter the length of the file (eg changing "http://example.com/" into "https://example.com/"). I'd like to do them intelligently rather than falling back on element.sourceline and element.sourcepos, but worst case, that's what I'll have to do (which would be fiddly). ChrisA From barry at barrys-emacs.org Fri Aug 19 15:12:35 2022 From: barry at barrys-emacs.org (Barry) Date: Fri, 19 Aug 2022 20:12:35 +0100 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: Message-ID: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> > On 19 Aug 2022, at 19:33, Chris Angelico wrote: > > ?What's the best way to precisely reconstruct an HTML file after > parsing it with BeautifulSoup? I recall that in bs4 it parses into an object tree and loses the detail of the input. I recently ported from very old bs to bs4 and hit the same issue. So no it will not output the same as went in. If you can trust the input to be parsed as xml, meaning all the rules of closing tags have been followed. Then I think you can parse and unparse thru xml to do what you want. Barry > > Using the Alice example from the BS4 docs: > >>>> html_doc = """The Dormouse's story > >

The Dormouse's story

> >

Once upon a time there were three little sisters; and > their names were > Elsie, > Lacie and > Tillie; > and they lived at the bottom of a well.

> >

...

> """ >>>> print(soup) > The Dormouse's story > >

The Dormouse's story

>

Once upon a time there were three little sisters; and > their names were > Elsie, > Lacie and > Tillie; > and they lived at the bottom of a well.

>

...

> >>>> > > Note two distinct changes: firstly, whitespace has been removed, and > secondly, attributes are reordered (I think alphabetically). There are > other canonicalizations being done, too. > > I'm trying to make some automated changes to a huge number of HTML > files, with minimal diffs so they're easy to validate. That means that > spurious changes like these are very much unwanted. Is there a way to > get BS4 to reconstruct the original precisely? > > The mutation itself would be things like finding an anchor tag and > changing its href attribute. Fairly simple changes, but might alter > the length of the file (eg changing "http://example.com/" into > "https://example.com/"). I'd like to do them intelligently rather than > falling back on element.sourceline and element.sourcepos, but worst > case, that's what I'll have to do (which would be fiddly). > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From 2QdxY4RzWzUUiLuE at potatochowder.com Fri Aug 19 16:05:14 2022 From: 2QdxY4RzWzUUiLuE at potatochowder.com (2QdxY4RzWzUUiLuE at potatochowder.com) Date: Fri, 19 Aug 2022 15:05:14 -0500 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: On 2022-08-19 at 20:12:35 +0100, Barry wrote: > > On 19 Aug 2022, at 19:33, Chris Angelico wrote: > > > > ?What's the best way to precisely reconstruct an HTML file after > > parsing it with BeautifulSoup? > > I recall that in bs4 it parses into an object tree and loses the > detail of the input. I recently ported from very old bs to bs4 and > hit the same issue. So no it will not output the same as went in. > > If you can trust the input to be parsed as xml, meaning all the rules > of closing tags have been followed. Then I think you can parse and > unparse thru xml to do what you want. XML is in the same boat. Except for "canonical form" (which underlies cryptographically signed XML documents) the standards explicitly don't require tools to round-trip the "source code." The preferred method of comparing XML documents is at the structural level rather than with textual representations. That way, the following two elements are the same (and similar with a collection of sub-elements in a different order in another document): and Dan From rosuav at gmail.com Fri Aug 19 17:01:09 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 20 Aug 2022 07:01:09 +1000 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: On Sat, 20 Aug 2022 at 05:12, Barry wrote: > > > > > On 19 Aug 2022, at 19:33, Chris Angelico wrote: > > > > ?What's the best way to precisely reconstruct an HTML file after > > parsing it with BeautifulSoup? > > I recall that in bs4 it parses into an object tree and loses the detail of the input. > I recently ported from very old bs to bs4 and hit the same issue. > So no it will not output the same as went in. > > If you can trust the input to be parsed as xml, meaning all the rules of closing > tags have been followed. Then I think you can parse and unparse thru xml to > do what you want. > Yeah, no I can't, this is HTML 4 with a ton of inconsistencies. Oh well. Thanks for trying, anyhow. So I'm left with a few options: 1) Give up on validation, give up on verification, and just run this thing on the production site with my fingers crossed 2) Instead of doing an intelligent reconstruction, just str.replace() one URL with another within the file 3) Split the file into lines, find the Nth line (elem.sourceline) and str.replace that line only 4) Attempt to use elem.sourceline and elem.sourcepos to find the start of the tag, manually find the end, and replace one tag with the reconstructed form. I'm inclined to the first option, honestly. The others just seem like hard work, and I became a programmer so I could be lazy... ChrisA From bouncingcats at gmail.com Fri Aug 19 20:02:30 2022 From: bouncingcats at gmail.com (David) Date: Sat, 20 Aug 2022 10:02:30 +1000 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: On Sat, 20 Aug 2022 at 04:31, Chris Angelico wrote: > What's the best way to precisely reconstruct an HTML file after > parsing it with BeautifulSoup? > Note two distinct changes: firstly, whitespace has been removed, and > secondly, attributes are reordered (I think alphabetically). There are > other canonicalizations being done, too. > I'm trying to make some automated changes to a huge number of HTML > files, with minimal diffs so they're easy to validate. That means that > spurious changes like these are very much unwanted. Is there a way to > get BS4 to reconstruct the original precisely? On Sat, 20 Aug 2022 at 07:02, Chris Angelico wrote: > On Sat, 20 Aug 2022 at 05:12, Barry wrote: > > I recall that in bs4 it parses into an object tree and loses the detail > > of the input. I recently ported from very old bs to bs4 and hit the > > same issue. So no it will not output the same as went in. > So I'm left with a few options: > 1) Give up on validation, give up on verification, and just run this > thing on the production site with my fingers crossed > 2) Instead of doing an intelligent reconstruction, just str.replace() one > URL with another within the file > 3) Split the file into lines, find the Nth line (elem.sourceline) and > str.replace that line only > 4) Attempt to use elem.sourceline and elem.sourcepos to find the start of > the tag, manually find the end, and replace one tag with the > reconstructed form. > I'm inclined to the first option, honestly. The others just seem like > hard work, and I became a programmer so I could be lazy... Hi, I don't know if you will like this option, but I don't see it on the list yet so ... I'm assuming that the phrase "with minimal diffs so they're easy to validate" means being eyeballed by a human. Have you considered two passes through BS? Do the first pass with no modification, so that the intermediate result gets the BS default "spurious" changes. Then do the second pass with the desired changes, so that the human will see only the desired changes in the diff. From rosuav at gmail.com Fri Aug 19 20:10:47 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 20 Aug 2022 10:10:47 +1000 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: On Sat, 20 Aug 2022 at 10:04, David wrote: > > On Sat, 20 Aug 2022 at 04:31, Chris Angelico wrote: > > > What's the best way to precisely reconstruct an HTML file after > > parsing it with BeautifulSoup? > > > Note two distinct changes: firstly, whitespace has been removed, and > > secondly, attributes are reordered (I think alphabetically). There are > > other canonicalizations being done, too. > > > I'm trying to make some automated changes to a huge number of HTML > > files, with minimal diffs so they're easy to validate. That means that > > spurious changes like these are very much unwanted. Is there a way to > > get BS4 to reconstruct the original precisely? > > On Sat, 20 Aug 2022 at 07:02, Chris Angelico wrote: > > On Sat, 20 Aug 2022 at 05:12, Barry wrote: > > > > I recall that in bs4 it parses into an object tree and loses the detail > > > of the input. I recently ported from very old bs to bs4 and hit the > > > same issue. So no it will not output the same as went in. > > > So I'm left with a few options: > > > 1) Give up on validation, give up on verification, and just run this > > thing on the production site with my fingers crossed > > > 2) Instead of doing an intelligent reconstruction, just str.replace() one > > URL with another within the file > > > 3) Split the file into lines, find the Nth line (elem.sourceline) and > > str.replace that line only > > > 4) Attempt to use elem.sourceline and elem.sourcepos to find the start of > > the tag, manually find the end, and replace one tag with the > > reconstructed form. > > > I'm inclined to the first option, honestly. The others just seem like > > hard work, and I became a programmer so I could be lazy... > > Hi, I don't know if you will like this option, but I don't see it on the > list yet so ... Hey, all options are welcomed :) > I'm assuming that the phrase "with minimal diffs so they're easy to > validate" means being eyeballed by a human. > > Have you considered two passes through BS? Do the first pass with no > modification, so that the intermediate result gets the BS default > "spurious" changes. > > Then do the second pass with the desired changes, so that the human will > see only the desired changes in the diff. I'm 100% confident of the actual changes, so that wouldn't really solve anything. The problem is that, without eyeballing the actual changes, I can't easily see if there's been something else changed or broken. This is a scripted change that will affect probably hundreds of HTML files across a large web site, so making sure I don't break anything means either (a) minimize the diff so it's clearly correct, or (b) eyeball the rendered versions of every page - manually - to see if there were any unintended changes. (There WILL be intended visual changes, so I can't render the page to bitmap and ensure that it hasn't changed. This is not React snapshot testing, which IMO is one of the most useless testing features ever devised. No, actually, that can't be true, someone MUST have made a worse one.) Appreciate the suggestion, though! ChrisA From PythonList at DancesWithMice.info Fri Aug 19 20:17:38 2022 From: PythonList at DancesWithMice.info (dn) Date: Sat, 20 Aug 2022 12:17:38 +1200 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: <7be37315-9adc-4aac-4598-be122a9c1ca6@DancesWithMice.info> On 20/08/2022 09.01, Chris Angelico wrote: > On Sat, 20 Aug 2022 at 05:12, Barry wrote: >> >> >> >>> On 19 Aug 2022, at 19:33, Chris Angelico wrote: >>> >>> ?What's the best way to precisely reconstruct an HTML file after >>> parsing it with BeautifulSoup? >> >> I recall that in bs4 it parses into an object tree and loses the detail of the input. >> I recently ported from very old bs to bs4 and hit the same issue. >> So no it will not output the same as went in. >> >> If you can trust the input to be parsed as xml, meaning all the rules of closing >> tags have been followed. Then I think you can parse and unparse thru xml to >> do what you want. >> > > > Yeah, no I can't, this is HTML 4 with a ton of inconsistencies. Oh > well. Thanks for trying, anyhow. > > So I'm left with a few options: > > 1) Give up on validation, give up on verification, and just run this > thing on the production site with my fingers crossed > 2) Instead of doing an intelligent reconstruction, just str.replace() > one URL with another within the file > 3) Split the file into lines, find the Nth line (elem.sourceline) and > str.replace that line only > 4) Attempt to use elem.sourceline and elem.sourcepos to find the start > of the tag, manually find the end, and replace one tag with the > reconstructed form. > > I'm inclined to the first option, honestly. The others just seem like > hard work, and I became a programmer so I could be lazy... +1 - but I've noticed that sometimes I have to work quite hard to be this lazy! Am assuming that http -> https is not the only 'change' (if it were, you'd just do that without BS). How many such changes are planned/need checking? Care to list them? -- -- Regards, =dn From rosuav at gmail.com Fri Aug 19 20:38:07 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 20 Aug 2022 10:38:07 +1000 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: <7be37315-9adc-4aac-4598-be122a9c1ca6@DancesWithMice.info> References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> <7be37315-9adc-4aac-4598-be122a9c1ca6@DancesWithMice.info> Message-ID: On Sat, 20 Aug 2022 at 10:19, dn wrote: > > On 20/08/2022 09.01, Chris Angelico wrote: > > On Sat, 20 Aug 2022 at 05:12, Barry wrote: > >> > >> > >> > >>> On 19 Aug 2022, at 19:33, Chris Angelico wrote: > >>> > >>> ?What's the best way to precisely reconstruct an HTML file after > >>> parsing it with BeautifulSoup? > >> > >> I recall that in bs4 it parses into an object tree and loses the detail of the input. > >> I recently ported from very old bs to bs4 and hit the same issue. > >> So no it will not output the same as went in. > >> > >> If you can trust the input to be parsed as xml, meaning all the rules of closing > >> tags have been followed. Then I think you can parse and unparse thru xml to > >> do what you want. > >> > > > > > > Yeah, no I can't, this is HTML 4 with a ton of inconsistencies. Oh > > well. Thanks for trying, anyhow. > > > > So I'm left with a few options: > > > > 1) Give up on validation, give up on verification, and just run this > > thing on the production site with my fingers crossed > > 2) Instead of doing an intelligent reconstruction, just str.replace() > > one URL with another within the file > > 3) Split the file into lines, find the Nth line (elem.sourceline) and > > str.replace that line only > > 4) Attempt to use elem.sourceline and elem.sourcepos to find the start > > of the tag, manually find the end, and replace one tag with the > > reconstructed form. > > > > I'm inclined to the first option, honestly. The others just seem like > > hard work, and I became a programmer so I could be lazy... > +1 - but I've noticed that sometimes I have to work quite hard to be > this lazy! Yeah, that's very true... > Am assuming that http -> https is not the only 'change' (if it were, > you'd just do that without BS). How many such changes are planned/need > checking? Care to list them? > Assumption is correct. The changes are more of the form "find all the problems, add to the list of fixes, try to minimize the ones that need to be done manually". So far, what I have is: 1) A bunch of http -> https, but not all of them - only domains where I've confirmed that it's valid 2) Some absolute to relative conversions: https://www.gsarchive.net/whowaswho/index.htm should be referred to as /whowaswho/index.htm instead 3) A few outdated URLs for which we know the replacement, eg http://www.cris.com/~oakapple/gasdisc/ to http://www.gasdisc.oakapplepress.com/ (this one can't go on HTTPS, which is one reason I can't shortcut that) 4) Some internal broken links where the path is wrong - anything that resolves to /books/ but can't be found might be better rewritten as /html/perf_grps/websites/ if the file can be found there 5) Any external link that yields a permanent redirect should, to save clientside requests, get replaced by the destination. We have some Creative Commons badges that have moved to new URLs. And there'll be other fixes to be done too. So it's a bit complicated, and no simple solution is really sufficient. At the very very least, I *need* to properly parse with BS4; the only question is whether I reconstruct from the parse tree, or go back to the raw file and try to edit it there. For the record, I have very long-term plans to migrate parts of the site to Markdown, which would make a lot of things easier. But for now, I need to fix the existing problems in the existing HTML files, without doing gigantic wholesale layout changes. ChrisA From monamlee00 at gmail.com Fri Aug 19 17:07:03 2022 From: monamlee00 at gmail.com (Mona Lee) Date: Fri, 19 Aug 2022 14:07:03 -0700 (PDT) Subject: Python scripts in .exe form Message-ID: <9bbeec64-b5ac-44fa-864c-2e7b8eb29a51n@googlegroups.com> I'm pretty new to Python, and I had to do some tinkering because I was running into issues with trying to download a package from PIP and must've caused some issues in my program that I don't know how to fix 1. It started when I was unable to update PIP to the newest version because of some "Unknown error" (VS Code error - unable to read file - (Unknown(FileSystemError) where I believe some file was not saved in the right location? 2. In my command line on VS code there used to be the prefix that looked something like "PS C:\Users\[name]>" but now it is "PS C:\Users\[name]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts> >From there I redownloaded my VS code but still have the 2) issue. also, my scripts are now in the .exe form that I cannot access because "it is either binary or in a unsupported text encoding" I've tried to extract it back into the .py form using pyinstxtractor and decompile-python3 but I can't successfully work these. 3. also wanted to mention that some of my old Python programs are missing. From jschwar at sbcglobal.net Sat Aug 20 09:25:01 2022 From: jschwar at sbcglobal.net (Jim Schwartz) Date: Sat, 20 Aug 2022 08:25:01 -0500 Subject: Python scripts in .exe form In-Reply-To: <9bbeec64-b5ac-44fa-864c-2e7b8eb29a51n@googlegroups.com> References: <9bbeec64-b5ac-44fa-864c-2e7b8eb29a51n@googlegroups.com> Message-ID: <695CDEE2-3B30-42AC-8FD0-8642AB88D7A5@sbcglobal.net> What method did you use to create the exe file from your python scripts? If it was pyinstaller, then it puts the compiled versions of these python scripts in a windows temp folder when you run them. You?ll be able to get the scripts from there. Sent from my iPhone > On Aug 19, 2022, at 9:51 PM, Mona Lee wrote: > > ?I'm pretty new to Python, and I had to do some tinkering because I was running into issues with trying to download a package from PIP and must've caused some issues in my program that I don't know how to fix > > 1. It started when I was unable to update PIP to the newest version because of some "Unknown error" (VS Code error - unable to read file - (Unknown(FileSystemError) where I believe some file was not saved in the right location? > > 2. In my command line on VS code there used to be the prefix that looked something like "PS C:\Users\[name]>" but now it is "PS C:\Users\[name]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts> > > From there I redownloaded my VS code but still have the 2) issue. > > also, my scripts are now in the .exe form that I cannot access because "it is either binary or in a unsupported text encoding" I've tried to extract it back into the .py form using pyinstxtractor and decompile-python3 but I can't successfully work these. > > 3. also wanted to mention that some of my old Python programs are missing. > -- > https://mail.python.org/mailman/listinfo/python-list From jon+usenet at unequivocal.eu Fri Aug 19 23:11:44 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Sat, 20 Aug 2022 03:11:44 -0000 (UTC) Subject: Mutating an HTML file with BeautifulSoup References: Message-ID: On 2022-08-19, Chris Angelico wrote: > What's the best way to precisely reconstruct an HTML file after > parsing it with BeautifulSoup? > > Using the Alice example from the BS4 docs: > >>>> html_doc = """The Dormouse's story > >

The Dormouse's story

> >

Once upon a time there were three little sisters; and > their names were >Elsie, >Lacie and >Tillie; > and they lived at the bottom of a well.

> >

...

> """ >>>> print(soup) >The Dormouse's story > >

The Dormouse's story

>

Once upon a time there were three little sisters; and > their names were >Elsie, >Lacie and >Tillie; > and they lived at the bottom of a well.

>

...

> >>>> > > Note two distinct changes: firstly, whitespace has been removed, and > secondly, attributes are reordered (I think alphabetically). There are > other canonicalizations being done, too. > > I'm trying to make some automated changes to a huge number of HTML > files, with minimal diffs so they're easy to validate. That means that > spurious changes like these are very much unwanted. Is there a way to > get BS4 to reconstruct the original precisely? > > The mutation itself would be things like finding an anchor tag and > changing its href attribute. Fairly simple changes, but might alter > the length of the file (eg changing "http://example.com/" into > "https://example.com/"). I'd like to do them intelligently rather than > falling back on element.sourceline and element.sourcepos, but worst > case, that's what I'll have to do (which would be fiddly). I'm tempting the Wrath of Zalgo by saying it, but ... regexp? From rosuav at gmail.com Sat Aug 20 14:06:17 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 21 Aug 2022 04:06:17 +1000 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: On Sun, 21 Aug 2022 at 03:27, Stefan Ram wrote: > > 2QdxY4RzWzUUiLuE at potatochowder.com writes: > >textual representations. That way, the following two elements are the > >same (and similar with a collection of sub-elements in a different order > >in another document): > > The /elements/ differ. They have the /same/ infoset. That's the bit that's hard to prove. > The OP could edit the files with regexps to create a new version. To you and Jon, who also suggested this: how would that be beneficial? With Beautiful Soup, I have the line number and position within the line where the tag starts; what does a regex give me that I don't have that way? > Soup := BeautifulSoup. > > Then have Soup read both the new version and the old version. > > Then have Soup also edit the old version read in, the same way as > the regexps did and verify that now the old version edited by > Soup and the new version created using regexps agree. > > Or just use Soup as a tool to show the diffs for visual inspection > by having Soup read both the original version and the version edited > with regexps. Now both are normalized by Soup and Soup can show the > diffs (such a diff feature might not be a part of Soup, but it should > not be too much effort to write one using Soup). > But as mentioned, the entire problem *is* the normalization, as I have no proof that it has had no impact on the rendering of the page. Comparing two normalized versions is no better than my original option 1, whereby I simply ignore the normalization and write out the reconstructed content. It's easy if you know for certain that the page is well-formed. Much harder if you do not - or, as in some cases, if you know the page is badly-formed. ChrisA From barry at barrys-emacs.org Sat Aug 20 18:04:46 2022 From: barry at barrys-emacs.org (Barry) Date: Sat, 20 Aug 2022 23:04:46 +0100 Subject: Python scripts in .exe form In-Reply-To: <695CDEE2-3B30-42AC-8FD0-8642AB88D7A5@sbcglobal.net> References: <695CDEE2-3B30-42AC-8FD0-8642AB88D7A5@sbcglobal.net> Message-ID: <56441F68-50E8-4B70-82DA-E03F8236E9C5@barrys-emacs.org> > On 20 Aug 2022, at 14:28, Jim Schwartz wrote: > > ?What method did you use to create the exe file from your python scripts? If it was pyinstaller, then it puts the compiled versions of these python scripts in a windows temp folder when you run them. You?ll be able to get the scripts from there. The temp file is only for .dll files the python code is in a data block that is appended to the .exe stub. There are tools that can grab the appended dat and dump it out. Or atleast should be. Barry > > Sent from my iPhone > >> On Aug 19, 2022, at 9:51 PM, Mona Lee wrote: >> >> ?I'm pretty new to Python, and I had to do some tinkering because I was running into issues with trying to download a package from PIP and must've caused some issues in my program that I don't know how to fix >> >> 1. It started when I was unable to update PIP to the newest version because of some "Unknown error" (VS Code error - unable to read file - (Unknown(FileSystemError) where I believe some file was not saved in the right location? >> >> 2. In my command line on VS code there used to be the prefix that looked something like "PS C:\Users\[name]>" but now it is "PS C:\Users\[name]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts> >> >> From there I redownloaded my VS code but still have the 2) issue. >> >> also, my scripts are now in the .exe form that I cannot access because "it is either binary or in a unsupported text encoding" I've tried to extract it back into the .py form using pyinstxtractor and decompile-python3 but I can't successfully work these. >> >> 3. also wanted to mention that some of my old Python programs are missing. >> -- >> https://mail.python.org/mailman/listinfo/python-list > > -- > https://mail.python.org/mailman/listinfo/python-list From jon+usenet at unequivocal.eu Sat Aug 20 14:16:02 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Sat, 20 Aug 2022 18:16:02 -0000 (UTC) Subject: Mutating an HTML file with BeautifulSoup References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: On 2022-08-20, Chris Angelico wrote: > On Sun, 21 Aug 2022 at 03:27, Stefan Ram wrote: >> 2QdxY4RzWzUUiLuE at potatochowder.com writes: >> >textual representations. That way, the following two elements are the >> >same (and similar with a collection of sub-elements in a different order >> >in another document): >> >> The /elements/ differ. They have the /same/ infoset. > > That's the bit that's hard to prove. > >> The OP could edit the files with regexps to create a new version. > > To you and Jon, who also suggested this: how would that be beneficial? > With Beautiful Soup, I have the line number and position within the > line where the tag starts; what does a regex give me that I don't have > that way? You mean you could use BeautifulSoup to read the file and identify the bits you want to change by line number and offset, and then you could use that data to try and update the file, hoping like hell that your definition of "line" and "offset" are identical to BeautifulSoup's and that you don't mess up later changes when you do earlier ones (you could do them in reverse order of line and offset I suppose) and probably resorting to regexps anyway in order to find the part of the tag you want to change ... ... or you could avoid all that faff and just do re.sub()? From jon+usenet at unequivocal.eu Sat Aug 20 17:51:41 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Sat, 20 Aug 2022 21:51:41 -0000 (UTC) Subject: Mutating an HTML file with BeautifulSoup References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: On 2022-08-20, Stefan Ram wrote: > Jon Ribbens writes: >>... or you could avoid all that faff and just do re.sub()? > > import bs4 > import re > > source = '' > > # Use Python to change the source, keeping the order of attributes. > > result = re.sub( r'href\s*=\s*"http"', r'href="https"', source ) > result = re.sub( r"href\s*=\s*'http'", r"href='https'", result ) You could go a bit harder with the regexp of course, e.g.: result = re.sub( r"""(<\s*a\s+[^>]*href\s*=\s*)(['"])\s*OLD\s*\2""", r"\1\2NEW\2", source, flags=re.IGNORECASE ) > # Now use BeautifulSoup only for the verification of the result. > > reference = bs4.BeautifulSoup( source, features="html.parser" ) > for a in reference.find_all( "a" ): > if a[ 'href' ]== 'http': a[ 'href' ]='https' > > print( bs4.BeautifulSoup( result, features="html.parser" )== reference ) Hmm, yes that seems like a pretty good idea. From PythonList at DancesWithMice.info Sat Aug 20 19:46:24 2022 From: PythonList at DancesWithMice.info (dn) Date: Sun, 21 Aug 2022 11:46:24 +1200 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> <7be37315-9adc-4aac-4598-be122a9c1ca6@DancesWithMice.info> Message-ID: <27f23c7c-d167-1d0c-0270-9abe21bee9af@DancesWithMice.info> On 20/08/2022 12.38, Chris Angelico wrote: > On Sat, 20 Aug 2022 at 10:19, dn wrote: >> On 20/08/2022 09.01, Chris Angelico wrote: >>> On Sat, 20 Aug 2022 at 05:12, Barry wrote: >>>>> On 19 Aug 2022, at 19:33, Chris Angelico wrote: >>>>> >>>>> ?What's the best way to precisely reconstruct an HTML file after >>>>> parsing it with BeautifulSoup? ... >>> well. Thanks for trying, anyhow. >>> >>> So I'm left with a few options: >>> >>> 1) Give up on validation, give up on verification, and just run this >>> thing on the production site with my fingers crossed >>> 2) Instead of doing an intelligent reconstruction, just str.replace() >>> one URL with another within the file >>> 3) Split the file into lines, find the Nth line (elem.sourceline) and >>> str.replace that line only >>> 4) Attempt to use elem.sourceline and elem.sourcepos to find the start >>> of the tag, manually find the end, and replace one tag with the >>> reconstructed form. >>> >>> I'm inclined to the first option, honestly. The others just seem like >>> hard work, and I became a programmer so I could be lazy... >> +1 - but I've noticed that sometimes I have to work quite hard to be >> this lazy! > > Yeah, that's very true... > >> Am assuming that http -> https is not the only 'change' (if it were, >> you'd just do that without BS). How many such changes are planned/need >> checking? Care to list them? This project has many of the same 'smells' as a database-harmonisation effort. Particularly one where 'the previous guy' used to use field-X for certain data, but his replacement decided that field-Y 'sounded better' (or some such user-logic). Arrrggghhhh! If you like head-aches, and users coming to you with ifs-buts-and-maybes AFTER you've 'done stuff', this is your sort of project! > Assumption is correct. The changes are more of the form "find all the > problems, add to the list of fixes, try to minimize the ones that need > to be done manually". So far, what I have is: Having taken the trouble to identify this list of improvements and given the determination to verify each, consider working through one item at a time, rather than in a single pass. This will enable individual logging of changes, a manual check of each alteration, and the ability to choose/tailor the best tool for that specific task. In fact, depending upon frequency, making the changes manually (and with improved confidence in the result). The presence of (or allusion to) the word "some" in this list-items is 'the killer'. Automation doesn't like 'some' (cf "all") unless the criteria can be clearly and unambiguously defined. Ouch! (I don't think you need to be told any of this, but hey: dreams are free!) > 1) A bunch of http -> https, but not all of them - only domains where > I've confirmed that it's valid The search-criteria is the list of valid domains, rather than the "http/https" which is likely the first focus. > 2) Some absolute to relative conversions: > https://www.gsarchive.net/whowaswho/index.htm should be referred to as > /whowaswho/index.htm instead Similarly, if you have a list of these. > 3) A few outdated URLs for which we know the replacement, eg > http://www.cris.com/~oakapple/gasdisc/ to > http://www.gasdisc.oakapplepress.com/ (this one can't go on > HTTPS, which is one reason I can't shortcut that) Again. > 4) Some internal broken links where the path is wrong - anything that > resolves to /books/ but can't be found might be better > rewritten as /html/perf_grps/websites/ if the file can be > found there Again. > 5) Any external link that yields a permanent redirect should, to save > clientside requests, get replaced by the destination. We have some > Creative Commons badges that have moved to new URLs. Do you have these as a list, or are you intending the automated-method to auto-magically follow the link to determine any need for action? > And there'll be other fixes to be done too. So it's a bit complicated, > and no simple solution is really sufficient. At the very very least, I > *need* to properly parse with BS4; the only question is whether I > reconstruct from the parse tree, or go back to the raw file and try to > edit it there. At least the diffs would give you something to work-from, but it's a bit like git-diffs claiming a 'change' when the only difference is that my IDE strips blanks from the ends of code-lines, or some-such silliness. Which brings me to ask: why "*need* to properly parse with BS4"? What about selective use of tools, previously-mentioned in this thread? Is Selenium worthy of consideration? I'm assuming you've already been using a link-checker utility to locate the links which need to be changed. They can be used in QA-mode after-the-fact too. > For the record, I have very long-term plans to migrate parts of the > site to Markdown, which would make a lot of things easier. But for > now, I need to fix the existing problems in the existing HTML files, > without doing gigantic wholesale layout changes. ...and there's another option. If the Markdown conversion is done first, it will obviate any option of diffs completely. However, it will introduce a veritable cornucopia of opportunity for this and 'other stuff' to go-wrong, bringing us back to a page-by-page check or broad-checks only, and an appeal to readers to report problems. The (PM-oriented) observation is that if you are baulking at the amount of work 'now', you'll be equally dismayed by the consequences of a subsequent 'Markdown project'! Perhaps, therefore, some counter-intuitive logic, eg combining the two/biting two bullets/recognising that many of risks and likelihoods of error overlap (rather than add/multiply). 'Bit rot' is so common in today's world, do readers treat such pages/sites particularly differently? Somewhat conversely, even in our 'release-often, break-early' world, do users often exert themselves to provide constructive feedback, eg 'link broken'? -- Regards, =dn From rosuav at gmail.com Sat Aug 20 20:43:50 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 21 Aug 2022 10:43:50 +1000 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: On Sun, 21 Aug 2022 at 09:31, Jon Ribbens via Python-list wrote: > > On 2022-08-20, Chris Angelico wrote: > > On Sun, 21 Aug 2022 at 03:27, Stefan Ram wrote: > >> 2QdxY4RzWzUUiLuE at potatochowder.com writes: > >> >textual representations. That way, the following two elements are the > >> >same (and similar with a collection of sub-elements in a different order > >> >in another document): > >> > >> The /elements/ differ. They have the /same/ infoset. > > > > That's the bit that's hard to prove. > > > >> The OP could edit the files with regexps to create a new version. > > > > To you and Jon, who also suggested this: how would that be beneficial? > > With Beautiful Soup, I have the line number and position within the > > line where the tag starts; what does a regex give me that I don't have > > that way? > > You mean you could use BeautifulSoup to read the file and identify the > bits you want to change by line number and offset, and then you could > use that data to try and update the file, hoping like hell that your > definition of "line" and "offset" are identical to BeautifulSoup's > and that you don't mess up later changes when you do earlier ones (you > could do them in reverse order of line and offset I suppose) and > probably resorting to regexps anyway in order to find the part of the > tag you want to change ... > > ... or you could avoid all that faff and just do re.sub()? Stefan answered in part, but I'll add that it is far FAR easier to do the analysis with BS4 than regular expressions. I'm not sure what "hoping like hell" is supposed to mean here, since the line and offset have been 100% accurate in my experience; the only part I'm unsure about is where the _end_ of the tag is (and maybe there's a way I can use BS4 again to get that??). ChrisA From rosuav at gmail.com Sat Aug 20 21:00:33 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 21 Aug 2022 11:00:33 +1000 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: <27f23c7c-d167-1d0c-0270-9abe21bee9af@DancesWithMice.info> References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> <7be37315-9adc-4aac-4598-be122a9c1ca6@DancesWithMice.info> <27f23c7c-d167-1d0c-0270-9abe21bee9af@DancesWithMice.info> Message-ID: On Sun, 21 Aug 2022 at 09:48, dn wrote: > > On 20/08/2022 12.38, Chris Angelico wrote: > > On Sat, 20 Aug 2022 at 10:19, dn wrote: > >> On 20/08/2022 09.01, Chris Angelico wrote: > >>> On Sat, 20 Aug 2022 at 05:12, Barry wrote: > >>>>> On 19 Aug 2022, at 19:33, Chris Angelico wrote: > >>>>> > >>>>> ?What's the best way to precisely reconstruct an HTML file after > >>>>> parsing it with BeautifulSoup? > ... > > >>> well. Thanks for trying, anyhow. > >>> > >>> So I'm left with a few options: > >>> > >>> 1) Give up on validation, give up on verification, and just run this > >>> thing on the production site with my fingers crossed > >>> 2) Instead of doing an intelligent reconstruction, just str.replace() > >>> one URL with another within the file > >>> 3) Split the file into lines, find the Nth line (elem.sourceline) and > >>> str.replace that line only > >>> 4) Attempt to use elem.sourceline and elem.sourcepos to find the start > >>> of the tag, manually find the end, and replace one tag with the > >>> reconstructed form. > >>> > >>> I'm inclined to the first option, honestly. The others just seem like > >>> hard work, and I became a programmer so I could be lazy... > >> +1 - but I've noticed that sometimes I have to work quite hard to be > >> this lazy! > > > > Yeah, that's very true... > > > >> Am assuming that http -> https is not the only 'change' (if it were, > >> you'd just do that without BS). How many such changes are planned/need > >> checking? Care to list them? > > This project has many of the same 'smells' as a database-harmonisation > effort. Particularly one where 'the previous guy' used to use field-X > for certain data, but his replacement decided that field-Y 'sounded > better' (or some such user-logic). Arrrggghhhh! > > If you like head-aches, and users coming to you with ifs-buts-and-maybes > AFTER you've 'done stuff', this is your sort of project! Well, I don't like headaches, but I do appreciate what the G&S Archive has given me over the years, so I'm taking this on as a means of giving back to the community. > > Assumption is correct. The changes are more of the form "find all the > > problems, add to the list of fixes, try to minimize the ones that need > > to be done manually". So far, what I have is: > > Having taken the trouble to identify this list of improvements and given > the determination to verify each, consider working through one item at a > time, rather than in a single pass. This will enable individual logging > of changes, a manual check of each alteration, and the ability to > choose/tailor the best tool for that specific task. > > In fact, depending upon frequency, making the changes manually (and with > improved confidence in the result). Unfortunately the frequency is very high. > The presence of (or allusion to) the word "some" in this list-items is > 'the killer'. Automation doesn't like 'some' (cf "all") unless the > criteria can be clearly and unambiguously defined. Ouch! > > (I don't think you need to be told any of this, but hey: dreams are free!) Right; the criteria are quite well defined, but I omitted the details for brevity. > > 1) A bunch of http -> https, but not all of them - only domains where > > I've confirmed that it's valid > > The search-criteria is the list of valid domains, rather than the > "http/https" which is likely the first focus. Yeah. I do a first pass to enumerate all domains that are ever linked to with http:// URLs, and then I have a script that goes through and checks to see if they redirect me to the same URL on the other protocol, or other ways of checking. So yes, the list of valid domains is part of the program's effective input. > > 2) Some absolute to relative conversions: > > https://www.gsarchive.net/whowaswho/index.htm should be referred to as > > /whowaswho/index.htm instead > > Similarly, if you have a list of these. It's more just the pattern "https://www.gsarchive.net/" and "https://gsarchive.net/", and the corresponding "http://" URLs, plus a few other malformed versions that are worth correcting (if ever I find a link to "www.gsarchive.net/", it's almost certainly missing its protocol). > > 3) A few outdated URLs for which we know the replacement, eg > > http://www.cris.com/~oakapple/gasdisc/ to > > http://www.gasdisc.oakapplepress.com/ (this one can't go on > > HTTPS, which is one reason I can't shortcut that) > > Again. Same; although those are manually entered as patterns. > > 4) Some internal broken links where the path is wrong - anything that > > resolves to /books/ but can't be found might be better > > rewritten as /html/perf_grps/websites/ if the file can be > > found there > > Again. The fixups are manually entered, but I also need to know about every broken internal link so that I can look through them and figure out what's wrong. > > 5) Any external link that yields a permanent redirect should, to save > > clientside requests, get replaced by the destination. We have some > > Creative Commons badges that have moved to new URLs. > > Do you have these as a list, or are you intending the automated-method > to auto-magically follow the link to determine any need for action? The same script that checks for http->https conversion probes all links and checks to see if (a) it returns a perm redirect, or (b) it returns an error. Fix the first group, log the second, leave anything else alone. > > And there'll be other fixes to be done too. So it's a bit complicated, > > and no simple solution is really sufficient. At the very very least, I > > *need* to properly parse with BS4; the only question is whether I > > reconstruct from the parse tree, or go back to the raw file and try to > > edit it there. > > At least the diffs would give you something to work-from, but it's a bit > like git-diffs claiming a 'change' when the only difference is that my > IDE strips blanks from the ends of code-lines, or some-such silliness. Right; and the reconstructed version has a LOT of those unnecessary changes. I'm seeing a lot of changes to whitespace. The only problem is whether I can be confident that none of those changes could ever matter. > Which brings me to ask: why "*need* to properly parse with BS4"? Well, there's a *need to properly parse*, because I don't want to summon "the One whose Name cannot be expressed in the Basic Multilingual Plane" by using regular expressions on HTML. Am open to other suggestions; BS4 is the single most obvious one, but by no means the only way to do things. > What about selective use of tools, previously-mentioned in this thread? I've answered the option of regular expressions; did I miss any other HTML-aware tools being mentioned? If so, my apologies, and feel free to remind me. > Is Selenium worthy of consideration? Yes..... but I don't know how much it would buy me. It certainly has no options for editing back the original HTML, so all it would do is the parsing side of things (which is already working fine). > I'm assuming you've already been using a link-checker utility to locate > the links which need to be changed. They can be used in QA-mode > after-the-fact too. I actually haven't, but only because I figured that the autofixer would do the same job as the link-checker. Or rather, I wrote my own link-checker because I needed it to do more. And again, most standard utilities merely list the problems, they don't have a way to fix them. > > For the record, I have very long-term plans to migrate parts of the > > site to Markdown, which would make a lot of things easier. But for > > now, I need to fix the existing problems in the existing HTML files, > > without doing gigantic wholesale layout changes. > > ...and there's another option. If the Markdown conversion is done first, > it will obviate any option of diffs completely. However, it will > introduce a veritable cornucopia of opportunity for this and 'other > stuff' to go-wrong, bringing us back to a page-by-page check or > broad-checks only, and an appeal to readers to report problems. Yeah, and the fundamental problem with the MD conversion is time - it's a big manual process. I want to be able to do that progressively over time, but get the basic stuff sorted out much sooner. Ideally, it should be possible to fix all the autofixable links this week and get that sorted out, but converting pages to Markdown will happen slowly over the next few years. > The (PM-oriented) observation is that if you are baulking at the amount > of work 'now', you'll be equally dismayed by the consequences of a > subsequent 'Markdown project'! Nah, there's no rush on it, and I know from experience how much benefit it can give :) > Perhaps, therefore, some counter-intuitive logic, eg combining the > two/biting two bullets/recognising that many of risks and likelihoods of > error overlap (rather than add/multiply). That's true, and for new pages, it's way easier to handle (for instance, this page https://gsarchive.net/html/dixon.html did not exist prior to my curatorship - for obvious reasons - and I created it as a Markdown file). > 'Bit rot' is so common in today's world, do readers treat such > pages/sites particularly differently? That's what I am unsure of, and why I would prefer to make as few unnecessary changes as possible. However, I am leaning more and more strongly towards "just let BS4 do its canonicalization", given that all the alternatives posted here have been worse. > Somewhat conversely, even in our 'release-often, break-early' world, do > users often exert themselves to provide constructive feedback, eg 'link > broken'? Maybe? But there are always pages that only a few people ever look at (this is a vast archive and some of its content is *extremely* niche), so I would prefer to preempt the issues. Appreciate the thoughts. ChrisA From PythonList at DancesWithMice.info Sat Aug 20 23:39:33 2022 From: PythonList at DancesWithMice.info (dn) Date: Sun, 21 Aug 2022 15:39:33 +1200 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> <7be37315-9adc-4aac-4598-be122a9c1ca6@DancesWithMice.info> <27f23c7c-d167-1d0c-0270-9abe21bee9af@DancesWithMice.info> Message-ID: <3690bf42-8c34-58b2-1c5b-d38eeeb02bc4@DancesWithMice.info> On 21/08/2022 13.00, Chris Angelico wrote: > On Sun, 21 Aug 2022 at 09:48, dn wrote: >> On 20/08/2022 12.38, Chris Angelico wrote: >>> On Sat, 20 Aug 2022 at 10:19, dn wrote: >>>> On 20/08/2022 09.01, Chris Angelico wrote: >>>>> On Sat, 20 Aug 2022 at 05:12, Barry wrote: >>>>>>> On 19 Aug 2022, at 19:33, Chris Angelico wrote: >>>>> So I'm left with a few options: >>>>> >>>>> 1) Give up on validation, give up on verification, and just run this >>>>> thing on the production site with my fingers crossed >>>>> 2) Instead of doing an intelligent reconstruction, just str.replace() >>>>> one URL with another within the file >>>>> 3) Split the file into lines, find the Nth line (elem.sourceline) and >>>>> str.replace that line only >>>>> 4) Attempt to use elem.sourceline and elem.sourcepos to find the start >>>>> of the tag, manually find the end, and replace one tag with the >>>>> reconstructed form. >>>>> >>>>> I'm inclined to the first option, honestly. The others just seem like >>>>> hard work, and I became a programmer so I could be lazy... >>>> +1 - but I've noticed that sometimes I have to work quite hard to be >>>> this lazy! >>> >>> Yeah, that's very true... >>> >>>> Am assuming that http -> https is not the only 'change' (if it were, >>>> you'd just do that without BS). How many such changes are planned/need >>>> checking? Care to list them? >> >> This project has many of the same 'smells' as a database-harmonisation >> effort. Particularly one where 'the previous guy' used to use field-X >> for certain data, but his replacement decided that field-Y 'sounded >> better' (or some such user-logic). Arrrggghhhh! >> >> If you like head-aches, and users coming to you with ifs-buts-and-maybes >> AFTER you've 'done stuff', this is your sort of project! > > Well, I don't like headaches, but I do appreciate what the G&S Archive > has given me over the years, so I'm taking this on as a means of > giving back to the community. This point will be picked-up in the conclusion. NB in the same way that you want to 'give back', so also do others - even if in minor ways or 'when-relevant'! >>> Assumption is correct. The changes are more of the form "find all the >>> problems, add to the list of fixes, try to minimize the ones that need >>> to be done manually". So far, what I have is: >> >> Having taken the trouble to identify this list of improvements and given >> the determination to verify each, consider working through one item at a >> time, rather than in a single pass. This will enable individual logging >> of changes, a manual check of each alteration, and the ability to >> choose/tailor the best tool for that specific task. >> >> In fact, depending upon frequency, making the changes manually (and with >> improved confidence in the result). > > Unfortunately the frequency is very high. Screechingly so? Like you're singing Three Little Maids? >> The presence of (or allusion to) the word "some" in this list-items is >> 'the killer'. Automation doesn't like 'some' (cf "all") unless the >> criteria can be clearly and unambiguously defined. Ouch! >> >> (I don't think you need to be told any of this, but hey: dreams are free!) > > Right; the criteria are quite well defined, but I omitted the details > for brevity. > >>> 1) A bunch of http -> https, but not all of them - only domains where >>> I've confirmed that it's valid >> >> The search-criteria is the list of valid domains, rather than the >> "http/https" which is likely the first focus. > > Yeah. I do a first pass to enumerate all domains that are ever linked > to with http:// URLs, and then I have a script that goes through and > checks to see if they redirect me to the same URL on the other > protocol, or other ways of checking. So yes, the list of valid domains > is part of the program's effective input. Wow! Having got that far, you have achieved data-validity. Is there a need to perform a before-after check or diff? Perhaps start making the one-for-one replacements without further anxiety. As long as there's no silly-mistake, eg failing to remove an opening or closing angle-bracket; isn't that about all the checking needed? (for this category of updates) >>> 2) Some absolute to relative conversions: >>> https://www.gsarchive.net/whowaswho/index.htm should be referred to as >>> /whowaswho/index.htm instead >> >> Similarly, if you have a list of these. > > It's more just the pattern "https://www.gsarchive.net/" and > "https://gsarchive.net/", and the corresponding "http://" > URLs, plus a few other malformed versions that are worth correcting > (if ever I find a link to "www.gsarchive.net/", it's almost > certainly missing its protocol). Isn't the inspection tool (described elsewhere) reporting an HTML/editor line number? That being the case, won't a bit of Swiss-Army knife Python-string work enable appropriate processing and re-writing - as well as providing the means to statistically-sample for QA? >>> 3) A few outdated URLs for which we know the replacement, eg >>> http://www.cris.com/~oakapple/gasdisc/ to >>> http://www.gasdisc.oakapplepress.com/ (this one can't go on >>> HTTPS, which is one reason I can't shortcut that) >> >> Again. > > Same; although those are manually entered as patterns. Ah "manual". The trusty IDE/editor as your friend... Although, if the same pattern appears in multiple places, maybe it would be possible to create a template-solution, and then apply to specific filename and line-number combinations? BTW in talk of "line-number", you will have realised the need to re-run the identification of such after each of these steps - in case the 'new stuff' relating to earlier steps (assuming above became also a temporal sequence) is shorter/longer than the current HTML. >>> 4) Some internal broken links where the path is wrong - anything that >>> resolves to /books/ but can't be found might be better >>> rewritten as /html/perf_grps/websites/ if the file can be >>> found there >> >> Again. > > The fixups are manually entered, but I also need to know about every > broken internal link so that I can look through them and figure out > what's wrong. OK, so it is assumed that the link-checker tool is performing the problem identification/location, and that's as far as anyone/any computer, could hope to go. >>> 5) Any external link that yields a permanent redirect should, to save >>> clientside requests, get replaced by the destination. We have some >>> Creative Commons badges that have moved to new URLs. >> >> Do you have these as a list, or are you intending the automated-method >> to auto-magically follow the link to determine any need for action? > > The same script that checks for http->https conversion probes all > links and checks to see if (a) it returns a perm redirect, or (b) it > returns an error. Fix the first group, log the second, leave anything > else alone. QED! >>> And there'll be other fixes to be done too. So it's a bit complicated, >>> and no simple solution is really sufficient. At the very very least, I >>> *need* to properly parse with BS4; the only question is whether I >>> reconstruct from the parse tree, or go back to the raw file and try to >>> edit it there. >> >> At least the diffs would give you something to work-from, but it's a bit >> like git-diffs claiming a 'change' when the only difference is that my >> IDE strips blanks from the ends of code-lines, or some-such silliness. > > Right; and the reconstructed version has a LOT of those unnecessary > changes. I'm seeing a lot of changes to whitespace. The only problem > is whether I can be confident that none of those changes could ever > matter. "White-space" has lesser-meaning in HTML - this is NOT Python! In HTML if I write "HTML file" (with two spaces), the browser will shorten the display to a single space (hence some uses of   - non-broken space). Similarly, if attempt to use "\n" to start a new line of text... Is there a danger of 'chasing your own tail', ie seeking a solution to a problem which really doesn't matter (particularly if we add the phrase: at the user-level)? Which brings-up the question of the efficacy of diffs cf the efficacy of BS4's contributions? (see later: statistical QA cf 100% confirmations) >> Which brings me to ask: why "*need* to properly parse with BS4"? > > Well, there's a *need to properly parse*, because I don't want to > summon "the One whose Name cannot be expressed in the Basic > Multilingual Plane" by using regular expressions on HTML. Am open to > other suggestions; BS4 is the single most obvious one, but by no means > the only way to do things. Agree with "properly parse". Question was an apparent dedication to BS4 when there are other tools. Just checking you aren't wearing that type of 'blinders'. (didn't think so, but...) >> What about selective use of tools, previously-mentioned in this thread? > > I've answered the option of regular expressions; did I miss any other > HTML-aware tools being mentioned? If so, my apologies, and feel free > to remind me. > >> Is Selenium worthy of consideration? > > Yes..... but I don't know how much it would buy me. It certainly has > no options for editing back the original HTML, so all it would do is > the parsing side of things (which is already working fine). In which case, no gain. (I probably use it more than BS - but because it is useful to 'test' web-pages, GUI behavior, etc) My thinking was to start with [a parser] and deal with a sub-set of the list of 'problems', one (separate) routine at a time. Either-mentioned will do the job. A better 'diff' would not look at the HTML, but compare the web-page's before and after 'appearances'! (after all, the link-checker has already figured-out the 'behind the scenes' part) >> I'm assuming you've already been using a link-checker utility to locate >> the links which need to be changed. They can be used in QA-mode >> after-the-fact too. > > I actually haven't, but only because I figured that the autofixer > would do the same job as the link-checker. Or rather, I wrote my own > link-checker because I needed it to do more. And again, most standard > utilities merely list the problems, they don't have a way to fix them. Discussed throughout this reply. (most were written a long, long, time ago - pre-dating the widespread introduction (and now insistence?) of https, JS advantages, etc) >>> For the record, I have very long-term plans to migrate parts of the >>> site to Markdown, which would make a lot of things easier. But for >>> now, I need to fix the existing problems in the existing HTML files, >>> without doing gigantic wholesale layout changes. >> >> ...and there's another option. If the Markdown conversion is done first, >> it will obviate any option of diffs completely. However, it will >> introduce a veritable cornucopia of opportunity for this and 'other >> stuff' to go-wrong, bringing us back to a page-by-page check or >> broad-checks only, and an appeal to readers to report problems. > > Yeah, and the fundamental problem with the MD conversion is time - > it's a big manual process. I want to be able to do that progressively > over time, but get the basic stuff sorted out much sooner. Ideally, it > should be possible to fix all the autofixable links this week and get > that sorted out, but converting pages to Markdown will happen slowly > over the next few years. Not something I've ever needed to consider. Are there no tools for this? >> The (PM-oriented) observation is that if you are baulking at the amount >> of work 'now', you'll be equally dismayed by the consequences of a >> subsequent 'Markdown project'! > > Nah, there's no rush on it, and I know from experience how much > benefit it can give :) Warning: more 'normal people' know something of HTML, than do of Markdown. In fact, whereas many people from outside of IT attend our HTML5 courses (implicit disclaimer!), I'll suggest that if a person knows Markdown (s)he is at least 85% likely to be in IT. Another ([in]famous dn off-the-wall) question: have you considered 'crowd-sourcing' the project? There are bound to be members who particularly favor one operetta or song. If the project were moved to a wiki or software like WordPress, would individual members be prepared to copy-paste from 'the old' to 'the new', checking links and copy-pasting the URL, etc, as they go? You might then become PM with responsibility for listing all the existing pages and crossing them off as 'converted'. Also, dealing with 'complicated matters', eg links which the member is unable to replace. NB I recall (somewhere) a claim (about "distraction" and "consumption" cf "creativity") that if all Americans were to stop watching ("consuming") TV for a single weekend, it would release sufficient time to "create" Wikipedia in its entirety. >> Perhaps, therefore, some counter-intuitive logic, eg combining the >> two/biting two bullets/recognising that many of risks and likelihoods of >> error overlap (rather than add/multiply). > > That's true, and for new pages, it's way easier to handle (for > instance, this page https://gsarchive.net/html/dixon.html did not > exist prior to my curatorship - for obvious reasons - and I created it > as a Markdown file). Well, I'm not just a pretty face - and most of the time, not even that! >> 'Bit rot' is so common in today's world, do readers treat such >> pages/sites particularly differently? > > That's what I am unsure of, and why I would prefer to make as few > unnecessary changes as possible. However, I am leaning more and more > strongly towards "just let BS4 do its canonicalization", given that > all the alternatives posted here have been worse. Good! Remember, the more important measure is what the users/members think - not how IT-perfect it might be. This is the opposite of the mantra I (over-)frequently recite to trainees (particularly those who have just learned JS and think they can now 'take-over the world'...) "just because we can do it, doesn't make it a good idea"! I feel, whilst a modest contribution, almost worthy of G&S! >> Somewhat conversely, even in our 'release-often, break-early' world, do >> users often exert themselves to provide constructive feedback, eg 'link >> broken'? > > Maybe? But there are always pages that only a few people ever look at > (this is a vast archive and some of its content is *extremely* niche), > so I would prefer to preempt the issues. > > Appreciate the thoughts. I'm conscious that some of the thoughts have come from having a Consulting/PM 'hat' on; whereas others address more technical aspects. Similarly, is it possible that you are attempting to be "the very model of a modern Major-General", whilst the service required may be more on the line about being "very good at [la, la, la; something or other - he can't remember the words)] and calculus" (IT not invented back in the days of the Pirates of Penzance)? Looking at the site, (unkindly-speaking) it is reminiscent of AOL/GeoCities days. Which is not necessarily 'bad', but is indicative of a membership who care less about appearances and more about 'the business' of the group. Accordingly, and referring back to the responses people have to dead-lines, and such-like, isn't it *more*-likely that such members will report 'issues'? Thus, would inviting such communications, perhaps by putting a 'banner' on every page, be likely to yield constructive results without generating (unreasonable) complaint? In turn, this might mean lowering your personal standards and exceptions on the 'calculus' side,and accepting that it may not be perfect AND assuming that the users are committed to the cause and therefore more interested in being constructive and part of the improvements project (than in carping from the side-lines) - rather than trying to make the work look like that of someone who has given fault-less service for decades and enjoyed many commensurate promotions, Mr Major-General, sir? In short (referring back to the 'list of options', above, top), there's no need to "give up" (and I can't see you allowing yourself to do-so anyway) but perhaps grant yourself permission to accept a result (slightly) less than 100%! (and yes, maybe that is the "lazy" coming-out, but there's also a sense of YAGNI when investing significant effort into infrequently used resources/viewed web-pages - maybe apply the 80:20 'rule'?) Meantime, I'm off to find my boxed-set and play some CDs of 'silly songs' while I work... -- Regards, =dn From rosuav at gmail.com Sun Aug 21 00:25:23 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 21 Aug 2022 14:25:23 +1000 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: <3690bf42-8c34-58b2-1c5b-d38eeeb02bc4@DancesWithMice.info> References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> <7be37315-9adc-4aac-4598-be122a9c1ca6@DancesWithMice.info> <27f23c7c-d167-1d0c-0270-9abe21bee9af@DancesWithMice.info> <3690bf42-8c34-58b2-1c5b-d38eeeb02bc4@DancesWithMice.info> Message-ID: On Sun, 21 Aug 2022 at 13:41, dn wrote: > > On 21/08/2022 13.00, Chris Angelico wrote: > > Well, I don't like headaches, but I do appreciate what the G&S Archive > > has given me over the years, so I'm taking this on as a means of > > giving back to the community. > > This point will be picked-up in the conclusion. NB in the same way that > you want to 'give back', so also do others - even if in minor ways or > 'when-relevant'! Very true. > >> In fact, depending upon frequency, making the changes manually (and with > >> improved confidence in the result). > > > > Unfortunately the frequency is very high. > > Screechingly so? Like you're singing Three Little Maids? You don't want to hear me singing that.... although I do recall once singing Lady Ella's part at a Qwert, to gales of laughter. > > Yeah. I do a first pass to enumerate all domains that are ever linked > > to with http:// URLs, and then I have a script that goes through and > > checks to see if they redirect me to the same URL on the other > > protocol, or other ways of checking. So yes, the list of valid domains > > is part of the program's effective input. > > Wow! Having got that far, you have achieved data-validity. Is there a > need to perform a before-after check or diff? Yes, to ensure that nothing has changed that I *didn't* plan. The planned changes aren't the problem here, I can verify those elsewhere. > Perhaps start making the one-for-one replacements without further > anxiety. As long as there's no silly-mistake, eg failing to remove an > opening or closing angle-bracket; isn't that about all the checking needed? > (for this category of updates) Maybe, but probably not. > BTW in talk of "line-number", you will have realised the need to re-run > the identification of such after each of these steps - in case the 'new > stuff' relating to earlier steps (assuming above became also a temporal > sequence) is shorter/longer than the current HTML. Yep, that's not usually a problem. > >>> And there'll be other fixes to be done too. So it's a bit complicated, > >>> and no simple solution is really sufficient. At the very very least, I > >>> *need* to properly parse with BS4; the only question is whether I > >>> reconstruct from the parse tree, or go back to the raw file and try to > >>> edit it there. > >> > >> At least the diffs would give you something to work-from, but it's a bit > >> like git-diffs claiming a 'change' when the only difference is that my > >> IDE strips blanks from the ends of code-lines, or some-such silliness. > > > > Right; and the reconstructed version has a LOT of those unnecessary > > changes. I'm seeing a lot of changes to whitespace. The only problem > > is whether I can be confident that none of those changes could ever > > matter. > > "White-space" has lesser-meaning in HTML - this is NOT Python! In HTML > if I write "HTML file" (with two spaces), the browser will shorten the > display to a single space (hence some uses of   - non-broken > space). Similarly, if attempt to use "\n" to start a new line of text... Yes, whitespace has less meaning... except when it doesn't. https://developer.mozilla.org/en-US/docs/Web/CSS/white-space Text can become preformatted by the styling, and there could be nothing whatsoever in the HTML page that shows this. I think most of the HTML files in this site have been created by a WYSIWYG editor, partly because of clues like a single bold space in a non-bold sequence of text, and the styles aren't consistent everywhere. Given that poetry comes up a lot on this site, I wouldn't put it past the editor to have set a whitespace rule on something. But I'm probably going to just ignore that and hope that any such errors are less significant than the current set of broken links. > Is there a danger of 'chasing your own tail', ie seeking a solution to a > problem which really doesn't matter (particularly if we add the phrase: > at the user-level)? Unfortunately not. I now know of three categories of change that, in theory, shouldn't affect anything: whitespace, order of attributes ("" becoming ""), and self-closing tags. Whitespace probably won't matter, until it does. Order of attributes is absolutely fine.... unless one of them is miswritten and now we've lost a lot of information about how it ought to have been written. And self-closing tags are probably insignificant, but I don't know how browsers handle things like "

...

" - and I wouldn't know whether the original intention was for the second one to be a self-closing empty paragraph, or a miswritten closing tag. It's easy to say that these changes have no effect on well-formed HTML. It's less easy to know what browsers will do with ill-formed HTML. > Agree with "properly parse". Question was an apparent dedication to BS4 > when there are other tools. Just checking you aren't wearing that type > of 'blinders'. > (didn't think so, but...) No, but there's also always the option of some tool that I've never heard of! The single most obvious *to me* might not be the best overall. > >> Is Selenium worthy of consideration? > > > > Yes..... but I don't know how much it would buy me. It certainly has > > no options for editing back the original HTML, so all it would do is > > the parsing side of things (which is already working fine). > > In which case, no gain. > (I probably use it more than BS - but because it is useful to 'test' > web-pages, GUI behavior, etc) Yeah, that's what it shines at. > A better 'diff' would not look at the HTML, but compare the web-page's > before and after 'appearances'! > (after all, the link-checker has already figured-out the 'behind the > scenes' part) In theory, but what constitutes a reasonable change to the appearance? > > Yeah, and the fundamental problem with the MD conversion is time - > > it's a big manual process. I want to be able to do that progressively > > over time, but get the basic stuff sorted out much sooner. Ideally, it > > should be possible to fix all the autofixable links this week and get > > that sorted out, but converting pages to Markdown will happen slowly > > over the next few years. > > Not something I've ever needed to consider. Are there no tools for this? Yes and no. Part of the reason for doing it manually is that you need to decide what parts go in the individual pages (the Markdown files) and what belongs in the layout file (a single HTML file). Deduplication requires a measure of intelligence, especially when it's not 100% identical on different pages, so you have to figure out what parameterization is worth doing. > Warning: more 'normal people' know something of HTML, than do of > Markdown. In fact, whereas many people from outside of IT attend our > HTML5 courses (implicit disclaimer!), I'll suggest that if a person > knows Markdown (s)he is at least 85% likely to be in IT. Maybe, but it's also far FAR easier to learn Markdown. Here's a web site that is managed by a digital artist, most definitely not an IT person: https://devicatoutlet.com/ I helped her get it all set up, and she edits the Markdown files herself. (And commits and pushes to GitHub so it can be hosted on GH Pages, which disproves any myths that git is impossible for non-programmers to use.) > Another ([in]famous dn off-the-wall) question: have you considered > 'crowd-sourcing' the project? There are bound to be members who > particularly favor one operetta or song. If the project were moved to a > wiki or software like WordPress, would individual members be prepared to > copy-paste from 'the old' to 'the new', checking links and copy-pasting > the URL, etc, as they go? I'd rather move into Markdown than either MediaWiki or Wordpress, partly because PHP sucks, and partly because it's nearly impossible to maintain URLs when you do a migration like that. (In the case of the Markdown files, I do have a special step in the build system to allow me to force the output file name, but I almost never need it - only for a few special cases where it's ".htm" instead of ".html" or something.) Breaking URLs is a major problem. But once the Markdown system is in place, I absolutely would welcome people contributing changes in that way. That would end up being part of the long-term job though. > NB I recall (somewhere) a claim (about "distraction" and "consumption" > cf "creativity") that if all Americans were to stop watching > ("consuming") TV for a single weekend, it would release sufficient time > to "create" Wikipedia in its entirety. Yes, because we absolutely NEED a third of a billion lazy people trying to write content while wanting to just flake :) > This is the opposite of the mantra I (over-)frequently recite to > trainees (particularly those who have just learned JS and think they can > now 'take-over the world'...) "just because we can do it, doesn't make > it a good idea"! But taking over the world is so tempting....... > Similarly, is it possible that you are attempting to be "the very model > of a modern Major-General", whilst the service required may be more on > the line about being "very good at [la, la, la; something or other - he > can't remember the words)] and calculus" (IT not invented back in the > days of the Pirates of Penzance)? > > Looking at the site, (unkindly-speaking) it is reminiscent of > AOL/GeoCities days. Which is not necessarily 'bad', but is indicative of > a membership who care less about appearances and more about 'the > business' of the group. I think it's more a result of design-by-committee, or rather, design-by-whoever-feels-like-doing-this (a Charlieocracy of sorts). For now, I'm maintaining most of that, but hey, if someone looks at the Markdown version and wants to make improvements, they'd only have to change the layout file! > In short (referring back to the 'list of options', above, top), there's > no need to "give up" (and I can't see you allowing yourself to do-so > anyway) but perhaps grant yourself permission to accept a result > (slightly) less than 100%! I'm absolutely not giving up, and yes, I will accept a result below 100%. What I would like to ensure, if possible, is that I do not create additional problems while fixing these. > (and yes, maybe that is the "lazy" coming-out, but there's also a sense > of YAGNI when investing significant effort into infrequently used > resources/viewed web-pages - maybe apply the 80:20 'rule'?) > > > Meantime, I'm off to find my boxed-set and play some CDs of 'silly > songs' while I work... Enjoy! ChrisA From barry at barrys-emacs.org Sun Aug 21 03:25:58 2022 From: barry at barrys-emacs.org (Barry) Date: Sun, 21 Aug 2022 08:25:58 +0100 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: Message-ID: > On 19 Aug 2022, at 22:04, Chris Angelico wrote: > > ?On Sat, 20 Aug 2022 at 05:12, Barry wrote: >> >> >> >>>> On 19 Aug 2022, at 19:33, Chris Angelico wrote: >>> >>> ?What's the best way to precisely reconstruct an HTML file after >>> parsing it with BeautifulSoup? >> >> I recall that in bs4 it parses into an object tree and loses the detail of the input. >> I recently ported from very old bs to bs4 and hit the same issue. >> So no it will not output the same as went in. >> >> If you can trust the input to be parsed as xml, meaning all the rules of closing >> tags have been followed. Then I think you can parse and unparse thru xml to >> do what you want. >> > > > Yeah, no I can't, this is HTML 4 with a ton of inconsistencies. Oh > well. Thanks for trying, anyhow. > > So I'm left with a few options: > > 1) Give up on validation, give up on verification, and just run this > thing on the production site with my fingers crossed Can you build a beta site with original intack? Also wonder if using selenium to walk the site may work as a verification step? I cannot recall if you can get an image of the browser window to do image compares with to look for rendering differences. From my one task using bs4 I did not see it produce any bad results. In my case the problems where in the code that built on bs1 using bad assumptions. > 2) Instead of doing an intelligent reconstruction, just str.replace() > one URL with another within the file > 3) Split the file into lines, find the Nth line (elem.sourceline) and > str.replace that line only > 4) Attempt to use elem.sourceline and elem.sourcepos to find the start > of the tag, manually find the end, and replace one tag with the > reconstructed form. > > I'm inclined to the first option, honestly. The others just seem like > hard work, and I became a programmer so I could be lazy... > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Sun Aug 21 04:09:32 2022 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 21 Aug 2022 18:09:32 +1000 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: Message-ID: On Sun, 21 Aug 2022 at 17:26, Barry wrote: > > > > > On 19 Aug 2022, at 22:04, Chris Angelico wrote: > > > > ?On Sat, 20 Aug 2022 at 05:12, Barry wrote: > >> > >> > >> > >>>> On 19 Aug 2022, at 19:33, Chris Angelico wrote: > >>> > >>> ?What's the best way to precisely reconstruct an HTML file after > >>> parsing it with BeautifulSoup? > >> > >> I recall that in bs4 it parses into an object tree and loses the detail of the input. > >> I recently ported from very old bs to bs4 and hit the same issue. > >> So no it will not output the same as went in. > >> > >> If you can trust the input to be parsed as xml, meaning all the rules of closing > >> tags have been followed. Then I think you can parse and unparse thru xml to > >> do what you want. > >> > > > > > > Yeah, no I can't, this is HTML 4 with a ton of inconsistencies. Oh > > well. Thanks for trying, anyhow. > > > > So I'm left with a few options: > > > > 1) Give up on validation, give up on verification, and just run this > > thing on the production site with my fingers crossed > > Can you build a beta site with original intack? In a naive way, a full copy would be quite a few gigabytes. I could cut that down a good bit by taking only HTML files and the things they reference, but then we run into the same problem of broken links, which is what we're here to solve in the first place. But I would certainly not want to run two copies of the site and then manually compare. > Also wonder if using selenium to walk the site may work as a verification step? > I cannot recall if you can get an image of the browser window to do image compares with to look for rendering differences. Image recognition won't necessarily even be valid; some of the changes will have visual consequences (eg a broken image reference now becoming correct), and as soon as that happens, the whole document can reflow. > From my one task using bs4 I did not see it produce any bad results. > In my case the problems where in the code that built on bs1 using bad assumptions. Did that get run on perfect HTML, or on messy real-world stuff that uses quirks mode? ChrisA From barry at barrys-emacs.org Sun Aug 21 10:48:43 2022 From: barry at barrys-emacs.org (Barry) Date: Sun, 21 Aug 2022 15:48:43 +0100 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: Message-ID: > On 21 Aug 2022, at 09:12, Chris Angelico wrote: > > ?On Sun, 21 Aug 2022 at 17:26, Barry wrote: >> >> >> >>>> On 19 Aug 2022, at 22:04, Chris Angelico wrote: >>> >>> ?On Sat, 20 Aug 2022 at 05:12, Barry wrote: >>>> >>>> >>>> >>>>>> On 19 Aug 2022, at 19:33, Chris Angelico wrote: >>>>> >>>>> ?What's the best way to precisely reconstruct an HTML file after >>>>> parsing it with BeautifulSoup? >>>> >>>> I recall that in bs4 it parses into an object tree and loses the detail of the input. >>>> I recently ported from very old bs to bs4 and hit the same issue. >>>> So no it will not output the same as went in. >>>> >>>> If you can trust the input to be parsed as xml, meaning all the rules of closing >>>> tags have been followed. Then I think you can parse and unparse thru xml to >>>> do what you want. >>>> >>> >>> >>> Yeah, no I can't, this is HTML 4 with a ton of inconsistencies. Oh >>> well. Thanks for trying, anyhow. >>> >>> So I'm left with a few options: >>> >>> 1) Give up on validation, give up on verification, and just run this >>> thing on the production site with my fingers crossed >> >> Can you build a beta site with original intack? > > In a naive way, a full copy would be quite a few gigabytes. I could > cut that down a good bit by taking only HTML files and the things they > reference, but then we run into the same problem of broken links, > which is what we're here to solve in the first place. > > But I would certainly not want to run two copies of the site and then > manually compare. > >> Also wonder if using selenium to walk the site may work as a verification step? >> I cannot recall if you can get an image of the browser window to do image compares with to look for rendering differences. > > Image recognition won't necessarily even be valid; some of the changes > will have visual consequences (eg a broken image reference now > becoming correct), and as soon as that happens, the whole document can > reflow. > >> From my one task using bs4 I did not see it produce any bad results. >> In my case the problems where in the code that built on bs1 using bad assumptions. > > Did that get run on perfect HTML, or on messy real-world stuff that > uses quirks mode? I small number of messy html pages. Barry > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list From hjp-python at hjp.at Sun Aug 21 14:19:07 2022 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 21 Aug 2022 20:19:07 +0200 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: <20220821181907.2wve4ywkilgkosh6@hjp.at> On 2022-08-20 21:51:41 -0000, Jon Ribbens via Python-list wrote: > On 2022-08-20, Stefan Ram wrote: > > Jon Ribbens writes: > >>... or you could avoid all that faff and just do re.sub()? > > source = '
' > > > > # Use Python to change the source, keeping the order of attributes. > > > > result = re.sub( r'href\s*=\s*"http"', r'href="https"', source ) > > result = re.sub( r"href\s*=\s*'http'", r"href='https'", result ) Depending on the content of the site, this might replace some stuff which is not a link. > You could go a bit harder with the regexp of course, e.g.: > > result = re.sub( > r"""(<\s*a\s+[^>]*href\s*=\s*)(['"])\s*OLD\s*\2""", This will fail on: The problem can be solved with regular expressions (and given the constraints I think I would prefer that to using Beautiful Soup), but getting the regexps right is not trivial, at least in the general case. It may become a lot easier if you know that certain conventions were followed (e.g. that ">" was always written as ">") or it may become even harder when the files contain errors. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From simone.zambonardi at gmail.com Sun Aug 21 05:11:38 2022 From: simone.zambonardi at gmail.com (simone zambonardi) Date: Sun, 21 Aug 2022 02:11:38 -0700 (PDT) Subject: subprocess.popen how wait complete open process Message-ID: <7c8281be-38d1-45e4-954d-58ffb90ba220n@googlegroups.com> Hi, I am running a program with the punishment subrocess.Popen(...) what I should do is to stop the script until the launched program is fully open. How can I do this? I used a time.sleep() function but I think there are other ways. Thanks From jon+usenet at unequivocal.eu Sun Aug 21 07:24:16 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Sun, 21 Aug 2022 11:24:16 -0000 (UTC) Subject: Mutating an HTML file with BeautifulSoup References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: On 2022-08-21, Chris Angelico wrote: > On Sun, 21 Aug 2022 at 09:31, Jon Ribbens via Python-list > wrote: >> On 2022-08-20, Chris Angelico wrote: >> > On Sun, 21 Aug 2022 at 03:27, Stefan Ram wrote: >> >> 2QdxY4RzWzUUiLuE at potatochowder.com writes: >> >> >textual representations. That way, the following two elements are the >> >> >same (and similar with a collection of sub-elements in a different order >> >> >in another document): >> >> >> >> The /elements/ differ. They have the /same/ infoset. >> > >> > That's the bit that's hard to prove. >> > >> >> The OP could edit the files with regexps to create a new version. >> > >> > To you and Jon, who also suggested this: how would that be beneficial? >> > With Beautiful Soup, I have the line number and position within the >> > line where the tag starts; what does a regex give me that I don't have >> > that way? >> >> You mean you could use BeautifulSoup to read the file and identify the >> bits you want to change by line number and offset, and then you could >> use that data to try and update the file, hoping like hell that your >> definition of "line" and "offset" are identical to BeautifulSoup's >> and that you don't mess up later changes when you do earlier ones (you >> could do them in reverse order of line and offset I suppose) and >> probably resorting to regexps anyway in order to find the part of the >> tag you want to change ... >> >> ... or you could avoid all that faff and just do re.sub()? > > Stefan answered in part, but I'll add that it is far FAR easier to do > the analysis with BS4 than regular expressions. I'm not sure what > "hoping like hell" is supposed to mean here, since the line and offset > have been 100% accurate in my experience; Given the string: b"\n \r\r\n\v\n\r\xed\xa0\x80\xed\xbc\x9f\xcc\x80e\xc3\xa8?" what is the line number and offset of the question mark - and does BeautifulSoup agree with your answer? Does the answer to that second question change depending on what parser you tell BeautifulSoup to use? (If your answer is "if the input contains \xed\xa0\x80\xed\xbc\x9f then I am happy with the program throwing an exception" then feel free to remove that substring from the question.) > the only part I'm unsure about is where the _end_ of the tag is (and > maybe there's a way I can use BS4 again to get that??). There doesn't seem to be. More to the point, there doesn't seem to be a way to find out where the *attributes* are, so as I said you'll most likely end up using regexps anyway. From pbryan at anode.ca Sun Aug 21 15:48:07 2022 From: pbryan at anode.ca (Paul Bryan) Date: Sun, 21 Aug 2022 12:48:07 -0700 Subject: subprocess.popen how wait complete open process In-Reply-To: <7c8281be-38d1-45e4-954d-58ffb90ba220n@googlegroups.com> References: <7c8281be-38d1-45e4-954d-58ffb90ba220n@googlegroups.com> Message-ID: <98631bbb5e1c5c934bcc2d6e6af4005e5c87cd04.camel@anode.ca> Sometimes, launching subprocesses can seem like punishment. I don't think there is a standard cross-platform way to know when a launched asynchronous process is "fully open" (i.e. fully initialized, accepting user input). On Sun, 2022-08-21 at 02:11 -0700, simone zambonardi wrote: > Hi, I am running a program with the punishment subrocess.Popen(...) > what I should do is to stop the script until the launched program is > fully open. How can I do this? I used a time.sleep() function but I > think there are other ways. Thanks From rosuav at gmail.com Sun Aug 21 17:05:08 2022 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 22 Aug 2022 07:05:08 +1000 Subject: subprocess.popen how wait complete open process In-Reply-To: <7c8281be-38d1-45e4-954d-58ffb90ba220n@googlegroups.com> References: <7c8281be-38d1-45e4-954d-58ffb90ba220n@googlegroups.com> Message-ID: On Mon, 22 Aug 2022 at 05:39, simone zambonardi wrote: > > Hi, I am running a program with the punishment subrocess.Popen(...) what I should do is to stop the script until the launched program is fully open. How can I do this? I used a time.sleep() function but I think there are other ways. Thanks > First you have to define "fully open". How would you know? ChrisA From rosuav at gmail.com Sun Aug 21 17:19:33 2022 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 22 Aug 2022 07:19:33 +1000 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: On Mon, 22 Aug 2022 at 05:43, Jon Ribbens via Python-list wrote: > > On 2022-08-21, Chris Angelico wrote: > > On Sun, 21 Aug 2022 at 09:31, Jon Ribbens via Python-list > > wrote: > >> On 2022-08-20, Chris Angelico wrote: > >> > On Sun, 21 Aug 2022 at 03:27, Stefan Ram wrote: > >> >> 2QdxY4RzWzUUiLuE at potatochowder.com writes: > >> >> >textual representations. That way, the following two elements are the > >> >> >same (and similar with a collection of sub-elements in a different order > >> >> >in another document): > >> >> > >> >> The /elements/ differ. They have the /same/ infoset. > >> > > >> > That's the bit that's hard to prove. > >> > > >> >> The OP could edit the files with regexps to create a new version. > >> > > >> > To you and Jon, who also suggested this: how would that be beneficial? > >> > With Beautiful Soup, I have the line number and position within the > >> > line where the tag starts; what does a regex give me that I don't have > >> > that way? > >> > >> You mean you could use BeautifulSoup to read the file and identify the > >> bits you want to change by line number and offset, and then you could > >> use that data to try and update the file, hoping like hell that your > >> definition of "line" and "offset" are identical to BeautifulSoup's > >> and that you don't mess up later changes when you do earlier ones (you > >> could do them in reverse order of line and offset I suppose) and > >> probably resorting to regexps anyway in order to find the part of the > >> tag you want to change ... > >> > >> ... or you could avoid all that faff and just do re.sub()? > > > > Stefan answered in part, but I'll add that it is far FAR easier to do > > the analysis with BS4 than regular expressions. I'm not sure what > > "hoping like hell" is supposed to mean here, since the line and offset > > have been 100% accurate in my experience; > > Given the string: > > b"\n \r\r\n\v\n\r\xed\xa0\x80\xed\xbc\x9f\xcc\x80e\xc3\xa8?" > > what is the line number and offset of the question mark - and does > BeautifulSoup agree with your answer? Does the answer to that second > question change depending on what parser you tell BeautifulSoup to use? I'm not sure, because I don't know how to ask BS4 about the location of a question mark. But I replaced that with a tag, and: >>> raw = b"\n \r\r\n\v\n\r\xed\xa0\x80\xed\xbc\x9f\xcc\x80e\xc3\xa8" >>> from bs4 import BeautifulSoup >>> soup = BeautifulSoup(raw, "html.parser") >>> soup.body.sourceline 4 >>> soup.body.sourcepos 12 >>> raw.split(b"\n")[3] b'\r\xed\xa0\x80\xed\xbc\x9f\xcc\x80e\xc3\xa8' >>> raw.split(b"\n")[3][12:] b'' So, yes, it seems to be correct. (Slightly odd in that the sourceline is 1-based but the sourcepos is 0-based, but that is indeed the case, as confirmed with a much more straight-forward string.) And yes, it depends on the parser, but I'm using html.parser and it's fine. > (If your answer is "if the input contains \xed\xa0\x80\xed\xbc\x9f then > I am happy with the program throwing an exception" then feel free to > remove that substring from the question.) Malformed UTF-8 doesn't seem to be a problem. Every file here seems to be either UTF-8 or ISO-8859, and in the latter case, I'm assuming 8859-1. So I would probably just let this one go through as 8859-1. > > the only part I'm unsure about is where the _end_ of the tag is (and > > maybe there's a way I can use BS4 again to get that??). > > There doesn't seem to be. More to the point, there doesn't seem to be > a way to find out where the *attributes* are, so as I said you'll most > likely end up using regexps anyway. I'm okay with replacing an entire tag that needs to be changed. Especially if I can replace just the opening tag, not the contents and closing tag. And in fact, I may just do that part by scanning for an unencoded greater-than, on the assumptions that (a) BS4 will correctly encode any greater-thans in attributes, and (b) if there's a mis-encoded one in the input, the diff will be small enough to eyeball, and a human should easily notice that the text has been massively expanded and duplicated. ChrisA From buck.2019 at gmail.com Sun Aug 21 20:04:41 2022 From: buck.2019 at gmail.com (Buck Evan) Date: Sun, 21 Aug 2022 19:04:41 -0500 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: Message-ID: I've had much success doing round trips through the lxml.html parser. https://lxml.de/lxmlhtml.html I ditched bs for lxml long ago and never regretted it. If you find that you have a bunch of invalid html that lxml inadvertently "fixes", I would recommend adding a stutter-step to your project: perform a noop roundtrip thru lxml on all files. I'd then analyze any diff by progressively excluding changes via `grep -vP`. Unless I'm mistaken, all such changes should fall into no more than a dozen groups. On Fri, Aug 19, 2022, 1:34 PM Chris Angelico wrote: > What's the best way to precisely reconstruct an HTML file after > parsing it with BeautifulSoup? > > Using the Alice example from the BS4 docs: > > >>> html_doc = """The Dormouse's story > >

The Dormouse's story

> >

Once upon a time there were three little sisters; and > their names were > Elsie, > Lacie and > Tillie; > and they lived at the bottom of a well.

> >

...

> """ > >>> print(soup) > The Dormouse's story > >

The Dormouse's story

>

Once upon a time there were three little sisters; and > their names were > Elsie, > Lacie and > Tillie; > and they lived at the bottom of a well.

>

...

> > >>> > > Note two distinct changes: firstly, whitespace has been removed, and > secondly, attributes are reordered (I think alphabetically). There are > other canonicalizations being done, too. > > I'm trying to make some automated changes to a huge number of HTML > files, with minimal diffs so they're easy to validate. That means that > spurious changes like these are very much unwanted. Is there a way to > get BS4 to reconstruct the original precisely? > > The mutation itself would be things like finding an anchor tag and > changing its href attribute. Fairly simple changes, but might alter > the length of the file (eg changing "http://example.com/" into > "https://example.com/"). I'd like to do them intelligently rather than > falling back on element.sourceline and element.sourcepos, but worst > case, that's what I'll have to do (which would be fiddly). > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Sun Aug 21 23:30:58 2022 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 22 Aug 2022 13:30:58 +1000 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: Message-ID: On Mon, 22 Aug 2022 at 10:04, Buck Evan wrote: > > I've had much success doing round trips through the lxml.html parser. > > https://lxml.de/lxmlhtml.html > > I ditched bs for lxml long ago and never regretted it. > > If you find that you have a bunch of invalid html that lxml inadvertently "fixes", I would recommend adding a stutter-step to your project: perform a noop roundtrip thru lxml on all files. I'd then analyze any diff by progressively excluding changes via `grep -vP`. > Unless I'm mistaken, all such changes should fall into no more than a dozen groups. > Will this round-trip mutate every single file and reorder the tag attributes? Because I really don't want to manually eyeball all those changes. ChrisA From drsalists at gmail.com Sun Aug 21 23:41:43 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 21 Aug 2022 20:41:43 -0700 Subject: subprocess.popen how wait complete open process In-Reply-To: References: <7c8281be-38d1-45e4-954d-58ffb90ba220n@googlegroups.com> Message-ID: On Sun, Aug 21, 2022 at 2:05 PM Chris Angelico wrote: > On Mon, 22 Aug 2022 at 05:39, simone zambonardi > wrote: > > > > Hi, I am running a program with the punishment subrocess.Popen(...) what > I should do is to stop the script until the launched program is fully open. > How can I do this? I used a time.sleep() function but I think there are > other ways. Thanks > > > > First you have to define "fully open". How would you know? > If you're on X11, you could conceivably use: xwininfo -tree -root From rosuav at gmail.com Mon Aug 22 00:01:01 2022 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 22 Aug 2022 14:01:01 +1000 Subject: subprocess.popen how wait complete open process In-Reply-To: References: <7c8281be-38d1-45e4-954d-58ffb90ba220n@googlegroups.com> Message-ID: On Mon, 22 Aug 2022 at 13:41, Dan Stromberg wrote: > > > > On Sun, Aug 21, 2022 at 2:05 PM Chris Angelico wrote: >> >> On Mon, 22 Aug 2022 at 05:39, simone zambonardi >> wrote: >> > >> > Hi, I am running a program with the punishment subrocess.Popen(...) what I should do is to stop the script until the launched program is fully open. How can I do this? I used a time.sleep() function but I think there are other ways. Thanks >> > >> >> First you have to define "fully open". How would you know? > > > If you're on X11, you could conceivably use: > xwininfo -tree -root > That's only one possible definition: it has some sort of window. But to wait until a program is "fully open", you might have to wait past a splash screen until it has its actual application window. Or maybe even then, it's not ready for operation. Only the OP can know what defines "fully open". ChrisA From __peter__ at web.de Mon Aug 22 02:30:00 2022 From: __peter__ at web.de (Peter Otten) Date: Mon, 22 Aug 2022 08:30:00 +0200 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: Message-ID: <8b10c2c2-7c64-3dcb-6b0b-7aa2751aa625@web.de> On 22/08/2022 05:30, Chris Angelico wrote: > On Mon, 22 Aug 2022 at 10:04, Buck Evan wrote: >> >> I've had much success doing round trips through the lxml.html parser. >> >> https://lxml.de/lxmlhtml.html >> >> I ditched bs for lxml long ago and never regretted it. >> >> If you find that you have a bunch of invalid html that lxml inadvertently "fixes", I would recommend adding a stutter-step to your project: perform a noop roundtrip thru lxml on all files. I'd then analyze any diff by progressively excluding changes via `grep -vP`. >> Unless I'm mistaken, all such changes should fall into no more than a dozen groups. >> > > Will this round-trip mutate every single file and reorder the tag > attributes? Because I really don't want to manually eyeball all those > changes. Most certainly not. Reordering is a bs4 feature that is governed by a formatter. You can easily prevent that attributes are reorderd: >>> import bs4 >>> soup = bs4.BeautifulSoup("""
""") >>> soup
>>> class Formatter(bs4.formatter.HTMLFormatter): def attributes(self, tag): return [] if tag.attrs is None else list(tag.attrs.items()) >>> soup.decode(formatter=Formatter()) '
' Blank space is probably removed by the underlying html parser. It might be possible to make bs4 instantiate the lxml.html.HTMLParser with remove_blank_text=False, but I didn't try hard enough ;) That said, for my humble html scraping needs I have ditched bs4 in favor of lxml and its xpath capabilities. From eryksun at gmail.com Mon Aug 22 09:47:06 2022 From: eryksun at gmail.com (Eryk Sun) Date: Mon, 22 Aug 2022 08:47:06 -0500 Subject: subprocess.popen how wait complete open process In-Reply-To: <7c8281be-38d1-45e4-954d-58ffb90ba220n@googlegroups.com> References: <7c8281be-38d1-45e4-954d-58ffb90ba220n@googlegroups.com> Message-ID: On 8/21/22, simone zambonardi wrote: > Hi, I am running a program with the punishment subrocess.Popen(...) what I > should do is to stop the script until the launched program is fully open. > How can I do this? I used a time.sleep() function but I think there are > other ways. Thanks In Windows, WaitForInputIdle() waits until a thread in a process creates one or more windows and its message loop goes idle. Usually this is the main UI thread. Console processes are not supported. For example: import ctypes import subprocess user32 = ctypes.WinDLL('user32', use_last_error=True) INFINITE = 0xFFFF_FFFF WAIT_FAILED = 0xFFFF_FFFF WAIT_TIMEOUT = 0x0000_0102 # Waiting on a console process fails with ERROR_NOT_GUI_PROCESS. # This case be handled in other ways, depending on the need. ERROR_NOT_GUI_PROCESS = 1471 user32.WaitForInputIdle.restype = ctypes.c_ulong user32.WaitForInputIdle.argtypes = (ctypes.c_void_p, ctypes.c_ulong) def wait_for_input_idle(proc, timeout=None): if isinstance(proc, subprocess.Popen): handle = int(proc._handle) args = p.args else: handle = int(proc) args = '' if timeout is None: timeout_ms = INFINITE elif timeout < 0: raise ValueError('timeout cannot be negative') else: timeout_ms = int(timeout * 1000) if timeout_ms >= INFINITE: raise OverflowError('timeout is too large') status = user32.WaitForInputIdle(handle, timeout_ms) if status == WAIT_FAILED: raise ctypes.WinError(ctypes.get_last_error()) elif status == WAIT_TIMEOUT: raise subprocess.TimeoutExpired(args, timeout) assert status == 0 return if __name__ == '__main__': import time t0 = time.time() p = subprocess.Popen(['pythonw.exe', '-m', 'idlelib']) try: wait_for_input_idle(p, 5) except: p.terminate() raise wait_time = time.time() - t0 print(f'wait time: {wait_time:.3f} seconds') try: p.wait(5) except subprocess.TimeoutExpired: p.terminate() From jon+usenet at unequivocal.eu Sun Aug 21 20:09:01 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Mon, 22 Aug 2022 00:09:01 -0000 (UTC) Subject: Mutating an HTML file with BeautifulSoup References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> <20220821181907.2wve4ywkilgkosh6@hjp.at> Message-ID: On 2022-08-21, Peter J. Holzer wrote: > On 2022-08-20 21:51:41 -0000, Jon Ribbens via Python-list wrote: >> On 2022-08-20, Stefan Ram wrote: >> > Jon Ribbens writes: >> >>... or you could avoid all that faff and just do re.sub()? > >> > source = '' >> > >> > # Use Python to change the source, keeping the order of attributes. >> > >> > result = re.sub( r'href\s*=\s*"http"', r'href="https"', source ) >> > result = re.sub( r"href\s*=\s*'http'", r"href='https'", result ) > > Depending on the content of the site, this might replace some stuff > which is not a link. > >> You could go a bit harder with the regexp of course, e.g.: >> >> result = re.sub( >> r"""(<\s*a\s+[^>]*href\s*=\s*)(['"])\s*OLD\s*\2""", > > This will fail on: > I've seen *a lot* of bad/broken/weird HTML over the years, and I don't believe I've ever seen anyone do that. (Wrongly putting an 'alt' attribute on an 'a' element is very common, on the other hand ;-) ) > The problem can be solved with regular expressions (and given the > constraints I think I would prefer that to using Beautiful Soup), but > getting the regexps right is not trivial, at least in the general case. I would like to see the regular expression that could fully parse general HTML... From jon+usenet at unequivocal.eu Sun Aug 21 20:45:56 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Mon, 22 Aug 2022 00:45:56 -0000 (UTC) Subject: Mutating an HTML file with BeautifulSoup References: <04D12A76-92D8-4584-AE6E-AD3072E438EE@barrys-emacs.org> Message-ID: On 2022-08-21, Chris Angelico wrote: > On Mon, 22 Aug 2022 at 05:43, Jon Ribbens via Python-list > wrote: >> On 2022-08-21, Chris Angelico wrote: >> > On Sun, 21 Aug 2022 at 09:31, Jon Ribbens via Python-list >> > wrote: >> >> On 2022-08-20, Chris Angelico wrote: >> >> > On Sun, 21 Aug 2022 at 03:27, Stefan Ram wrote: >> >> >> 2QdxY4RzWzUUiLuE at potatochowder.com writes: >> >> >> >textual representations. That way, the following two elements are the >> >> >> >same (and similar with a collection of sub-elements in a different order >> >> >> >in another document): >> >> >> >> >> >> The /elements/ differ. They have the /same/ infoset. >> >> > >> >> > That's the bit that's hard to prove. >> >> > >> >> >> The OP could edit the files with regexps to create a new version. >> >> > >> >> > To you and Jon, who also suggested this: how would that be beneficial? >> >> > With Beautiful Soup, I have the line number and position within the >> >> > line where the tag starts; what does a regex give me that I don't have >> >> > that way? >> >> >> >> You mean you could use BeautifulSoup to read the file and identify the >> >> bits you want to change by line number and offset, and then you could >> >> use that data to try and update the file, hoping like hell that your >> >> definition of "line" and "offset" are identical to BeautifulSoup's >> >> and that you don't mess up later changes when you do earlier ones (you >> >> could do them in reverse order of line and offset I suppose) and >> >> probably resorting to regexps anyway in order to find the part of the >> >> tag you want to change ... >> >> >> >> ... or you could avoid all that faff and just do re.sub()? >> > >> > Stefan answered in part, but I'll add that it is far FAR easier to do >> > the analysis with BS4 than regular expressions. I'm not sure what >> > "hoping like hell" is supposed to mean here, since the line and offset >> > have been 100% accurate in my experience; >> >> Given the string: >> >> b"\n \r\r\n\v\n\r\xed\xa0\x80\xed\xbc\x9f\xcc\x80e\xc3\xa8?" >> >> what is the line number and offset of the question mark - and does >> BeautifulSoup agree with your answer? Does the answer to that second >> question change depending on what parser you tell BeautifulSoup to use? > > I'm not sure, because I don't know how to ask BS4 about the location > of a question mark. But I replaced that with a tag, and: > >>>> raw = b"\n \r\r\n\v\n\r\xed\xa0\x80\xed\xbc\x9f\xcc\x80e\xc3\xa8" >>>> from bs4 import BeautifulSoup >>>> soup = BeautifulSoup(raw, "html.parser") >>>> soup.body.sourceline > 4 >>>> soup.body.sourcepos > 12 >>>> raw.split(b"\n")[3] > b'\r\xed\xa0\x80\xed\xbc\x9f\xcc\x80e\xc3\xa8' >>>> raw.split(b"\n")[3][12:] > b'' > > So, yes, it seems to be correct. (Slightly odd in that the sourceline > is 1-based but the sourcepos is 0-based, but that is indeed the case, > as confirmed with a much more straight-forward string.) > > And yes, it depends on the parser, but I'm using html.parser and it's fine. Hah, yes, it appears html.parser does an end-run about my lovely carefully crafted hard case by not even *trying* to work out what type of line endings the file uses and is just hard-coded to only recognise "\n" as a line ending. With the offset though, BeautifulSoup made an arbitrary decision to use ISO-8859-1 encoding and so when you chopped the bytestring at that offset it only worked because BeautifulSoup had happened to choose a 1-byte-per-character encoding. Ironically, *without* the "\xed\xa0\x80\xed\xbc\x9f" it wouldn't have worked. >> (If your answer is "if the input contains \xed\xa0\x80\xed\xbc\x9f then >> I am happy with the program throwing an exception" then feel free to >> remove that substring from the question.) > > Malformed UTF-8 doesn't seem to be a problem. Every file here seems to > be either UTF-8 or ISO-8859, and in the latter case, I'm assuming > 8859-1. So I would probably just let this one go through as 8859-1. It looks like BeautifulSoup is doing something like that, yes. Personally I would be nervous about some of my files being parsed as UTF-8 and some of them ISO-8859-1 (due to decoding errors rather than some of the files actually *being* ISO-8859-1 ;-) ) >> > the only part I'm unsure about is where the _end_ of the tag is (and >> > maybe there's a way I can use BS4 again to get that??). >> >> There doesn't seem to be. More to the point, there doesn't seem to be >> a way to find out where the *attributes* are, so as I said you'll most >> likely end up using regexps anyway. > > I'm okay with replacing an entire tag that needs to be changed. Oh, that seems like quite a big change to the original problem. > Especially if I can replace just the opening tag, not the contents and > closing tag. And in fact, I may just do that part by scanning for an > unencoded greater-than, on the assumptions that (a) BS4 will correctly > encode any greater-thans in attributes, But your input wasn't created by BeautifulSoup (was it?) > and (b) if there's a mis-encoded one in the input, the diff will be > small enough to eyeball, and a human should easily notice that the > text has been massively expanded and duplicated. I strongly suggest Stefan Ram's excellent suggestion that, regardless of how you *make* the change, you can use BeautifulSoup to do a pretty strong check that the changes effected are both (a) all the ones you intended and (b) none that you didn't intend. From monamlee00 at gmail.com Sun Aug 21 23:21:15 2022 From: monamlee00 at gmail.com (Mona Lee) Date: Sun, 21 Aug 2022 20:21:15 -0700 (PDT) Subject: Python scripts in .exe form In-Reply-To: References: <695CDEE2-3B30-42AC-8FD0-8642AB88D7A5@sbcglobal.net> <9bbeec64-b5ac-44fa-864c-2e7b8eb29a51n@googlegroups.com> Message-ID: I didn't create exe files they kind of just appeared I guess? Perhaps somewhere in the process of redownloading my python/visual studio? My situation is similar to this person's description that I found online https://stackoverflow.com/questions/62315149/why-are-my-python-packages-being-installed-to-this-strange-folder On Saturday, August 20, 2022 at 7:25:31 AM UTC-6, Jim Schwartz wrote: > What method did you use to create the exe file from your python scripts? If it was pyinstaller, then it puts the compiled versions of these python scripts in a windows temp folder when you run them. You?ll be able to get the scripts from there. > > Sent from my iPhone > > > On Aug 19, 2022, at 9:51 PM, Mona Lee wrote: > > > > ?I'm pretty new to Python, and I had to do some tinkering because I was running into issues with trying to download a package from PIP and must've caused some issues in my program that I don't know how to fix > > > > 1. It started when I was unable to update PIP to the newest version because of some "Unknown error" (VS Code error - unable to read file - (Unknown(FileSystemError) where I believe some file was not saved in the right location? > > > > 2. In my command line on VS code there used to be the prefix that looked something like "PS C:\Users\[name]>" but now it is "PS C:\Users\[name]\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts> > > > > From there I redownloaded my VS code but still have the 2) issue. > > > > also, my scripts are now in the .exe form that I cannot access because "it is either binary or in a unsupported text encoding" I've tried to extract it back into the .py form using pyinstxtractor and decompile-python3 but I can't successfully work these. > > > > 3. also wanted to mention that some of my old Python programs are missing. > > -- > > https://mail.python.org/mailman/listinfo/python-list From hjp-python at hjp.at Mon Aug 22 13:56:52 2022 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 22 Aug 2022 19:56:52 +0200 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: <20220821181907.2wve4ywkilgkosh6@hjp.at> Message-ID: <20220822175652.sldx55xybyhbc45r@hjp.at> On 2022-08-22 00:09:01 -0000, Jon Ribbens via Python-list wrote: > On 2022-08-21, Peter J. Holzer wrote: > > On 2022-08-20 21:51:41 -0000, Jon Ribbens via Python-list wrote: > >> result = re.sub( > >> r"""(<\s*a\s+[^>]*href\s*=\s*)(['"])\s*OLD\s*\2""", > > > > This will fail on: > > > > I've seen *a lot* of bad/broken/weird HTML over the years, and I don't > believe I've ever seen anyone do that. (Wrongly putting an 'alt' > attribute on an 'a' element is very common, on the other hand ;-) ) My bad. I meant title, not alt, of course. The unescaped > is completely standard conforming HTML, however (both HTML 4.01 strict and HTML 5). You almost never have to escape > - in fact I can't think of any case right now - and I generally don't (sometimes I do for symmetry with <, but that's an aesthetic choice, not a technical one). > > The problem can be solved with regular expressions (and given the > > constraints I think I would prefer that to using Beautiful Soup), but > > getting the regexps right is not trivial, at least in the general case. > > I would like to see the regular expression that could fully parse > general HTML... That depends on what you mean by "parse". If you mean "construct a DOM tree", you can't since regular expressions (in the mathematical sense, not what's implemented by some programming languages) by definition describe finite automata, and those don't support recursion. But if you mean "split into a sequence of tags and PCDATA's (and then each tag further into its attributes)", that's absolutely possible, and that's all that is needed here. I don't think I have ever implemented a complete solution (if only because stuff like is extremely rare), but I should have some Perl code lying around which worked on a wide variety of HTML. I just have to find it again ... hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From hjp-python at hjp.at Mon Aug 22 14:34:13 2022 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 22 Aug 2022 20:34:13 +0200 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: Message-ID: <20220822183413.hiqwyn4zd6veeqft@hjp.at> On 2022-08-22 00:45:56 -0000, Jon Ribbens via Python-list wrote: > With the offset though, BeautifulSoup made an arbitrary decision to > use ISO-8859-1 encoding and so when you chopped the bytestring at > that offset it only worked because BeautifulSoup had happened to > choose a 1-byte-per-character encoding. Ironically, *without* the > "\xed\xa0\x80\xed\xbc\x9f" it wouldn't have worked. Actually it would. The unit is bytes if you feed it with bytes, and characters if you feed it with str. So in any case you can use the offset on the data you fed to the parser. Maybe not what you expected, but seems quite useful for what Chris has in mind. (OTOH it seems that the html parser doesn't heed any tags, which seems less than ideal for more pedestrian purposes.) > > So I would probably just let this one go through as 8859-1. > > It looks like BeautifulSoup is doing something like that, yes. > Personally I would be nervous about some of my files being parsed > as UTF-8 and some of them ISO-8859-1 (due to decoding errors rather > than some of the files actually *being* ISO-8859-1 ;-) ) Since none of the syntactically meaningful characters have a code >= 0x80, you can parse HTML at the byte level if you know that it's encoded in a strict superset of ASCII (which all of the ISO-8859 family and UTF-8 are). Only if that's not true (e.g. if your files might be UTF-16 (or Shift-JIS or EUC, if I remember correctly) then you have to know the the character set. (By parsing I mean only "create a syntax tree". Obviously you have to know the encoding to know whether to display ?c3 bc? as ??? or ????.) hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From jon+usenet at unequivocal.eu Mon Aug 22 15:27:28 2022 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Mon, 22 Aug 2022 19:27:28 -0000 (UTC) Subject: Mutating an HTML file with BeautifulSoup References: <20220822183413.hiqwyn4zd6veeqft@hjp.at> Message-ID: On 2022-08-22, Peter J. Holzer wrote: > On 2022-08-22 00:45:56 -0000, Jon Ribbens via Python-list wrote: >> With the offset though, BeautifulSoup made an arbitrary decision to >> use ISO-8859-1 encoding and so when you chopped the bytestring at >> that offset it only worked because BeautifulSoup had happened to >> choose a 1-byte-per-character encoding. Ironically, *without* the >> "\xed\xa0\x80\xed\xbc\x9f" it wouldn't have worked. > > Actually it would. The unit is bytes if you feed it with bytes, and > characters if you feed it with str. No it isn't. If you give BeautifulSoup's 'html.parser' bytes as input, it first chooses an encoding and decodes the bytes before sending that output to html.parser, which is what provides the offset. So the offsets it gives are in characters, and you've no simple way of converting that back to byte offsets. > (OTOH it seems that the html parser doesn't heed any > tags, which seems less than ideal for more pedestrian purposes.) html.parser doesn't accept bytes as input, so it couldn't do anything with the encoding even if it knew it. BeautifulSoup's 'html.parser' however does look for and use (using a regexp, natch). >> It looks like BeautifulSoup is doing something like that, yes. >> Personally I would be nervous about some of my files being parsed >> as UTF-8 and some of them ISO-8859-1 (due to decoding errors rather >> than some of the files actually *being* ISO-8859-1 ;-) ) > > Since none of the syntactically meaningful characters have a code >= > 0x80, you can parse HTML at the byte level if you know that it's encoded > in a strict superset of ASCII (which all of the ISO-8859 family and > UTF-8 are). Only if that's not true (e.g. if your files might be UTF-16 > (or Shift-JIS or EUC, if I remember correctly) then you have to know > the the character set. > > (By parsing I mean only "create a syntax tree". Obviously you have to > know the encoding to know whether to display =ABc3 bc=BB as =AB=FC=BB or = >=AB=C3=BC=BB.) But the job here isn't to create a syntax tree. It's to change some of the content, which for all we know is not ASCII. From jorgconforte at gmail.com Tue Aug 23 10:58:48 2022 From: jorgconforte at gmail.com (Jorge Conrado Conforte Conforte) Date: Tue, 23 Aug 2022 11:58:48 -0300 Subject: xarry netcdf message Message-ID: Hi, I'm reading my netcdf data air.2m.mon.ltm.nc. I used the netcdf4 and I didn't have message when i read my data. But if I use the xarray I had this message: /home/conrado/.conda/envs/meuambi/lib/python3.8/site-packages/xarray/backends/plugins.py:61: RuntimeWarning: Engine 'cfgrib' loading failed: module 'cfgrib.messages' has no attribute 'DEFAULT_INDEXPATH' warnings.warn(f"Engine {name!r} loading failed:\n{ex}", RuntimeWarning) /home/conrado/.conda/envs/meuambi/lib/python3.8/site-packages/xarray/coding/times.py:673: SerializationWarning: Unable to decode time axis into full numpy.datetime64 objects, continuing using cftime.datetime objects instead, reason: dates out of range dtype = _decode_cf_datetime_dtype(data, units, calendar, self.use_cftime) /home/conrado/.conda/envs/meuambi/lib/python3.8/site-packages/xarray/core/indexing.py:423: SerializationWarning: Unable to decode time axis into full numpy.datetime64 objects, continuing using cftime.datetime objects instead, reason: dates out of range return np.asarray(array[self.key], dtype=None) What can I do to solve this message. Thanks, Conrado From hjp-python at hjp.at Tue Aug 23 16:46:35 2022 From: hjp-python at hjp.at (Peter J. Holzer) Date: Tue, 23 Aug 2022 22:46:35 +0200 Subject: Mutating an HTML file with BeautifulSoup In-Reply-To: References: <20220822183413.hiqwyn4zd6veeqft@hjp.at> Message-ID: <20220823204635.tq736zxcqpplcatr@hjp.at> On 2022-08-22 19:27:28 -0000, Jon Ribbens via Python-list wrote: > On 2022-08-22, Peter J. Holzer wrote: > > On 2022-08-22 00:45:56 -0000, Jon Ribbens via Python-list wrote: > >> With the offset though, BeautifulSoup made an arbitrary decision to > >> use ISO-8859-1 encoding and so when you chopped the bytestring at > >> that offset it only worked because BeautifulSoup had happened to > >> choose a 1-byte-per-character encoding. Ironically, *without* the > >> "\xed\xa0\x80\xed\xbc\x9f" it wouldn't have worked. > > > > Actually it would. The unit is bytes if you feed it with bytes, and > > characters if you feed it with str. > > No it isn't. If you give BeautifulSoup's 'html.parser' bytes as input, > it first chooses an encoding and decodes the bytes before sending that > output to html.parser, which is what provides the offset. So the offsets > it gives are in characters, and you've no simple way of converting that > back to byte offsets. Ah, I see. It "worked" for me because "\xed\xa0\x80\xed\xbc\x9f" isn't valid UTF-8. So Beautifulsoup decided to ignore the "" I had inserted before and used ISO-8859-1, providing me with correct byte offsets. If I replace that gibberish with a correct UTF-8 sequence (e.g. "\x4B\xC3\xA4\x73\x65") the UTF-8 is decoded and I get a character offset. > >> It looks like BeautifulSoup is doing something like that, yes. > >> Personally I would be nervous about some of my files being parsed > >> as UTF-8 and some of them ISO-8859-1 (due to decoding errors rather > >> than some of the files actually *being* ISO-8859-1 ;-) ) > > > > Since none of the syntactically meaningful characters have a code >= > > 0x80, you can parse HTML at the byte level if you know that it's encoded > > in a strict superset of ASCII (which all of the ISO-8859 family and > > UTF-8 are). Only if that's not true (e.g. if your files might be UTF-16 > > (or Shift-JIS or EUC, if I remember correctly) then you have to know > > the the character set. > > > > (By parsing I mean only "create a syntax tree". Obviously you have to > > know the encoding to know whether to display =ABc3 bc=BB as =AB=FC=BB or = > >=AB=C3=BC=BB.) > > But the job here isn't to create a syntax tree. It's to change some of > the content, which for all we know is not ASCII. We know it's URLs, and the canonical form of an URL is ASCII. The URLs in the files may not be, but if they aren't you'll have to deal with variants anyway. And the start and end of the attribute can be determined in any strict superset of ASCII including UTF-8. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From vinay_sajip at yahoo.co.uk Tue Aug 23 18:52:37 2022 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Tue, 23 Aug 2022 22:52:37 +0000 (UTC) Subject: ANN: A new version (0.5.0) of python-gnupg has been released. References: <447311532.9099.1661295157999.ref@mail.yahoo.com> Message-ID: <447311532.9099.1661295157999@mail.yahoo.com> What Changed? ============= This is an enhancement and bug-fix release, and all users are encouraged to upgrade. Brief summary: * Fixed #181: Added the ability to pass file paths to encrypt_file, decrypt_file, ? sign_file, verify_file, get_recipients_file and added import_keys_file. * Fixed #183: Handle FAILURE and UNEXPECTED conditions correctly. Thanks to sebbASF for ? the patch. * Fixed #185: Handle VALIDSIG arguments more robustly. * Fixed #188: Remove handling of DECRYPTION_FAILED from Verify code, as not required ? there. Thanks to sebbASF for the patch. * Fixed #190: Handle KEY_CREATED more robustly. * Fixed #191: Handle NODATA messages during verification. * Fixed #196: Don't log chunk data by default, as it could contain sensitive ? information (during decryption, for example). * Added the ability to pass an environment to the gpg executable. Thanks to Edvard ? Rejthar for the patch. This release [2] has been signed with my code signing key: Vinay Sajip (CODE SIGNING KEY) Fingerprint: CA74 9061 914E AC13 8E66 EADB 9147 B477 339A 9B86 Recent changes to PyPI don't show the GPG signature with the download links. The source code repository is at [1]. An alternative download source where the signatures are available is at [4]. Documentation is available at [5]. As always, your feedback is most welcome (especially bug reports [3], patches and suggestions for improvement, or any other points via this group). Enjoy! Cheers Vinay Sajip [1] https://github.com/vsajip/python-gnupg [2] https://pypi.org/project/python-gnupg/0.5.0 [3] https://github.com/vsajip/python-gnupg/issues [4] https://github.com/vsajip/python-gnupg/releases/ [5] https://docs.red-dove.com/python-gnupg/ From dioumacorfaye at gmail.com Tue Aug 23 11:52:48 2022 From: dioumacorfaye at gmail.com (Dioumacor FAYE) Date: Tue, 23 Aug 2022 15:52:48 +0000 Subject: xarry netcdf message In-Reply-To: References: Message-ID: Hello, I think you can try this. I use Python 3.7.11 in jupyter Notebook import xarray as xr path = '/media/lpaosf/LPAOSF_DATA/maman/r1mm_r20mm_sdii/ chirps-v2.0.days_p05_r1mm_WA1981-2018.nc' # Open the NetCDF files in xr.DataSet r1mm = xr.open_dataset(path) time=r1mm['time'].data lon =r1mm['longitude'].data lat =r1mm['latitude'].data data_r1mm=r1mm['r1mm'].data Le mar. 23 ao?t 2022 ? 15:38, Jorge Conrado Conforte Conforte < jorgconforte at gmail.com> a ?crit : > Hi, > > I'm reading my netcdf data air.2m.mon.ltm.nc. > I used the netcdf4 and I didn't have message when i read my data. But if I > use the xarray I had this message: > > > /home/conrado/.conda/envs/meuambi/lib/python3.8/site-packages/xarray/backends/plugins.py:61: > RuntimeWarning: Engine 'cfgrib' loading failed: > module 'cfgrib.messages' has no attribute 'DEFAULT_INDEXPATH' > warnings.warn(f"Engine {name!r} loading failed:\n{ex}", RuntimeWarning) > > /home/conrado/.conda/envs/meuambi/lib/python3.8/site-packages/xarray/coding/times.py:673: > SerializationWarning: Unable to decode time axis into full numpy.datetime64 > objects, continuing using cftime.datetime objects instead, reason: dates > out of range > dtype = _decode_cf_datetime_dtype(data, units, calendar, self.use_cftime) > > /home/conrado/.conda/envs/meuambi/lib/python3.8/site-packages/xarray/core/indexing.py:423: > SerializationWarning: Unable to decode time axis into full numpy.datetime64 > objects, continuing using cftime.datetime objects instead, reason: dates > out of range > return np.asarray(array[self.key], dtype=None) > > What can I do to solve this message. > > Thanks, > > Conrado > -- > https://mail.python.org/mailman/listinfo/python-list > -- Bien ? vous, --------------------- ------------------ ----------------- -------------------- ----------------- Dioumacor FAYE doctorant au LPAOSF/ESP/UCAD/BP 5085 Dakar-Fann, S?n?gal. Tel labo: (00221) 33 825 93 64 Email: d.faye20171634 at zig.univ.sn Tel: +221773475098 +221783484308 Physicien en herbe Pseudo Skype: dioumacorfaye From gladstone28 at hotmail.com Tue Aug 23 07:00:11 2022 From: gladstone28 at hotmail.com (Gladstone Rose) Date: Tue, 23 Aug 2022 11:00:11 +0000 Subject: INSTALLATION DOES NOT WORK FRO GITBASH COMMAND LINE Message-ID: Why is my installation of Python does not work at the command line for git bash. I get the following message bash: python3: command not found Sent from Mail for Windows From user at example.net Wed Aug 24 02:47:05 2022 From: user at example.net (J.O. Aho) Date: Wed, 24 Aug 2022 08:47:05 +0200 Subject: Installation does not work fro GitBash command line In-Reply-To: References: Message-ID: On 23/08/2022 13.00, Gladstone Rose wrote: > Why is my installation of Python does not work at the command line for git bash. > > I get the following message > bash: python3: command not found It can be that you need to use python.exe instead of python3.exe, see my work computers response when using git bash: result from tabbing python: $ python python.exe python3.dll python3.exe python39.dll pythonw.exe run python3: $ python3.exe --version Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. run python: $ python.exe --version Python 3.9.7 You could always install a proper OS that provides you a bash out of the box. -- //Aho From mats at wichmann.us Wed Aug 24 09:22:42 2022 From: mats at wichmann.us (Mats Wichmann) Date: Wed, 24 Aug 2022 07:22:42 -0600 Subject: INSTALLATION DOES NOT WORK FRO GITBASH COMMAND LINE In-Reply-To: References: Message-ID: <8e79ae9a-7520-aac3-f309-8de0fdbb61d7@wichmann.us> On 8/23/22 05:00, Gladstone Rose wrote: > Why is my installation of Python does not work at the command line for git bash. > > I get the following message > bash: python3: command not found The git bash package for Windows is built from msys2, a GNU/Linux type environment which is only provisioned with tools that are deemed necessary for the operation of git. Which happens not to include Python. You can add it there, although it's not entirely trivial, because the git-bash setup also doesn't include the pacman package manager, which would make the install trivial. From kirebrow at yahoo.com Wed Aug 24 15:54:33 2022 From: kirebrow at yahoo.com (Erik M. Brown) Date: Wed, 24 Aug 2022 15:54:33 -0400 Subject: ImportError: No module named spambayes.resources (line 12 of setup_all.py) References: <011201d8b7f3$5675db50$036191f0$.ref@yahoo.com> Message-ID: <011201d8b7f3$5675db50$036191f0$@yahoo.com> Is anyone here familiar with SpamBayes? I am working with legacy 2.4.x Python code (I'm not a programmer, more of a power user) and I'm attempting to build the windows binary from the SpamBayes source. I'm running into an error when attempting to run "setup_all.py", the py2exe setup script, and I get the following: "ImportError: No module named spambayes.resources (line 12 of setup_all.py)" I'm able to run Spambayes from these source files in Outlook and have the correct python version, pywin32, as well as py2exe (2.4.x). Any idea on how to resolve this module import error? I can provide files and/or more details as well. Thank you all for the help! Take care, Erik Brown From mats at wichmann.us Wed Aug 24 18:23:02 2022 From: mats at wichmann.us (Mats Wichmann) Date: Wed, 24 Aug 2022 16:23:02 -0600 Subject: ImportError: No module named spambayes.resources (line 12 of setup_all.py) In-Reply-To: <011201d8b7f3$5675db50$036191f0$@yahoo.com> References: <011201d8b7f3$5675db50$036191f0$.ref@yahoo.com> <011201d8b7f3$5675db50$036191f0$@yahoo.com> Message-ID: <91c4fcd1-0309-ba1e-aad5-bd2e58a9f281@wichmann.us> On 8/24/22 13:54, Erik M. Brown via Python-list wrote: > Is anyone here familiar with SpamBayes? I am working with legacy 2.4.x > Python code (I'm not a programmer, more of a power user) and I'm attempting > to build the windows binary from the SpamBayes source. > > > > I'm running into an error when attempting to run "setup_all.py", the py2exe > setup script, and I get the following: > > > > "ImportError: No module named spambayes.resources (line 12 of setup_all.py)" Wow, that's a blast from the past... I wouldn't hold out too much hope, we're talking about something that's been on the inactive list for a decade and a half at least, if memory serves. Python 2.4 itself dates to 2004. There does seem to be have been some effort to uplift Spambayes to Python 3: https://github.com/mpwillson/spambayes3 but in generic terms: "no module named" is always a path problem. The Python that is running and emits that error is looking in a place where the code it's trying to import... isn't. If you got it to work in some scenario, you need to compare the version of Python involved in that effort, and its paths (sys.path value) vs. what's getting run when you try to execute the thing that's failing. From barry at barrys-emacs.org Thu Aug 25 02:17:44 2022 From: barry at barrys-emacs.org (Barry) Date: Thu, 25 Aug 2022 07:17:44 +0100 Subject: ImportError: No module named spambayes.resources (line 12 of setup_all.py) In-Reply-To: <91c4fcd1-0309-ba1e-aad5-bd2e58a9f281@wichmann.us> References: <91c4fcd1-0309-ba1e-aad5-bd2e58a9f281@wichmann.us> Message-ID: > On 24 Aug 2022, at 23:25, Mats Wichmann wrote: > > ?On 8/24/22 13:54, Erik M. Brown via Python-list wrote: >> Is anyone here familiar with SpamBayes? I am working with legacy 2.4.x >> Python code (I'm not a programmer, more of a power user) and I'm attempting >> to build the windows binary from the SpamBayes source. >> >> >> >> I'm running into an error when attempting to run "setup_all.py", the py2exe >> setup script, and I get the following: >> >> >> >> "ImportError: No module named spambayes.resources (line 12 of setup_all.py)" > > > Wow, that's a blast from the past... I wouldn't hold out too much hope, > we're talking about something that's been on the inactive list for a > decade and a half at least, if memory serves. Python 2.4 itself dates > to 2004. There does seem to be have been some effort to uplift Spambayes > to Python 3: > > https://github.com/mpwillson/spambayes3 > > but in generic terms: "no module named" is always a path problem. The > Python that is running and emits that error is looking in a place where > the code it's trying to import... isn't. If you got it to work in some > scenario, you need to compare the version of Python involved in that > effort, and its paths (sys.path value) vs. what's getting run when you > try to execute the thing that's failing. On fedora I still use spambayes and it works great, but I have it running under python 2.7. never did take on a port to python 3 I will have to consider that when python 2 finally is removed from fedora, or use something else. Barry > > > -- > https://mail.python.org/mailman/listinfo/python-list > From nsh531 at gmail.com Thu Aug 25 10:53:41 2022 From: nsh531 at gmail.com (=?UTF-8?B?16DXqteZINep15jXqNef?=) Date: Thu, 25 Aug 2022 17:53:41 +0300 Subject: [CrowdStrike/falconpy] Why I recieved this output: (Discussion #760)+pandas DataFrame error Message-ID: Someone here is understanding at pandas? ?????? ??? ?????, 25 ??????? 2022, ??? Joshua Hiller < notifications at github.com>: > This is pretty far out of scope, but reviewing the error message in your > IDE it appears you are passing scalars to the Dataframe. Since there is no > index, you're given an error. Googling about, several folks who hit this > error pass the keyword index=[0] and provide a dummy index. Depending on > your goals, this may not be the correct solution. > > ? > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . > You are receiving this because you authored the thread.Message ID: > > -- From nsh531 at gmail.com Thu Aug 25 11:01:42 2022 From: nsh531 at gmail.com (=?UTF-8?B?16DXqteZINep15jXqNef?=) Date: Thu, 25 Aug 2022 18:01:42 +0300 Subject: [CrowdStrike/falconpy] Why I recieved this output: (Discussion #760)+pandas DataFrame error In-Reply-To: References: Message-ID: 2022-08-25 17:53 GMT?+03:00?, ??? ???? : > Someone here is understanding at pandas? > > ?????? ??? ?????, 25 ??????? 2022, ??? Joshua Hiller < > notifications at github.com>: > >> This is pretty far out of scope, but reviewing the error message in your >> IDE it appears you are passing scalars to the Dataframe. Since there is >> no >> index, you're given an error. Googling about, several folks who hit this >> error pass the keyword index=[0] and provide a dummy index. Depending on >> your goals, this may not be the correct solution. >> >> ? >> Reply to this email directly, view it on GitHub >> , >> or unsubscribe >> >> . >> You are receiving this because you authored the thread.Message ID: >> >> > > > -- > > -- From nsh531 at gmail.com Thu Aug 25 11:51:26 2022 From: nsh531 at gmail.com (=?UTF-8?B?16DXqteZINep15jXqNef?=) Date: Thu, 25 Aug 2022 18:51:26 +0300 Subject: [CrowdStrike/falconpy] Why I recieved this output: (Discussion #760) In-Reply-To: References: Message-ID: ?????? ??? ?????, 25 ??????? 2022, ??? Joshua Hiller < notifications at github.com>: > Hi @NSH531 - > > If passing an index doesn't help, you can probably get more assistance > from the Pandas issue board located here: https://github.com/pandas-dev/ > pandas/issues > > ? > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . > You are receiving this because you were mentioned.Message ID: > > -- From nsh531 at gmail.com Fri Aug 26 01:28:59 2022 From: nsh531 at gmail.com (=?UTF-8?B?16DXqteZINep15jXqNef?=) Date: Fri, 26 Aug 2022 08:28:59 +0300 Subject: Fwd: [pandas-dev/pandas] BUG: I CANT TO RECIEVING OUTPUT FROM DATAFRAME (Issue #48256) In-Reply-To: References: Message-ID: ------------ ????? ??????? ---------- ???: *??? ????* ?????: ??? ????, 26 ??????? 2022 ????: Re: [pandas-dev/pandas] BUG: I CANT TO RECIEVING OUTPUT FROM DATAFRAME (Issue #48256) ??: pandas-dev/pandas < reply+ABNBJWPFIL765HHZXPB3L4WBCUBNZEVBNHHFBDBPPU at reply.github.com> ????: pandas-dev/pandas , Author < author at noreply.github.com> I'll do it at sunday ?????? ??? ?????, 25 ??????? 2022, ??? Marco Edward Gorelli < notifications at github.com>: > Hi - please make your example reproducible https://matthewrocklin.com/blo > g/work/2018/02/28/minimal-bug-reports > > ? > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . > You are receiving this because you authored the thread.Message ID: > > -- -- From estates at hestates.org Thu Aug 25 08:48:24 2022 From: estates at hestates.org (Fulian Wang) Date: Thu, 25 Aug 2022 12:48:24 +0000 Subject: INSTALLATION DOES NOT WORK FRO GITBASH COMMAND LINE In-Reply-To: <8e79ae9a-7520-aac3-f309-8de0fdbb61d7@wichmann.us> References: <8e79ae9a-7520-aac3-f309-8de0fdbb61d7@wichmann.us> Message-ID: Same to me. I watched the videos online about how to find it. All failed. Finally,I got it accidentally. You just input ?command ?at the screen of your computer. It is at the bottom of screen and next to windows logo. There is a? Type here to search ? . You type? command? then hit ?enter? . ?Command Prompt ? is out. The picture is attached. Get Outlook for iOS ________________________________ From: Python-list on behalf of Mats Wichmann Sent: Wednesday, August 24, 2022 8:22:42 AM To: python-list at python.org Subject: Re: INSTALLATION DOES NOT WORK FRO GITBASH COMMAND LINE On 8/23/22 05:00, Gladstone Rose wrote: > Why is my installation of Python does not work at the command line for git bash. > > I get the following message > bash: python3: command not found The git bash package for Windows is built from msys2, a GNU/Linux type environment which is only provisioned with tools that are deemed necessary for the operation of git. Which happens not to include Python. You can add it there, although it's not entirely trivial, because the git-bash setup also doesn't include the pacman package manager, which would make the install trivial. -- https://mail.python.org/mailman/listinfo/python-list From gheskett at shentel.net Fri Aug 26 16:37:37 2022 From: gheskett at shentel.net (gene heskett) Date: Fri, 26 Aug 2022 16:37:37 -0400 Subject: python 3.10 vs breakage Message-ID: Greetings all; Its now become obvious that 3.10 has broken some things. I can't build linuxcnc with it. And Octoprint has quit talking to 3d printers, now pronterface won't buy it, can't find a 4.0.7 version of wxPython with it sitting there staring at us. Whats chances of a fixed version for bookworm? Or even a bugs fixed release for bullseye? Thanks all. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From pbryan at anode.ca Fri Aug 26 16:51:45 2022 From: pbryan at anode.ca (Paul Bryan) Date: Fri, 26 Aug 2022 13:51:45 -0700 Subject: python 3.10 vs breakage In-Reply-To: References: Message-ID: Why can't you build linuxcnc with it? Why has Octoprint quit talking to 3d printers? Why won't pronterface buy it? Why can't you find a 4.0.7 version of wxPython? Why is it sitting there staring at you? What is bookworm? What is bullseye? On Fri, 2022-08-26 at 16:37 -0400, gene heskett wrote: > Greetings all; > > Its now become obvious that 3.10 has broken some things. I can't > build > linuxcnc with it. And > Octoprint has quit talking to 3d printers, now pronterface won't buy > it, > can't find a 4.0.7 > version of wxPython with it sitting there staring at us. > > Whats chances of a fixed version for bookworm? Or even a bugs fixed > release for bullseye? > > Thanks all. > > Cheers, Gene Heskett. > -- > "There are four boxes to be used in defense of liberty: > ? soap, ballot, jury, and ammo. Please use in that order." > -Ed Howdershelt (Author, 1940) > If we desire respect for the law, we must first make the law > respectable. > ? - Louis D. Brandeis > Genes Web page > From gheskett at shentel.net Fri Aug 26 17:36:39 2022 From: gheskett at shentel.net (gene heskett) Date: Fri, 26 Aug 2022 17:36:39 -0400 Subject: python 3.10 vs breakage In-Reply-To: References: Message-ID: <5c9fbcb7-a3a2-bef6-c54d-05ce0080c202@shentel.net> On 8/26/22 16:54, Paul Bryan wrote: > Why can't you build linuxcnc with it? Why has Octoprint quit talking to > 3d printers? Why won't pronterface buy it? Why can't you find a 4.0.7 > version of wxPython? Why is it sitting there staring at you? What is > bookworm? What is bullseye? Bullseye is the current debian-11, buster is last years, bookworm is next. Linuxcnc builds just fine on armhf buster, with its python-3.9.4. fails from 3.10 in bullseye. Pronterface.py can't find wxPython 4.0 or greater, with 4.0.7 installed. Octoprint did work, but has now stopped. So my 3d printing has become a sneakernet exercise again. Adding 3 to 5 more steps between OpenCSAD and the printer that will make my designs. The error code file from this mornings attempt to run pronterface.py is at Is there a workaround? Thank you. > On Fri, 2022-08-26 at 16:37 -0400, gene heskett wrote: >> Greetings all; >> >> Its now become obvious that 3.10 has broken some things. I can't >> build >> linuxcnc with it. And >> Octoprint has quit talking to 3d printers, now pronterface won't buy >> it, >> can't find a 4.0.7 >> version of wxPython with it sitting there staring at us. >> >> Whats chances of a fixed version for bookworm? Or even a bugs fixed >> release for bullseye? >> >> Thanks all. >> >> Cheers, Gene Heskett. >> -- >> "There are four boxes to be used in defense of liberty: >> ? soap, ballot, jury, and ammo. Please use in that order." >> -Ed Howdershelt (Author, 1940) >> If we desire respect for the law, we must first make the law >> respectable. >> ? - Louis D. Brandeis >> Genes Web page >> > Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From pbryan at anode.ca Fri Aug 26 18:05:51 2022 From: pbryan at anode.ca (Paul Bryan) Date: Fri, 26 Aug 2022 15:05:51 -0700 Subject: python 3.10 vs breakage In-Reply-To: <5c9fbcb7-a3a2-bef6-c54d-05ce0080c202@shentel.net> References: <5c9fbcb7-a3a2-bef6-c54d-05ce0080c202@shentel.net> Message-ID: <93d986335872c295862b55ec78c2046eb6eddd48.camel@anode.ca> The pronterface README doc [1] recommends Python 3.6, so I'd?say that it's likely incompatible with changes in Python 3.10. I think your best option would be to either downgrade to their recommended version of Python, or file an issue in their GitHub repository to address the incompatibility.? [1]?https://github.com/kliment/Printrun/blob/master/README.md On Fri, 2022-08-26 at 17:36 -0400, gene heskett wrote: > On 8/26/22 16:54, Paul Bryan wrote: > > Why can't you build linuxcnc with it? Why has Octoprint quit > > talking to > > 3d printers? Why won't pronterface buy it? Why can't you find a > > 4.0.7 > > version of wxPython? Why is it sitting there staring at you? What > > is > > bookworm? What is bullseye? > > Bullseye is the current debian-11, buster is last years, bookworm is > next. > > Linuxcnc builds just fine on armhf buster, with its python-3.9.4. > fails > from 3.10 in bullseye. Pronterface.py can't find wxPython 4.0 or > greater, with 4.0.7 installed. Octoprint did work, but has now > stopped. > So my 3d printing has become a sneakernet exercise again. Adding 3 to > 5 > more steps between OpenCSAD and the printer that will make my > designs. > The error code file from this mornings attempt to run pronterface.py > is at > > > > Is there a workaround? > > Thank you. > > On Fri, 2022-08-26 at 16:37 -0400, gene heskett wrote: > > > Greetings all; > > > > > > Its now become obvious that 3.10 has broken some things. I can't > > > build > > > linuxcnc with it. And > > > Octoprint has quit talking to 3d printers, now pronterface won't > > > buy > > > it, > > > can't find a 4.0.7 > > > version of wxPython with it sitting there staring at us. > > > > > > Whats chances of a fixed version for bookworm? Or even a bugs > > > fixed > > > release for bullseye? > > > > > > Thanks all. > > > > > > Cheers, Gene Heskett. > > > -- > > > "There are four boxes to be used in defense of liberty: > > > ?? soap, ballot, jury, and ammo. Please use in that order." > > > -Ed Howdershelt (Author, 1940) > > > If we desire respect for the law, we must first make the law > > > respectable. > > > ?? - Louis D. Brandeis > > > Genes Web page > > > > > > > > Cheers, Gene Heskett. From torriem at gmail.com Fri Aug 26 21:29:40 2022 From: torriem at gmail.com (Michael Torrie) Date: Fri, 26 Aug 2022 19:29:40 -0600 Subject: python 3.10 vs breakage In-Reply-To: References: Message-ID: <24cee955-8d45-4ff8-29ad-a9b17de6e71a@gmail.com> On 8/26/22 14:37, gene heskett wrote: > Greetings all; > > Its now become obvious that 3.10 has broken some things. I can't build > linuxcnc with it. And > Octoprint has quit talking to 3d printers, now pronterface won't buy it, > can't find a 4.0.7 > version of wxPython with it sitting there staring at us. I have Fedora 35 here, nearing it's end of life. It has Python 3.10.6, and wxPython 4.0.7. I installed Pronterface 2.0.0 from the Fedora repos and it runs fine as near as I can tell. So there's no inherent incompatibility with Python 3.10 and wxPython 4.0.7. > Whats chances of a fixed version for bookworm? Or even a bugs fixed > release for bullseye? Seems like it is a distro-specific problem; I cannot replicate your error with pronterface on Fedora 35. I have no idea why octoprint won't work. From gheskett at shentel.net Sat Aug 27 01:55:24 2022 From: gheskett at shentel.net (gene heskett) Date: Sat, 27 Aug 2022 01:55:24 -0400 Subject: python 3.10 vs breakage In-Reply-To: <24cee955-8d45-4ff8-29ad-a9b17de6e71a@gmail.com> References: <24cee955-8d45-4ff8-29ad-a9b17de6e71a@gmail.com> Message-ID: On 8/26/22 21:35, Michael Torrie wrote: > On 8/26/22 14:37, gene heskett wrote: >> Greetings all; >> >> Its now become obvious that 3.10 has broken some things. I can't build >> linuxcnc with it. And >> Octoprint has quit talking to 3d printers, now pronterface won't buy it, >> can't find a 4.0.7 >> version of wxPython with it sitting there staring at us. > I have Fedora 35 here, nearing it's end of life. It has Python 3.10.6, > and wxPython 4.0.7. I installed Pronterface 2.0.0 from the Fedora repos > and it runs fine as near as I can tell. So there's no inherent > incompatibility with Python 3.10 and wxPython 4.0.7. > >> Whats chances of a fixed version for bookworm? Or even a bugs fixed >> release for bullseye? > Seems like it is a distro-specific problem; I cannot replicate your > error with pronterface on Fedora 35. > > I have no idea why octoprint won't work. This is good to know as it helps to narrow down the battlefield. Octoprint now gets stuck claiming the printer is continuously requesting a repeat of line one, but It works fine if the gcode file is put on its sd card and printed from the printers menu. Octoprint is supposed to be able to handle more than one printer, but this change occurred after I had plugged in another printer and tried to add it. It was working great with a prusa mk3S+. And I'm trying to resurrect an Ender 5 Plus that has forgotten how to use any of the 3 BLTouch's I have. So I've replaced the head with a volcano version of an E3D-V6 and have a prox switch with the wrong logic output mounted in place of the BLTouch. It seems amazon is not immune to ID10T vendors. I ordered npn-no's and got pnp-nc's. Even the label on the devices cable is wrong. The head replacement includes an Orbiter V2 extruder sitting on top of the volcano, with me designing and printing the adapters. but still with the long capricorn tube feed to absorb the jerking on the feed spool the mk3s+ does. Even with the much improved grip a bondtech LGX extruder on the mk3s+ gives, I can still see artifacts of the spool jerk as it runs left/right in the print. Vertical flex in the head transport suspension rods I believe. So I've eliminated that geometry error on the Ender 5 plus by interposing a fixed length of tubing so it doesn't jerk on the spool as the head moves. The Dell with an i5 in it had its video out nullified by some noisy weather 20 days back, so I pulled out a 5 amp 5 volt box and hung a rock64/w/4gigs on it to run octoprint on, but it quit working on the mk3s+ when I plugged in the Ender. I'll probably have to re-install it all. Easy enough since I have armbian bullseye's img file here. The target of all this is production of a woodworking tool using modern cnc wood carving and 3d printing, of a device I see selling in the 3 digit price range on ebay that you'll hand down to your great grandkids if they are interested in fine woodworking as a means to buy groceries, good housing and nice wheels.? At my age, I'm that great great grandpa. Looking to supplement my SS in my dotage. A retired broadcast engineer, a C.E.T., approaching the end of my time here as I look at the calendar and see my 88th coming up shortly. I'd like to leave something useful behind. It will take at least 2 working printers to keep up with the output of one of my milling machines if sales materialize. 3d printers are not fast. A screw I can carve in 2 days, takes about 2 weeks to print the rest of it. Production, 20 a year, maybe. Thanks everybody.? Take care and stay well. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From gheskett at shentel.net Sun Aug 28 18:40:17 2022 From: gheskett at shentel.net (gene heskett) Date: Sun, 28 Aug 2022 18:40:17 -0400 Subject: What can I do about this? Message-ID: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> Greatings all; Persuant to my claim the py3.10 is busted, here is a sample. This is me, trying to make pronterface, inside a venv: When the package manager version will only run the gui-less "pronsole" but nothing else from that all python kit runs as it should or at all. From the package-managers install in /usr/share/doc/printrun-common/ I copied requirements.txt into the venv, and ran this command line: gene at rock64:~/venv$ pip3 install -r requirements.txt Defaulting to user installation because normal site-packages is not writeable Ignoring pyobjc-framework-Cocoa: markers 'sys_platform == "darwin"' don't match your environment Ignoring pyreadline: markers 'sys_platform == "win32"' don't match your environment Requirement already satisfied: pyserial>=3.0 in /usr/lib/python3/dist-packages (from -r requirements.txt (line 1)) (3.5) Collecting wxPython>=4.1 ? Using cached wxPython-4.2.0.tar.gz (71.0 MB) ? Preparing metadata (setup.py) ... error ? error: subprocess-exited-with-error ? ? python setup.py egg_info did not run successfully. ? ? exit code: 1 ? ??> [8 lines of output] ????? Traceback (most recent call last): ??????? File "", line 2, in ??????? File "", line 34, in ??????? File "/tmp/pip-install-c9gmbpsr/wxpython_1a0e096c87d84229b709c31ccb920a24/setup.py", line 27, in ????????? from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName ??????? File "/tmp/pip-install-c9gmbpsr/wxpython_1a0e096c87d84229b709c31ccb920a24/buildtools/config.py", line 30, in ????????? from attrdict import AttrDict ????? ModuleNotFoundError: No module named 'attrdict' ????? [end of output] ? note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed ? Encountered error while generating package metadata. ??> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. What do I need to do to fix this? It supposedly works on a rpi4b, but this is a rock64, V2, older stuff with 4 gigs of dram. Thank you for any help you can toss my way. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From rosuav at gmail.com Sun Aug 28 19:30:16 2022 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 29 Aug 2022 09:30:16 +1000 Subject: What can I do about this? In-Reply-To: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> Message-ID: On Mon, 29 Aug 2022 at 08:41, gene heskett wrote: > > Greatings all; > > Persuant to my claim the py3.10 is busted, here is a sample. This is me, > trying to make > pronterface, inside a venv: When the package manager version will only > run the gui-less "pronsole" > but nothing else from that all python kit runs as it should or at all. > From the package-managers install in /usr/share/doc/printrun-common/ I > copied requirements.txt > into the venv, and ran this command line: > > gene at rock64:~/venv$ pip3 install -r requirements.txt > Defaulting to user installation because normal site-packages is not > writeable I don't think Python 3.10 is busted; it's more likely your venv is not providing a pip3 command. Try "pip3 --version", "python3 --version", and then "python3 -m pip install -r requirements.txt". Why do you keep blaming Python as if it's fundamentally broken? ChrisA From hjp-python at hjp.at Sun Aug 28 19:32:01 2022 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 29 Aug 2022 01:32:01 +0200 Subject: What can I do about this? In-Reply-To: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> Message-ID: <20220828233201.k3xmcpdnpn63wxeb@hjp.at> On 2022-08-28 18:40:17 -0400, gene heskett wrote: > Persuant to my claim the py3.10 is busted, here is a sample. This is me, > trying to make > pronterface, inside a venv: When the package manager version will only run > the gui-less "pronsole" > but nothing else from that all python kit runs as it should or at all. > From the package-managers install in /usr/share/doc/printrun-common/ I > copied requirements.txt > into the venv, and ran this command line: > > gene at rock64:~/venv$ pip3 install -r requirements.txt You are almost certainly *not* in a venv here. First, your prompt doesn't show the name of the venv, > Defaulting to user installation because normal site-packages is not > writeable and second, because of this message, which you don't get if you invoke pip inside a venv (at least not if you can write it). So, first thing to do is to create the venv and activate it. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From gheskett at shentel.net Sun Aug 28 20:45:28 2022 From: gheskett at shentel.net (gene heskett) Date: Sun, 28 Aug 2022 20:45:28 -0400 Subject: What can I do about this? In-Reply-To: References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> Message-ID: On 8/28/22 19:36, Chris Angelico wrote: > On Mon, 29 Aug 2022 at 08:41, gene heskett wrote: >> Greatings all; >> >> Persuant to my claim the py3.10 is busted, here is a sample. This is me, >> trying to make >> pronterface, inside a venv: When the package manager version will only >> run the gui-less "pronsole" >> but nothing else from that all python kit runs as it should or at all. >> From the package-managers install in /usr/share/doc/printrun-common/ I >> copied requirements.txt >> into the venv, and ran this command line: >> >> gene at rock64:~/venv$ pip3 install -r requirements.txt >> Defaulting to user installation because normal site-packages is not >> writeable > I don't think Python 3.10 is busted; it's more likely your venv is not > providing a pip3 command. Try "pip3 --version", gene at rock64:~/venv$ pip3 --version pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10) > "python3 --version", gene at rock64:~/venv$ python3 --version Python 3.10.4 > and then "python3 -m pip install -r requirements.txt". gene at rock64:~/venv$ python3 -m pip install -r requirements.txt Defaulting to user installation because normal site-packages is not writeable Ignoring pyobjc-framework-Cocoa: markers 'sys_platform == "darwin"' don't match your environment Ignoring pyreadline: markers 'sys_platform == "win32"' don't match your environment Requirement already satisfied: pyserial>=3.0 in /usr/lib/python3/dist-packages (from -r requirements.txt (line 1)) (3.5) Collecting wxPython>=4.1 ? Using cached wxPython-4.2.0.tar.gz (71.0 MB) ? Preparing metadata (setup.py) ... error ? error: subprocess-exited-with-error ? ? python setup.py egg_info did not run successfully. ? ? exit code: 1 ? ??> [8 lines of output] ????? Traceback (most recent call last): ??????? File "", line 2, in ??????? File "", line 34, in ??????? File "/tmp/pip-install-g3phtj8f/wxpython_17898b1c7a6f49a690adac623d839514/setup.py", line 27, in ????????? from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName ??????? File "/tmp/pip-install-g3phtj8f/wxpython_17898b1c7a6f49a690adac623d839514/buildtools/config.py", line 30, in ????????? from attrdict import AttrDict ????? ModuleNotFoundError: No module named 'attrdict' ????? [end of output] ? note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed ? Encountered error while generating package metadata. ??> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. > > Why do you keep blaming Python as if it's fundamentally broken? > > ChrisA Given the above output, do you have a better target? It also fails to build linuxcnc on bullseye for armhf, on an rpi4b with 2 gigs of dram. Works perfectly on buster, but I expect that has been fixed? since linuxcnc looks like its good to go for inclusion in bookworm. Take care and stay well Chris. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From gheskett at shentel.net Sun Aug 28 20:55:10 2022 From: gheskett at shentel.net (gene heskett) Date: Sun, 28 Aug 2022 20:55:10 -0400 Subject: What can I do about this? In-Reply-To: <20220828233201.k3xmcpdnpn63wxeb@hjp.at> References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> <20220828233201.k3xmcpdnpn63wxeb@hjp.at> Message-ID: <96f5d626-5ebb-67a7-c7a7-1c6c5284fb1a@shentel.net> On 8/28/22 19:39, Peter J. Holzer wrote: > On 2022-08-28 18:40:17 -0400, gene heskett wrote: >> Persuant to my claim the py3.10 is busted, here is a sample. This is me, >> trying to make >> pronterface, inside a venv: When the package manager version will only run >> the gui-less "pronsole" >> but nothing else from that all python kit runs as it should or at all. >> From the package-managers install in /usr/share/doc/printrun-common/ I >> copied requirements.txt >> into the venv, and ran this command line: >> >> gene at rock64:~/venv$ pip3 install -r requirements.txt > You are almost certainly *not* in a venv here. First, your prompt > doesn't show the name of the venv, I've created that several times, as octoprint won''t run without it either. I found a way to autostart it on reboots and octoprint seems happy with it >> Defaulting to user installation because normal site-packages is not >> writeable > and second, because of this message, which you don't get if you invoke > pip inside a venv (at least not if you can write it). > > So, first thing to do is to create the venv and activate it. Procedure? Or a url to it? Thank you Peter. Take care & stay well. > hp > > Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From nntp.mbourne at spamgourmet.com Sat Aug 27 07:42:13 2022 From: nntp.mbourne at spamgourmet.com (Mark Bourne) Date: Sat, 27 Aug 2022 12:42:13 +0100 Subject: How to make a variable's late binding crosses the module boundary? References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> Message-ID: Jach Feng wrote: > I have two files: test.py and test2.py > --test.py-- > x = 2 > def foo(): > print(x) > foo() > > x = 3 > foo() > > --test2.py-- > from test import * > x = 4 > foo() > > ----- > Run test.py under Winows8.1, I get the expected result: > e:\MyDocument>py test.py > 2 > 3 > > But when run test2.py, the result is not my expected 2,3,4:-( > e:\MyDocument>py test2.py > 2 > 3 > 3 > > What to do? `from test import *` does not link the names in `test2` to those in `test`. It just binds objects bound to names in `test` to the same names in `test2`. A bit like doing: import test x = test.x foo = test.foo del test Subsequently assigning a different object to `x` in one module does not affect the object assigned to `x` in the other module. So `x = 4` in `test2.py` does not affect the object assigned to `x` in `test.py` - that's still `3`. If you want to do that, you need to import `test` and assign to `test.x`, for example: import test test.x = 4 test.foo() -- Mark. From wlfraed at ix.netcom.com Sat Aug 27 13:59:31 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Sat, 27 Aug 2022 13:59:31 -0400 Subject: python 3.10 vs breakage References: <5c9fbcb7-a3a2-bef6-c54d-05ce0080c202@shentel.net> Message-ID: <0nmkghhucnn5eulc85tqlq1b1med0d6ri0@4ax.com> On Fri, 26 Aug 2022 17:36:39 -0400, gene heskett declaimed the following: > >Bullseye is the current debian-11, buster is last years, bookworm is next. > >Linuxcnc builds just fine on armhf buster, with its python-3.9.4. fails >from 3.10 in bullseye. Pronterface.py can't find wxPython 4.0 or >greater, with 4.0.7 installed. Octoprint did work, but has now stopped. >So my 3d printing has become a sneakernet exercise again. Adding 3 to 5 >more steps between OpenCSAD and the printer that will make my designs. All of this suggests to me that you need to make your complaints to the Debian devs WRT how they have configured things (or, if using an R-Pi, the R-Pi Foundation, as they customize Debian for their release). . -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From jfong at ms4.hinet.net Sat Aug 27 21:40:18 2022 From: jfong at ms4.hinet.net (Jach Feng) Date: Sat, 27 Aug 2022 18:40:18 -0700 (PDT) Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> Message-ID: Mark Bourne ? 2022?8?27? ?????7:42:37 [UTC+8] ?????? > import test > test.x = 4 > test.foo() > > -- > Mark. Yes, you are right. But because of I am using "from test import *" which makes the name "test" disappear in the test2 scope, so this is not work. I solved this problem by moving "x" to a separate config.py file, import it in both test.py and test2.py, and access it using config.x --Jach From wlfraed at ix.netcom.com Sun Aug 28 19:33:12 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Sun, 28 Aug 2022 19:33:12 -0400 Subject: What can I do about this? References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> Message-ID: On Sun, 28 Aug 2022 18:40:17 -0400, gene heskett declaimed the following: >Collecting wxPython>=4.1 > ? Using cached wxPython-4.2.0.tar.gz (71.0 MB) > ? Preparing metadata (setup.py) ... error > ? error: subprocess-exited-with-error > > ??????? File >"/tmp/pip-install-c9gmbpsr/wxpython_1a0e096c87d84229b709c31ccb920a24/buildtools/config.py", >line 30, in > ????????? from attrdict import AttrDict > ????? ModuleNotFoundError: No module named 'attrdict' > ????? [end of output] > Well... First I'd ask where you obtained a 4.2.0 tar.gz version of wxPython? Maybe try overriding it with a 4.1 variant of it -- or whatever you can find in the OS's package manager. > >What do I need to do to fix this? It supposedly works on a rpi4b, but >this is a rock64, V2, >older stuff with 4 gigs of dram. > >Thank you for any help you can toss my way. > Ask in a forum specific to the OS? Heck, what IS the OS on that board, and how up-to-date is it? The R-Pi is running a Raspberry Foundation modified Debian Buster or Bullseye (appears they've pulled Buster, oldest OS in the archive is January's Bullseye release). This does not appear to really be a Python related problem -- rather it looks like OS misconfiguration/disagreement. However, you may wish to review https://github.com/wxWidgets/Phoenix/issues/2225 Python3.10 is, perhaps, too NEW and various third-party libraries have not been updated to be compatible with IT. Maybe install a version of Python3.9 and start over loading all those extra packages. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From Richard at Damon-Family.org Sun Aug 28 22:46:41 2022 From: Richard at Damon-Family.org (Richard Damon) Date: Sun, 28 Aug 2022 22:46:41 -0400 Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> Message-ID: On 8/27/22 7:42 AM, Mark Bourne wrote: > Jach Feng wrote: >> I have two files: test.py and test2.py >> --test.py-- >> x = 2 >> def foo(): >> ???? print(x) >> foo() >> >> x = 3 >> foo() >> >> --test2.py-- >> from test import * >> x = 4 >> foo() >> >> ----- >> Run test.py under Winows8.1, I get the expected result: >> e:\MyDocument>py test.py >> 2 >> 3 >> >> But when run test2.py, the result is not my expected 2,3,4:-( >> e:\MyDocument>py test2.py >> 2 >> 3 >> 3 >> >> What to do? > > `from test import *` does not link the names in `test2` to those in > `test`.? It just binds objects bound to names in `test` to the same > names in `test2`.? A bit like doing: > > import test > x = test.x > foo = test.foo > del test > > Subsequently assigning a different object to `x` in one module does > not affect the object assigned to `x` in the other module. So `x = 4` > in `test2.py` does not affect the object assigned to `x` in `test.py` > - that's still `3`.? If you want to do that, you need to import `test` > and assign to `test.x`, for example: > > import test > test.x = 4 > test.foo() > Yes, fundamental issue is that the statement from x import y makes a binding in this module to the object CURRECTLY bound to x.y to the name y, but if x.y gets rebound, this module does not track the changes. You can mutate the object x.y and see the changes, but not rebind it. If you need to see rebindings, you can't use the "from x import y" form, or at a minimum do it as: import x from x import y then later to get rebindings to x.y do a y = x.y to rebind to the current x.y object. -- Richard Damon From jfong at ms4.hinet.net Sun Aug 28 23:51:43 2022 From: jfong at ms4.hinet.net (Jach Feng) Date: Sun, 28 Aug 2022 20:51:43 -0700 (PDT) Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> Message-ID: <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> Richard Damon ? 2022?8?29? ?????10:47:08 [UTC+8] ?????? > On 8/27/22 7:42 AM, Mark Bourne wrote: > > Jach Feng wrote: > >> I have two files: test.py and test2.py > >> --test.py-- > >> x = 2 > >> def foo(): > >> print(x) > >> foo() > >> > >> x = 3 > >> foo() > >> > >> --test2.py-- > >> from test import * > >> x = 4 > >> foo() > >> > >> ----- > >> Run test.py under Winows8.1, I get the expected result: > >> e:\MyDocument>py test.py > >> 2 > >> 3 > >> > >> But when run test2.py, the result is not my expected 2,3,4:-( > >> e:\MyDocument>py test2.py > >> 2 > >> 3 > >> 3 > >> > >> What to do? > > > > `from test import *` does not link the names in `test2` to those in > > `test`. It just binds objects bound to names in `test` to the same > > names in `test2`. A bit like doing: > > > > import test > > x = test.x > > foo = test.foo > > del test > > > > Subsequently assigning a different object to `x` in one module does > > not affect the object assigned to `x` in the other module. So `x = 4` > > in `test2.py` does not affect the object assigned to `x` in `test.py` > > - that's still `3`. If you want to do that, you need to import `test` > > and assign to `test.x`, for example: > > > > import test > > test.x = 4 > > test.foo() > > > Yes, fundamental issue is that the statement > > from x import y > > makes a binding in this module to the object CURRECTLY bound to x.y to > the name y, but if x.y gets rebound, this module does not track the changes. > > You can mutate the object x.y and see the changes, but not rebind it. > > If you need to see rebindings, you can't use the "from x import y" form, > or at a minimum do it as: > > > import x > > from x import y > > then later to get rebindings to x.y do a > > y = x.y > > to rebind to the current x.y object. > > -- > Richard Damon Yes, an extra "import x" will solve my problem too! Sometimes I am wondering why "from x import y" hides x? hum...can't figure out the reason:-) --Jach From rosuav at gmail.com Mon Aug 29 01:58:22 2022 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 29 Aug 2022 15:58:22 +1000 Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> Message-ID: On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > > Richard Damon ? 2022?8?29? ?????10:47:08 [UTC+8] ?????? > > On 8/27/22 7:42 AM, Mark Bourne wrote: > > > Jach Feng wrote: > > >> I have two files: test.py and test2.py > > >> --test.py-- > > >> x = 2 > > >> def foo(): > > >> print(x) > > >> foo() > > >> > > >> x = 3 > > >> foo() > > >> > > >> --test2.py-- > > >> from test import * > > >> x = 4 > > >> foo() > > >> > > >> ----- > > >> Run test.py under Winows8.1, I get the expected result: > > >> e:\MyDocument>py test.py > > >> 2 > > >> 3 > > >> > > >> But when run test2.py, the result is not my expected 2,3,4:-( > > >> e:\MyDocument>py test2.py > > >> 2 > > >> 3 > > >> 3 > > >> > > >> What to do? > > > > > > `from test import *` does not link the names in `test2` to those in > > > `test`. It just binds objects bound to names in `test` to the same > > > names in `test2`. A bit like doing: > > > > > > import test > > > x = test.x > > > foo = test.foo > > > del test > > > > > > Subsequently assigning a different object to `x` in one module does > > > not affect the object assigned to `x` in the other module. So `x = 4` > > > in `test2.py` does not affect the object assigned to `x` in `test.py` > > > - that's still `3`. If you want to do that, you need to import `test` > > > and assign to `test.x`, for example: > > > > > > import test > > > test.x = 4 > > > test.foo() > > > > > Yes, fundamental issue is that the statement > > > > from x import y > > > > makes a binding in this module to the object CURRECTLY bound to x.y to > > the name y, but if x.y gets rebound, this module does not track the changes. > > > > You can mutate the object x.y and see the changes, but not rebind it. > > > > If you need to see rebindings, you can't use the "from x import y" form, > > or at a minimum do it as: > > > > > > import x > > > > from x import y > > > > then later to get rebindings to x.y do a > > > > y = x.y > > > > to rebind to the current x.y object. > > > > -- > > Richard Damon > Yes, an extra "import x" will solve my problem too! Sometimes I am wondering why "from x import y" hides x? hum...can't figure out the reason:-) > "from x import y" doesn't hide x - it just grabs y. Python does what you tell it to. :) ChrisA From gheskett at shentel.net Mon Aug 29 04:51:13 2022 From: gheskett at shentel.net (gene heskett) Date: Mon, 29 Aug 2022 04:51:13 -0400 Subject: What can I do about this? In-Reply-To: References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> Message-ID: <82b052e2-6842-a434-e727-7aeb6befdd35@shentel.net> On 8/28/22 20:51, gene heskett wrote: > On 8/28/22 19:36, Chris Angelico wrote: >> On Mon, 29 Aug 2022 at 08:41, gene heskett wrote: >>> Greatings all; >>> >>> Persuant to my claim the py3.10 is busted, here is a sample. This is >>> me, >>> trying to make >>> pronterface, inside a venv: When the package manager version will only >>> run the gui-less "pronsole" >>> but nothing else from that all python kit runs as it should or at all. >>> ? From the package-managers install in >>> /usr/share/doc/printrun-common/ I >>> copied requirements.txt >>> into the venv, and ran this command line: >>> >>> gene at rock64:~/venv$ pip3 install -r requirements.txt >>> Defaulting to user installation because normal site-packages is not >>> writeable >> I don't think Python 3.10 is busted; it's more likely your venv is not >> providing a pip3 command. Try "pip3 --version", > gene at rock64:~/venv$ pip3 --version > pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10) >> ? "python3 --version", > gene at rock64:~/venv$ python3 --version > Python 3.10.4 > >> and then "python3 -m pip install -r requirements.txt". > gene at rock64:~/venv$ python3 -m pip install -r requirements.txt > Defaulting to user installation because normal site-packages is not > writeable > Ignoring pyobjc-framework-Cocoa: markers 'sys_platform == "darwin"' > don't match your environment > Ignoring pyreadline: markers 'sys_platform == "win32"' don't match > your environment > Requirement already satisfied: pyserial>=3.0 in > /usr/lib/python3/dist-packages (from -r requirements.txt (line 1)) (3.5) > Collecting wxPython>=4.1 > ? Using cached wxPython-4.2.0.tar.gz (71.0 MB) > ? Preparing metadata (setup.py) ... error > ? error: subprocess-exited-with-error > > ? ? python setup.py egg_info did not run successfully. > ? ? exit code: 1 > ? ??> [8 lines of output] > ????? Traceback (most recent call last): > ??????? File "", line 2, in > ??????? File "", line 34, in > ??????? File > "/tmp/pip-install-g3phtj8f/wxpython_17898b1c7a6f49a690adac623d839514/setup.py", > line 27, in > ????????? from buildtools.config import Config, msg, opj, runcmd, > canGetSOName, getSOName > ??????? File > "/tmp/pip-install-g3phtj8f/wxpython_17898b1c7a6f49a690adac623d839514/buildtools/config.py", > line 30, in > ????????? from attrdict import AttrDict > ????? ModuleNotFoundError: No module named 'attrdict' > ????? [end of output] > > ? note: This error originates from a subprocess, and is likely not a > problem with pip. > error: metadata-generation-failed > > ? Encountered error while generating package metadata. > ??> See above for output. > > note: This is an issue with the package mentioned above, not pip. > hint: See above for details. > >> >> Why do you keep blaming Python as if it's fundamentally broken? >> >> ChrisA > Given the above output, do you have a better target? It also fails to > build linuxcnc on > bullseye for armhf, on an rpi4b with 2 gigs of dram. > Works perfectly on buster, but I expect that has been fixed? since > linuxcnc > looks like its good to go for inclusion in bookworm. > I;ve created a separate venv to install printrun, I does not work either. So in that venv, I've done a git clone of printrun. Then after that, it appears there is no such critter as a wxPython.whl for the arms, only x86_64's. So whats the diff if it run ok on a pi, or claims it does. I don't have a spare rpi4b and they are equ to teeth for a chicken ATM. What, on the arms, substitutes for the missing "*.whl" file? > Take care and stay well Chris. > > Cheers, Gene Heskett. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From roel at roelschroeven.net Mon Aug 29 05:19:42 2022 From: roel at roelschroeven.net (Roel Schroeven) Date: Mon, 29 Aug 2022 11:19:42 +0200 Subject: What can I do about this? In-Reply-To: <96f5d626-5ebb-67a7-c7a7-1c6c5284fb1a@shentel.net> References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> <20220828233201.k3xmcpdnpn63wxeb@hjp.at> <96f5d626-5ebb-67a7-c7a7-1c6c5284fb1a@shentel.net> Message-ID: Op 29/08/2022 om 2:55 schreef gene heskett: > On 8/28/22 19:39, Peter J. Holzer wrote: >> On 2022-08-28 18:40:17 -0400, gene heskett wrote: >>> Persuant to my claim the py3.10 is busted, here is a sample. This is >>> me, >>> trying to make >>> pronterface, inside a venv: When the package manager version will >>> only run >>> the gui-less "pronsole" >>> but nothing else from that all python kit runs as it should or at all. >>> ?From the package-managers install in /usr/share/doc/printrun-common/ I >>> copied requirements.txt >>> into the venv, and ran this command line: >>> >>> gene at rock64:~/venv$ pip3 install -r requirements.txt >> You are almost certainly *not* in a venv here. First, your prompt >> doesn't show the name of the venv, > I've created that several times, as octoprint won''t run without it > either. > I found a way to autostart it on reboots and octoprint seems happy > with it I agree with Peter: it doesn't look as if you are invoking the pip3 in the venv. Just making the venv-directory the current directory doesn't activate it. As a diagnostic, ask the OS which pip3 is actually used: $ type -a pip3 Does that show the pip3 installed in the venv? Or the system-wide one? If it's not the pip3 in the venv, well, then that's the problem (or at least part of the problem). Solution: first check whether the venv really contains 'pip3' (as opposed to eg. just 'pip'): list the contents of the bin subdirectory of the venv. If not, use 'pip' or whatever instead. Then to make sure you use the one in the venv, either activate the venv or explicitly specify the path when invoking pip/pip3 (and likewise for python/python3). So either (assuming you're using bash): $ source {path_to_venv}/bin/pip3? # activate the venv $ type -a pip3? # check whether now the correct pip3 is used $ pip3 install -r requirements.txt? # finally invoke pip3 or: $ {path_to_venv}/bin/pip3 install -r requirements.txt Activating the venv is easier if you're going to use multiple commands in the venv. Note that activating the venv only has effect on the current shell; other shells are unaffected, and when you close the current shell the venv is not activated anymore. Explicitly using the path is easier for one-off calls, or in things like crontab. -- "There is no cause so noble that it will not attract fuggheads." -- Larry Niven From gheskett at shentel.net Mon Aug 29 11:12:17 2022 From: gheskett at shentel.net (gene heskett) Date: Mon, 29 Aug 2022 11:12:17 -0400 Subject: What can I do about this? In-Reply-To: References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> <20220828233201.k3xmcpdnpn63wxeb@hjp.at> <96f5d626-5ebb-67a7-c7a7-1c6c5284fb1a@shentel.net> Message-ID: On 8/29/22 05:25, Roel Schroeven wrote: > Op 29/08/2022 om 2:55 schreef gene heskett: >> On 8/28/22 19:39, Peter J. Holzer wrote: >>> On 2022-08-28 18:40:17 -0400, gene heskett wrote: >>>> Persuant to my claim the py3.10 is busted, here is a sample. This >>>> is me, >>>> trying to make >>>> pronterface, inside a venv: When the package manager version will >>>> only run >>>> the gui-less "pronsole" >>>> but nothing else from that all python kit runs as it should or at all. >>>> ?From the package-managers install in >>>> /usr/share/doc/printrun-common/ I >>>> copied requirements.txt >>>> into the venv, and ran this command line: >>>> >>>> gene at rock64:~/venv$ pip3 install -r requirements.txt >>> You are almost certainly *not* in a venv here. First, your prompt >>> doesn't show the name of the venv, >> I've created that several times, as octoprint won''t run without it >> either. >> I found a way to autostart it on reboots and octoprint seems happy >> with it > I agree with Peter: it doesn't look as if you are invoking the pip3 in > the venv. Just making the venv-directory the current directory doesn't > activate it. > > As a diagnostic, ask the OS which pip3 is actually used: > > $ type -a pip3 > I get different answers in or out of the venv venv) gene at rock64:~/printrun/Printrun$ type -a pip3 pip3 is /home/gene/printrun/Printrun/venv/bin/pip3 pip3 is /usr/bin/pip3 pip3 is /bin/pip3 or: gene at rock64:~/src/wxPython-4.2.0$ type -a pip3 pip3 is /usr/bin/pip3 pip3 is /bin/pip3 but with all the build instructions I've now followed, I now have at least 3 different venv subdirs scattered about. one in /home/gene, one in /home/gene/Octoprint, and one in /home/gene/printrun each with its own bin subdir, but not identical contents. > Does that show the pip3 installed in the venv? Or the system-wide one? > If it's not the pip3 in the venv, well, then that's the problem (or at > least part of the problem). Solution: first check whether the venv > really contains 'pip3' (as opposed to eg. just 'pip'): list the > contents of the bin subdirectory of the venv. gene at rock64:~/venv/bin$ ls -l total 36 -rw-r--r-- 1 gene gene 1982 Aug 21 13:12 activate -rw-r--r-- 1 gene gene? 908 Aug 21 13:12 activate.csh -rw-r--r-- 1 gene gene 2050 Aug 21 13:12 activate.fish -rw-r--r-- 1 gene gene 9033 Aug 21 13:12 Activate.ps1 -rwxrwxr-x 1 gene gene? 232 Aug 21 13:12 pip -rwxrwxr-x 1 gene gene? 232 Aug 21 13:12 pip3 -rwxrwxr-x 1 gene gene? 232 Aug 21 13:12 pip3.10 lrwxrwxrwx 1 gene gene??? 7 Aug 21 13:11 python -> python3 lrwxrwxrwx 1 gene gene?? 16 Aug 21 13:11 python3 -> /usr/bin/python3 lrwxrwxrwx 1 gene gene??? 7 Aug 21 13:11 python3.10 -> python3 > If not, use 'pip' or whatever instead. Then to make sure you use the > one in the venv, either activate the venv or explicitly specify the > path when invoking pip/pip3 (and likewise for python/python3). > > So either (assuming you're using bash): > > $ source {path_to_venv}/bin/pip3? # activate the venv > $ type -a pip3? # check whether now the correct pip3 is used > $ pip3 install -r requirements.txt? # finally invoke pip3 > > or: > > $ {path_to_venv}/bin/pip3 install -r requirements.txt > > Activating the venv is easier if you're going to use multiple commands > in the venv. Note that activating the venv only has effect on the > current shell; other shells are unaffected, and when you close the > current shell the venv is not activated anymore. > Explicitly using the path is easier for one-off calls, or in things > like crontab. > I've not had to deal with venv's before. Can more than one of these venv things peacefully coexist?? Seems like they should. If there is sufficient nv memory, But I am a 100% new bee here. The card itself is a 64GB. I also have the git clone of wxPython-4.2.0, but nothing I can invoke there builds it. But there are no specific linux instructions there, osx and winders only. The package managers version of wxPython-4.0.7 apparently is not new enough. It seems to me these utility's ought to be able to all live in one venv, or there should be an env python path that is specific to each application. This would lead to a huge waste of nv storage by duplicating a venv for each app, not sensible when the target of the venv is a common arm64 system. All broadcom for gpio etc. Presently, Octoprint works, and so does pronsole which has no gui, but Octoprint is a one printer show, and I've a small farm of printers. Most of which have failed the PETG test ,but that claimed to be PETG compatible, but quickly failed when fed a roll of it. PETG is the same plastic forever bottles are made from, much stronger than the PLA most folks use for artwork and what I'm doing needs its physical strength. It also raises the printhead temp around 50C, which causes teflon to slowly ablate with phosgene gas as output. Dangerous stuff, and high maintenance too. What I hope to be the 2nd workhorse? is an Ender 5 Plus, a huge core-xy thing that now has a 300C capable head and an orbiter-v2 direct drive, heavy enough I've had to restrict? its top speed from its default 500mm. The other printer is a Prusa MK3S+ I've about $1500 USD in. It works nice _now_ but came with a high leakage hot block some gorilla had over tightened and stripped the heat break threads, but is slow if fed at cura's default 60mm speeds. So what should I do next? That includes blowing it all away and starting over. I have another rock64. and a kvm swithch on an Amazon truck, be here tomorrow. That may be my best bet, a separate rock64 and octoprint for each printer. That at least looks like it might work. Find a 10+ amp 5 volt supply to run a bunch of the korean boards. If the kvm switch works. Awaiting advice.? Thank you. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From jfong at ms4.hinet.net Mon Aug 29 04:00:10 2022 From: jfong at ms4.hinet.net (Jach Feng) Date: Mon, 29 Aug 2022 01:00:10 -0700 (PDT) Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> Message-ID: Chris Angelico ? 2022?8?29? ?????1:58:58 [UTC+8] ?????? > On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > > > > Richard Damon ? 2022?8?29? ?????10:47:08 [UTC+8] ?????? > > > On 8/27/22 7:42 AM, Mark Bourne wrote: > > > > Jach Feng wrote: > > > >> I have two files: test.py and test2.py > > > >> --test.py-- > > > >> x = 2 > > > >> def foo(): > > > >> print(x) > > > >> foo() > > > >> > > > >> x = 3 > > > >> foo() > > > >> > > > >> --test2.py-- > > > >> from test import * > > > >> x = 4 > > > >> foo() > > > >> > > > >> ----- > > > >> Run test.py under Winows8.1, I get the expected result: > > > >> e:\MyDocument>py test.py > > > >> 2 > > > >> 3 > > > >> > > > >> But when run test2.py, the result is not my expected 2,3,4:-( > > > >> e:\MyDocument>py test2.py > > > >> 2 > > > >> 3 > > > >> 3 > > > >> > > > >> What to do? > > > > > > > > `from test import *` does not link the names in `test2` to those in > > > > `test`. It just binds objects bound to names in `test` to the same > > > > names in `test2`. A bit like doing: > > > > > > > > import test > > > > x = test.x > > > > foo = test.foo > > > > del test > > > > > > > > Subsequently assigning a different object to `x` in one module does > > > > not affect the object assigned to `x` in the other module. So `x = 4` > > > > in `test2.py` does not affect the object assigned to `x` in `test.py` > > > > - that's still `3`. If you want to do that, you need to import `test` > > > > and assign to `test.x`, for example: > > > > > > > > import test > > > > test.x = 4 > > > > test.foo() > > > > > > > Yes, fundamental issue is that the statement > > > > > > from x import y > > > > > > makes a binding in this module to the object CURRECTLY bound to x.y to > > > the name y, but if x.y gets rebound, this module does not track the changes. > > > > > > You can mutate the object x.y and see the changes, but not rebind it. > > > > > > If you need to see rebindings, you can't use the "from x import y" form, > > > or at a minimum do it as: > > > > > > > > > import x > > > > > > from x import y > > > > > > then later to get rebindings to x.y do a > > > > > > y = x.y > > > > > > to rebind to the current x.y object. > > > > > > -- > > > Richard Damon > > Yes, an extra "import x" will solve my problem too! Sometimes I am wondering why "from x import y" hides x? hum...can't figure out the reason:-) > > > "from x import y" doesn't hide x - it just grabs y. Python does what > you tell it to. :) > > ChrisA But I had heard people say that "from x import y" did import the whole x module into memory, just as "import x" did, not "grabs y" only. Is this correct? --Jach From nntp.mbourne at spamgourmet.com Mon Aug 29 06:40:33 2022 From: nntp.mbourne at spamgourmet.com (Mark Bourne) Date: Mon, 29 Aug 2022 11:40:33 +0100 Subject: How to make a variable's late binding crosses the module boundary? References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> Message-ID: Jach Feng wrote: > Chris Angelico ? 2022?8?29? ?????1:58:58 [UTC+8] ?????? >> On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: >>> >>> Richard Damon ? 2022?8?29? ?????10:47:08 [UTC+8] ?????? >>>> On 8/27/22 7:42 AM, Mark Bourne wrote: >>>>> Jach Feng wrote: >>>>>> I have two files: test.py and test2.py >>>>>> --test.py-- >>>>>> x = 2 >>>>>> def foo(): >>>>>> print(x) >>>>>> foo() >>>>>> >>>>>> x = 3 >>>>>> foo() >>>>>> >>>>>> --test2.py-- >>>>>> from test import * >>>>>> x = 4 >>>>>> foo() >>>>>> >>>>>> ----- >>>>>> Run test.py under Winows8.1, I get the expected result: >>>>>> e:\MyDocument>py test.py >>>>>> 2 >>>>>> 3 >>>>>> >>>>>> But when run test2.py, the result is not my expected 2,3,4:-( >>>>>> e:\MyDocument>py test2.py >>>>>> 2 >>>>>> 3 >>>>>> 3 >>>>>> >>>>>> What to do? >>>>> >>>>> `from test import *` does not link the names in `test2` to those in >>>>> `test`. It just binds objects bound to names in `test` to the same >>>>> names in `test2`. A bit like doing: >>>>> >>>>> import test >>>>> x = test.x >>>>> foo = test.foo >>>>> del test >>>>> >>>>> Subsequently assigning a different object to `x` in one module does >>>>> not affect the object assigned to `x` in the other module. So `x = 4` >>>>> in `test2.py` does not affect the object assigned to `x` in `test.py` >>>>> - that's still `3`. If you want to do that, you need to import `test` >>>>> and assign to `test.x`, for example: >>>>> >>>>> import test >>>>> test.x = 4 >>>>> test.foo() >>>>> >>>> Yes, fundamental issue is that the statement >>>> >>>> from x import y >>>> >>>> makes a binding in this module to the object CURRECTLY bound to x.y to >>>> the name y, but if x.y gets rebound, this module does not track the changes. >>>> >>>> You can mutate the object x.y and see the changes, but not rebind it. >>>> >>>> If you need to see rebindings, you can't use the "from x import y" form, >>>> or at a minimum do it as: >>>> >>>> >>>> import x >>>> >>>> from x import y >>>> >>>> then later to get rebindings to x.y do a >>>> >>>> y = x.y >>>> >>>> to rebind to the current x.y object. >>>> >>>> -- >>>> Richard Damon >>> Yes, an extra "import x" will solve my problem too! Sometimes I am wondering why "from x import y" hides x? hum...can't figure out the reason:-) >>> >> "from x import y" doesn't hide x - it just grabs y. Python does what >> you tell it to. :) >> >> ChrisA > But I had heard people say that "from x import y" did import the whole x module into memory, just as "import x" did, not "grabs y" only. Is this correct? `from x import y` does import the whole module x into memory, and adds it to `sys.modules`. But it only binds the name `y` in the namespace of module doing the import (and it binds it to the value of `x.y` at the time the import is done - it doesn't magically keep them in sync if one or the other is later reassigned). The point about the whole module being imported is that you don't save any memory by using `from x import y` to avoid importing some very large object `z` from `x`. Those other large objects might be needed by functions which have been imported (e.g. your `foo` function still needs `x` even if you haven't imported `x` - so it still needs to be loaded into memory) or might be imported and used by other modules importing `x`, so they still have to be loaded when any part of `x` is imported - they just don't have to be bound to names in the importing module's namespace. As Richard mentioned, if `x.y` is a mutable object (such as a list) you can still mutate that object (e.g. add/remove items) and those changes will be seen in both modules. That's because both are still bound to the same object and you're mutating that existing object. If you assign a new list to either, that won't be seen by the other. -- Mark. From nntp.mbourne at spamgourmet.com Mon Aug 29 07:02:01 2022 From: nntp.mbourne at spamgourmet.com (Mark Bourne) Date: Mon, 29 Aug 2022 12:02:01 +0100 Subject: What can I do about this? References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> <20220828233201.k3xmcpdnpn63wxeb@hjp.at> <96f5d626-5ebb-67a7-c7a7-1c6c5284fb1a@shentel.net> Message-ID: Roel Schroeven wrote: > Op 29/08/2022 om 2:55 schreef gene heskett: >> On 8/28/22 19:39, Peter J. Holzer wrote: >>> On 2022-08-28 18:40:17 -0400, gene heskett wrote: >>>> Persuant to my claim the py3.10 is busted, here is a sample. This is >>>> me, >>>> trying to make >>>> pronterface, inside a venv: When the package manager version will >>>> only run >>>> the gui-less "pronsole" >>>> but nothing else from that all python kit runs as it should or at all. >>>> ?From the package-managers install in /usr/share/doc/printrun-common/ I >>>> copied requirements.txt >>>> into the venv, and ran this command line: >>>> >>>> gene at rock64:~/venv$ pip3 install -r requirements.txt >>> You are almost certainly *not* in a venv here. First, your prompt >>> doesn't show the name of the venv, >> I've created that several times, as octoprint won''t run without it >> either. >> I found a way to autostart it on reboots and octoprint seems happy >> with it > I agree with Peter: it doesn't look as if you are invoking the pip3 in > the venv. Just making the venv-directory the current directory doesn't > activate it. > > As a diagnostic, ask the OS which pip3 is actually used: > > $ type -a pip3 > > Does that show the pip3 installed in the venv? Or the system-wide one? > If it's not the pip3 in the venv, well, then that's the problem (or at > least part of the problem). Solution: first check whether the venv > really contains 'pip3' (as opposed to eg. just 'pip'): list the contents > of the bin subdirectory of the venv. If not, use 'pip' or whatever > instead. Then to make sure you use the one in the venv, either activate > the venv or explicitly specify the path when invoking pip/pip3 (and > likewise for python/python3). > > So either (assuming you're using bash): > > $ source {path_to_venv}/bin/pip3? # activate the venv I think this first line should probably be: $ source {path_to_venv}/bin/activate # activate the venv i.e. with `activate` rather than `pip3`? > $ type -a pip3? # check whether now the correct pip3 is used > $ pip3 install -r requirements.txt? # finally invoke pip3 > > or: > > $ {path_to_venv}/bin/pip3 install -r requirements.txt > > Activating the venv is easier if you're going to use multiple commands > in the venv. Note that activating the venv only has effect on the > current shell; other shells are unaffected, and when you close the > current shell the venv is not activated anymore. > Explicitly using the path is easier for one-off calls, or in things like > crontab. > From wlfraed at ix.netcom.com Mon Aug 29 11:46:09 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Mon, 29 Aug 2022 11:46:09 -0400 Subject: What can I do about this? References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> <82b052e2-6842-a434-e727-7aeb6befdd35@shentel.net> Message-ID: On Mon, 29 Aug 2022 04:51:13 -0400, gene heskett declaimed the following: >What, on the arms, substitutes for the missing "*.whl" file? > In Debian -- apt-get https://packages.debian.org/stable/source/wxpython4.0 of course, that will install things system-wide, not in a virtual environment, and compatible with the system Python. For Bullseye, that is still Python 3.9! pi at rpi3bplus-1:~$ uname -a Linux rpi3bplus-1 5.15.32-v7+ #1538 SMP Thu Mar 31 19:38:48 BST 2022 armv7l GNU/Linux pi at rpi3bplus-1:~$ sudo apt search wxpython Sorting... Done Full Text Search... Done gnumed-client/stable 1.8.5+dfsg-2 all medical practice management - Client psychopy/stable 2020.2.10+dfsg-2 all environment for creating psychology stimuli in Python pyscanfcs/stable 0.3.6+ds-2+b1 armhf scientific tool for perpendicular line scanning FCS python3-genx/stable 3.0.2-1 armhf differential evolution algorithm for fitting python3-opengl/stable 3.1.5+dfsg-1 all Python bindings to OpenGL (Python 3) python3-pyface/stable 6.1.2-2 all traits-capable windowing framework python3-squaremap/stable 1:1.0.5-2 all wxPython control to display hierarchic data as nested squares python3-wxgtk-media4.0/stable 4.0.7+dfsg-10 armhf Python 3 interface to the wxWidgets Cross-platform C++ GUI toolkit (wx.media) python3-wxgtk-webview4.0/stable 4.0.7+dfsg-10 armhf Python 3 interface to the wxWidgets Cross-platform C++ GUI toolkit (wx.html2) python3-wxgtk4.0/stable 4.0.7+dfsg-10 armhf Python 3 interface to the wxWidgets Cross-platform C++ GUI toolkit soundgrain/stable 6.0.1-2 all Graphical interface to control granular sound synthesis modules wxglade/stable 1.0.1-1 all GUI designer written in Python with wxPython wxpython-tools/stable 4.0.7+dfsg-10 all Tools from the wxPython distribution pi at rpi3bplus-1:~$ pi at rpi3bplus-1:~$ sudo apt install python3-wxgtk4.0 Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 Suggested packages: wx3.0-doc The following NEW packages will be installed: libwxbase3.0-0v5 libwxgtk3.0-gtk3-0v5 python3-wxgtk4.0 0 upgraded, 3 newly installed, 0 to remove and 161 not upgraded. Need to get 10.5 MB of archives. After this operation, 51.6 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libwxbase3.0-0v5 armhf 3.0.5.1+dfsg-2 [918 kB] Get:2 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libwxgtk3.0-gtk3-0v5 armhf 3.0.5.1+dfsg-2 [3650 kB] Get:3 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf python3-wxgtk4.0 armhf 4.0.7+dfsg-10 [5970 kB] Fetched 10.5 MB in 8s (1346 kB/s) Selecting previously unselected package libwxbase3.0-0v5:armhf. (Reading database ... 175515 files and directories currently installed.) Preparing to unpack .../libwxbase3.0-0v5_3.0.5.1+dfsg-2_armhf.deb ... Unpacking libwxbase3.0-0v5:armhf (3.0.5.1+dfsg-2) ... Selecting previously unselected package libwxgtk3.0-gtk3-0v5:armhf. Preparing to unpack .../libwxgtk3.0-gtk3-0v5_3.0.5.1+dfsg-2_armhf.deb ... Unpacking libwxgtk3.0-gtk3-0v5:armhf (3.0.5.1+dfsg-2) ... Selecting previously unselected package python3-wxgtk4.0. Preparing to unpack .../python3-wxgtk4.0_4.0.7+dfsg-10_armhf.deb ... Unpacking python3-wxgtk4.0 (4.0.7+dfsg-10) ... Setting up libwxbase3.0-0v5:armhf (3.0.5.1+dfsg-2) ... Setting up libwxgtk3.0-gtk3-0v5:armhf (3.0.5.1+dfsg-2) ... Setting up python3-wxgtk4.0 (4.0.7+dfsg-10) ... Processing triggers for libc-bin (2.31-13+rpt2+rpi1+deb11u2) ... pi at rpi3bplus-1:~$ Or... You wait until somebody builds a Python3.10 ARMHF compatible wheel. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From rosuav at gmail.com Mon Aug 29 12:45:39 2022 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 30 Aug 2022 02:45:39 +1000 Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> Message-ID: On Tue, 30 Aug 2022 at 02:38, Jach Feng wrote: > > Chris Angelico ? 2022?8?29? ?????1:58:58 [UTC+8] ?????? > > On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > > > > > > Richard Damon ? 2022?8?29? ?????10:47:08 [UTC+8] ?????? > > > > On 8/27/22 7:42 AM, Mark Bourne wrote: > > > > > Jach Feng wrote: > > > > >> I have two files: test.py and test2.py > > > > >> --test.py-- > > > > >> x = 2 > > > > >> def foo(): > > > > >> print(x) > > > > >> foo() > > > > >> > > > > >> x = 3 > > > > >> foo() > > > > >> > > > > >> --test2.py-- > > > > >> from test import * > > > > >> x = 4 > > > > >> foo() > > > > >> > > > > >> ----- > > > > >> Run test.py under Winows8.1, I get the expected result: > > > > >> e:\MyDocument>py test.py > > > > >> 2 > > > > >> 3 > > > > >> > > > > >> But when run test2.py, the result is not my expected 2,3,4:-( > > > > >> e:\MyDocument>py test2.py > > > > >> 2 > > > > >> 3 > > > > >> 3 > > > > >> > > > > >> What to do? > > > > > > > > > > `from test import *` does not link the names in `test2` to those in > > > > > `test`. It just binds objects bound to names in `test` to the same > > > > > names in `test2`. A bit like doing: > > > > > > > > > > import test > > > > > x = test.x > > > > > foo = test.foo > > > > > del test > > > > > > > > > > Subsequently assigning a different object to `x` in one module does > > > > > not affect the object assigned to `x` in the other module. So `x = 4` > > > > > in `test2.py` does not affect the object assigned to `x` in `test.py` > > > > > - that's still `3`. If you want to do that, you need to import `test` > > > > > and assign to `test.x`, for example: > > > > > > > > > > import test > > > > > test.x = 4 > > > > > test.foo() > > > > > > > > > Yes, fundamental issue is that the statement > > > > > > > > from x import y > > > > > > > > makes a binding in this module to the object CURRECTLY bound to x.y to > > > > the name y, but if x.y gets rebound, this module does not track the changes. > > > > > > > > You can mutate the object x.y and see the changes, but not rebind it. > > > > > > > > If you need to see rebindings, you can't use the "from x import y" form, > > > > or at a minimum do it as: > > > > > > > > > > > > import x > > > > > > > > from x import y > > > > > > > > then later to get rebindings to x.y do a > > > > > > > > y = x.y > > > > > > > > to rebind to the current x.y object. > > > > > > > > -- > > > > Richard Damon > > > Yes, an extra "import x" will solve my problem too! Sometimes I am wondering why "from x import y" hides x? hum...can't figure out the reason:-) > > > > > "from x import y" doesn't hide x - it just grabs y. Python does what > > you tell it to. :) > > > > ChrisA > But I had heard people say that "from x import y" did import the whole x module into memory, just as "import x" did, not "grabs y" only. Is this correct? > In order to do any sort of import, Python has to run the whole module. But after that, something gets set in your module so that you can get access to it. import x # is kinda like go_and_run("x") x = fetch_module("x") from x import y # is kinda like go_and_run("x") y = fetch_module("x").y Either way, the whole module gets run, but then there's an assignment into your module that depends on what you're importing. ChrisA From roel at roelschroeven.net Mon Aug 29 12:50:19 2022 From: roel at roelschroeven.net (Roel Schroeven) Date: Mon, 29 Aug 2022 18:50:19 +0200 Subject: What can I do about this? In-Reply-To: References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> <20220828233201.k3xmcpdnpn63wxeb@hjp.at> <96f5d626-5ebb-67a7-c7a7-1c6c5284fb1a@shentel.net> Message-ID: <209019f7-4118-081d-a55c-64d5a5b89da9@roelschroeven.net> Mark Bourne schreef op 29/08/2022 om 13:02: > Roel Schroeven wrote: > > $ source {path_to_venv}/bin/pip3? # activate the venv > > I think this first line should probably be: > > $ source {path_to_venv}/bin/activate # activate the venv > > i.e. with `activate` rather than `pip3`? Oops, yes, of course. Thank you for the correction! -- "In the old days, writers used to sit in front of a typewriter and stare out of the window. Nowadays, because of the marvels of convergent technology, the thing you type on and the window you stare out of are now the same thing.? -- Douglas Adams From gheskett at shentel.net Mon Aug 29 13:43:18 2022 From: gheskett at shentel.net (gene heskett) Date: Mon, 29 Aug 2022 13:43:18 -0400 Subject: What can I do about this? In-Reply-To: References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> <20220828233201.k3xmcpdnpn63wxeb@hjp.at> <96f5d626-5ebb-67a7-c7a7-1c6c5284fb1a@shentel.net> Message-ID: On 8/29/22 12:50, Mark Bourne wrote: > Roel Schroeven wrote: >> Op 29/08/2022 om 2:55 schreef gene heskett: >>> On 8/28/22 19:39, Peter J. Holzer wrote: >>>> On 2022-08-28 18:40:17 -0400, gene heskett wrote: >>>>> Persuant to my claim the py3.10 is busted, here is a sample. This >>>>> is me, >>>>> trying to make >>>>> pronterface, inside a venv: When the package manager version will >>>>> only run >>>>> the gui-less "pronsole" >>>>> but nothing else from that all python kit runs as it should or at >>>>> all. >>>>> ?From the package-managers install in >>>>> /usr/share/doc/printrun-common/ I >>>>> copied requirements.txt >>>>> into the venv, and ran this command line: >>>>> >>>>> gene at rock64:~/venv$ pip3 install -r requirements.txt >>>> You are almost certainly *not* in a venv here. First, your prompt >>>> doesn't show the name of the venv, >>> I've created that several times, as octoprint won''t run without it >>> either. >>> I found a way to autostart it on reboots and octoprint seems happy >>> with it >> I agree with Peter: it doesn't look as if you are invoking the pip3 >> in the venv. Just making the venv-directory the current directory >> doesn't activate it. >> >> As a diagnostic, ask the OS which pip3 is actually used: >> >> $ type -a pip3 >> >> Does that show the pip3 installed in the venv? Or the system-wide >> one? If it's not the pip3 in the venv, well, then that's the problem >> (or at least part of the problem). Solution: first check whether the >> venv really contains 'pip3' (as opposed to eg. just 'pip'): list the >> contents of the bin subdirectory of the venv. If not, use 'pip' or >> whatever instead. Then to make sure you use the one in the venv, >> either activate the venv or explicitly specify the path when invoking >> pip/pip3 (and likewise for python/python3). >> >> So either (assuming you're using bash): >> >> $ source {path_to_venv}/bin/pip3? # activate the venv > > I think this first line should probably be: > > $ source {path_to_venv}/bin/activate? # activate the venv > > i.e. with `activate` rather than `pip3`? > >> $ type -a pip3? # check whether now the correct pip3 is used >> $ pip3 install -r requirements.txt? # finally invoke pip3 >> >> or: >> >> $ {path_to_venv}/bin/pip3 install -r requirements.txt That got me to showstopper #2: (lengthy warniing) (venv) gene at rock64:~/printrun/Printrun$ ./venv/bin/pip3 install -r requirements.txt Ignoring pyobjc-framework-Cocoa: markers 'sys_platform == "darwin"' don't match your environment Ignoring pyreadline: markers 'sys_platform == "win32"' don't match your environment Requirement already satisfied: pyserial>=3.0 in ./venv/lib/python3.10/site-packages (from -r requirements.txt (line 1)) (3.5) Collecting wxPython==4.1.0 ? Using cached wxPython-4.1.0.tar.gz (65.8 MB) ? Preparing metadata (setup.py) ... done Collecting numpy>=1.8.2 ? Using cached numpy-1.23.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (13.9 MB) Requirement already satisfied: pyglet>=1.1 in ./venv/lib/python3.10/site-packages (from -r requirements.txt (line 4)) (1.5.26) Collecting cffi ? Using cached cffi-1.15.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (449 kB) Collecting cairocffi ? Using cached cairocffi-1.3.0.tar.gz (88 kB) ? Preparing metadata (setup.py) ... done Collecting cairosvg>=1.0.9 ? Using cached CairoSVG-2.5.2-py3-none-any.whl (45 kB) Collecting psutil>=2.1 ? Using cached psutil-5.9.1-cp310-cp310-linux_aarch64.whl Collecting lxml>=2.9.1 ? Using cached lxml-4.9.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl (6.6 MB) Collecting appdirs>=1.4.0 ? Using cached appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB) Collecting dbus-python>=1.2.0 ? Using cached dbus-python-1.2.18.tar.gz (578 kB) ? Preparing metadata (setup.py) ... done Collecting pillow ? Using cached Pillow-9.2.0-cp310-cp310-manylinux_2_28_aarch64.whl (3.1 MB) Collecting six ? Using cached six-1.16.0-py2.py3-none-any.whl (11 kB) Collecting pycparser ? Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB) Collecting cssselect2 ? Using cached cssselect2-0.6.0-py3-none-any.whl (15 kB) Collecting tinycss2 ? Using cached tinycss2-1.1.1-py3-none-any.whl (21 kB) Collecting defusedxml ? Using cached defusedxml-0.7.1-py2.py3-none-any.whl (25 kB) Requirement already satisfied: webencodings in ./venv/lib/python3.10/site-packages (from cssselect2->cairosvg>=1.0.9->-r requirements.txt (line 7)) (0.5.1) Using legacy 'setup.py install' for wxPython, since package 'wheel' is not installed. Using legacy 'setup.py install' for cairocffi, since package 'wheel' is not installed. Using legacy 'setup.py install' for dbus-python, since package 'wheel' is not installed. Installing collected packages: dbus-python, appdirs, tinycss2, six, pycparser, psutil, pillow, numpy, lxml, defusedxml, wxPython, cssselect2, cffi, cairocffi, cairosvg ? Running setup.py install for dbus-python ... error ? error: subprocess-exited-with-error ? ? Running setup.py install for dbus-python did not run successfully. ? ? exit code: 1 ? ??> [166 lines of output] ????? running install /home/gene/printrun/Printrun/venv/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. ??????? warnings.warn( ????? running build ????? creating /tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/build ????? creating /tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/build/temp.linux-aarch64-3.10 ????? checking whether make supports nested variables... yes ????? checking whether to enable maintainer-specific portions of Makefiles... no ????? checking for gcc... gcc ????? checking whether the C compiler works... yes ????? checking for C compiler default output file name... a.out ????? checking for suffix of executables... ????? checking whether we are cross compiling... no ????? checking for suffix of object files... o ????? checking whether we are using the GNU C compiler... yes ????? checking whether gcc accepts -g... yes ????? checking for gcc option to accept ISO C89... none needed ????? checking whether gcc understands -c and -o together... yes ????? checking how to run the C preprocessor... gcc -E ????? checking for grep that handles long lines and -e... /usr/bin/grep ????? checking for egrep... /usr/bin/grep -E ????? checking for ANSI C header files... yes ????? checking for sys/types.h... yes ????? checking for sys/stat.h... yes ????? checking for stdlib.h... yes ????? checking for string.h... yes ????? checking for memory.h... yes ????? checking for strings.h... yes ????? checking for inttypes.h... yes ????? checking for stdint.h... yes ????? checking for unistd.h... yes ????? checking minix/config.h usability... no ????? checking minix/config.h presence... no ????? checking for minix/config.h... no ????? checking whether it is safe to define __EXTENSIONS__... yes ????? checking for a BSD-compatible install... /usr/bin/install -c ????? checking whether build environment is sane... yes ????? checking for a thread-safe mkdir -p... /usr/bin/mkdir -p ????? checking for gawk... no ????? checking for mawk... mawk ????? checking whether make sets $(MAKE)... yes ????? checking whether make supports the include directive... yes (GNU style) ????? checking whether UID '1000' is supported by ustar format... yes ????? checking whether GID '1000' is supported by ustar format... yes ????? checking how to create a ustar tar archive... gnutar ????? checking dependency style of gcc... gcc3 ????? checking build system type... aarch64-unknown-linux-gnu ????? checking host system type... aarch64-unknown-linux-gnu ????? checking for native Windows host... no ????? checking how to print strings... printf ????? checking for a sed that does not truncate output... /usr/bin/sed ????? checking for fgrep... /usr/bin/grep -F ????? checking for ld used by gcc... /usr/bin/ld ????? checking if the linker (/usr/bin/ld) is GNU ld... yes ????? checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B ????? checking the name lister (/usr/bin/nm -B) interface... BSD nm ????? checking whether ln -s works... yes ????? checking the maximum length of command line arguments... 1572864 ????? checking how to convert aarch64-unknown-linux-gnu file names to aarch64-unknown-linux-gnu format... func_convert_file_noop ????? checking how to convert aarch64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop ????? checking for /usr/bin/ld option to reload object files... -r ????? checking for objdump... objdump ????? checking how to recognize dependent libraries... pass_all ????? checking for dlltool... no ????? checking how to associate runtime and link libraries... printf %s\n ????? checking for ar... ar ????? checking for archiver @FILE support... @ ????? checking for strip... strip ????? checking for ranlib... ranlib ????? checking command to parse /usr/bin/nm -B output from gcc object... ok ????? checking for sysroot... no ????? checking for a working dd... /usr/bin/dd ????? checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1 ????? checking for mt... mt ????? checking if mt is a manifest tool... no ????? checking for dlfcn.h... yes ????? checking for objdir... .libs ????? checking if gcc supports -fno-rtti -fno-exceptions... no ????? checking for gcc option to produce PIC... -fPIC -DPIC ????? checking if gcc PIC flag -fPIC -DPIC works... yes ????? checking if gcc static flag -static works... yes ????? checking if gcc supports -c -o file.o... yes ????? checking if gcc supports -c -o file.o... (cached) yes ????? checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes ????? checking whether -lc should be explicitly linked in... no ????? checking dynamic linker characteristics... GNU/Linux ld.so ????? checking how to hardcode library paths into programs... immediate ????? checking whether stripping libraries is possible... yes ????? checking if libtool supports shared libraries... yes ????? checking whether to build shared libraries... yes ????? checking whether to build static libraries... no ????? checking for inline... inline ????? checking for gawk... (cached) mawk ????? checking for python... /home/gene/printrun/Printrun/venv/bin/python3 ????? checking for a version of Python >= '2.1.0'... yes ????? checking for a version of Python >= '2.7'... yes ????? checking for the distutils Python package... yes ????? checking for Python include path... :1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives ????? :1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead ????? :1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives ????? :1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead ????? -I/usr/include/python3.10 ????? checking for Python library path... :4: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives ????? :4: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead ????? :3: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives ????? :3: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead ????? :2: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives ????? :2: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead ????? -L/usr/lib/aarch64-linux-gnu -lpython3.10 ????? checking for Python site-packages path... :1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives ????? :1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead ????? /home/gene/printrun/Printrun/venv/lib/python3.10/site-packages ????? checking python extra libraries... :1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives ????? :1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead ????? -lcrypt -ldl? -lm -lm ????? checking python extra linking flags... :1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives ????? :1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead ????? -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions ????? checking consistency of all components of python development environment... yes ????? checking for python version... 3.10 ????? checking for python platform... linux ????? checking for python script directory... ${prefix}/lib/python3.10/site-packages ????? checking for python extension module directory... ${exec_prefix}/lib/python3.10/site-packages ????? :1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives ????? checking python3 module: sphinx... no ????? checking python3 module: sphinx_rtd_theme... no ????? checking for dbus-run-session... /usr/bin/dbus-run-session ????? checking for pkg-config... /usr/bin/pkg-config ????? checking pkg-config is at least version 0.9.0... yes ????? checking for dbus-1 >= 1.8... no ????? configure: error: Package requirements (dbus-1 >= 1.8) were not met: ????? No package 'dbus-1' found ????? Consider adjusting the PKG_CONFIG_PATH environment variable if you ????? installed software in a non-standard prefix. ????? Alternatively, you may set the environment variables DBUS_CFLAGS ????? and DBUS_LIBS to avoid the need to call pkg-config. ????? See the pkg-config man page for more details. ????? Traceback (most recent call last): ??????? File "", line 2, in ??????? File "", line 34, in ??????? File "/tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/setup.py", line 85, in ????????? setup( ??????? File "/home/gene/printrun/Printrun/venv/lib/python3.10/site-packages/setuptools/__init__.py", line 153, in setup ????????? return distutils.core.setup(**attrs) ??????? File "/usr/lib/python3.10/distutils/core.py", line 148, in setup ????????? dist.run_commands() ??????? File "/usr/lib/python3.10/distutils/dist.py", line 966, in run_commands ????????? self.run_command(cmd) ??????? File "/usr/lib/python3.10/distutils/dist.py", line 985, in run_command ????????? cmd_obj.run() ??????? File "/home/gene/printrun/Printrun/venv/lib/python3.10/site-packages/setuptools/command/install.py", line 68, in run ????????? return orig.install.run(self) ??????? File "/usr/lib/python3.10/distutils/command/install.py", line 619, in run ????????? self.run_command('build') ??????? File "/usr/lib/python3.10/distutils/cmd.py", line 313, in run_command ????????? self.distribution.run_command(command) ??????? File "/usr/lib/python3.10/distutils/dist.py", line 985, in run_command ????????? cmd_obj.run() ??????? File "/tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/setup.py", line 56, in run ????????? subprocess.check_call([ ??????? File "/usr/lib/python3.10/subprocess.py", line 369, in check_call ????????? raise CalledProcessError(retcode, cmd) ????? subprocess.CalledProcessError: Command '['/tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/configure', '--disable-maintainer-mode', 'PYTHON=/home/gene/printrun/Printrun/venv/bin/python3', '--prefix=/tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/build/temp.linux-aarch64-3.10/prefix']' returned non-zero exit status 1. ????? [end of output] ? note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure ? Encountered error while trying to install package. ??> dbus-python note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure. (venv) gene at rock64:~/printrun/Printrun$ There is help there, but to me its engrish. Next fix? >> >> Activating the venv is easier if you're going to use multiple >> commands in the venv. Note that activating the venv only has effect >> on the current shell; other shells are unaffected, and when you close >> the current shell the venv is not activated anymore. >> Explicitly using the path is easier for one-off calls, or in things >> like crontab. >> Thank you Mark Bourne, this looks like actual progress in what has turned into a cast iron bitch. I'll not touch that shell till the next advice is tendered. However "echo $PKG_CONFIG_PATH" is null in this venv. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From hjp-python at hjp.at Mon Aug 29 14:45:12 2022 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 29 Aug 2022 20:45:12 +0200 Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> Message-ID: <20220829184512.ecfifxamjnqxmipz@hjp.at> On 2022-08-29 11:40:33 +0100, Mark Bourne wrote: > Jach Feng wrote: > > Chris Angelico ? 2022?8?29? ?????1:58:58 [UTC+8] ?????? > > > On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > > > > Sometimes I am wondering why "from x import y" hides x? > > > > hum...can't figure out the reason:-) > > > > > > > "from x import y" doesn't hide x - it just grabs y. Python does > > > what you tell it to. :) > > > > > But I had heard people say that "from x import y" did import the > > whole x module into memory, just as "import x" did, not "grabs y" > > only. Is this correct? > > `from x import y` does import the whole module x into memory, and adds > it to `sys.modules`. But it only binds the name `y` in the namespace > of module doing the import (and it binds it to the value of `x.y` at > the time the import is done I think this should be rephrased. "`x.y` at the time the import is done" implies that at this time the name `x` does exist in the current namespace. Which then leads to the conclusion that this name must be hidden later. But I don't think this is the case. The module is imported but it isn't bound to any name in the current (global) namespace (obviously there must be some variable bound to it, but that's probably a local variable in the importer and it isn't called `x`). Then the object bound to the name `y` in the loaed module is bound to the name `y` in the current namespace. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From hjp-python at hjp.at Mon Aug 29 15:06:21 2022 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 29 Aug 2022 21:06:21 +0200 Subject: What can I do about this? In-Reply-To: References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> <20220828233201.k3xmcpdnpn63wxeb@hjp.at> <96f5d626-5ebb-67a7-c7a7-1c6c5284fb1a@shentel.net> Message-ID: <20220829190621.yyktkpsxdci6foas@hjp.at> On 2022-08-29 13:43:18 -0400, gene heskett wrote: > On 8/29/22 12:50, Mark Bourne wrote: > > Roel Schroeven wrote: > > > $ pip3 install -r requirements.txt? # finally invoke pip3 > > > > > > or: > > > > > > $ {path_to_venv}/bin/pip3 install -r requirements.txt > That got me to showstopper #2: (lengthy warniing) > [...] > ????? checking for dbus-1 >= 1.8... no > ????? configure: error: Package requirements (dbus-1 >= 1.8) were not met: > > ????? No package 'dbus-1' found Since this message comes from configure, it is probably looking for the development version of the dbus library here. apt search dbus-1 reveals (among other things): libdbus-1-dev/jammy 1.12.20-2ubuntu4 amd64 simple interprocess messaging system (development headers) (this is on Ubuntu, so the version number is probably different, but the package name should be the same as on Debian.) So you invoke apt install libdbus-1-dev and try again. At which point you will probably discove another missing library. Rinse and repeat. Ideally the README should mention such dependencies, but since the exact names of the packages depend on the distribution, it will often be vague unless you happen to use the same distribution as the developer. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From hjp-python at hjp.at Mon Aug 29 15:07:42 2022 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 29 Aug 2022 21:07:42 +0200 Subject: What can I do about this? In-Reply-To: References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> <20220828233201.k3xmcpdnpn63wxeb@hjp.at> <96f5d626-5ebb-67a7-c7a7-1c6c5284fb1a@shentel.net> Message-ID: <20220829190742.uplsrfkvdrlwngzl@hjp.at> On 2022-08-29 11:12:17 -0400, gene heskett wrote: > I've not had to deal with venv's before. Can more than one of these > venv things peacefully coexist? Yes. Having multiple venvs is the main reason for their existence. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From mmontgomery at levado.to Mon Aug 29 14:10:05 2022 From: mmontgomery at levado.to (Meredith Montgomery) Date: Mon, 29 Aug 2022 15:10:05 -0300 Subject: Coffee References: Message-ID: <86fshe2a6a.fsf@levado.to> ram at zedat.fu-berlin.de (Stefan Ram) writes: > |Python's obviously a great tool for all kinds of programming things, > |and I would say if you're only gonna use one programming > |language in your live, Python will probably the right one. > Brian Kernighan > > I transcribed this from the recent video > "Coffee with Brian Kernighan". Sounds reasonable. I have been learning Python bit by bit simply because there seems to be no other way to talk to university people. But somehow I am so in love with Lisp that it makes me sort of blind because sometimes I feel more productive in Python simply because I'm always using it. When I can write Lisp, I do it, but often I feel like I'm a role-playing TCP Slow Start or something like that. From mmontgomery at levado.to Mon Aug 29 14:18:24 2022 From: mmontgomery at levado.to (Meredith Montgomery) Date: Mon, 29 Aug 2022 15:18:24 -0300 Subject: on GNU EMACS's python-mode, loading entire buffer Message-ID: <86y1v6zzf3.fsf@levado.to> Perhaps this isn't the right newsgroup, but I kinda feel I will find more GNU EMACS users running the native python-mode here than in GNU EMACS newsgroups. Not every GNU EMACS user cares about Python. (Right?) A sort of a complaint is that when I used to run GNU EMACS 24.3.1, I'd open a file.py and simply say C-c C-c and it would ask me if I wanted a dedicated process, load a REPL load my entire buffer. Now in 27.1, things are different. I say C-c C-c and it tells me to start the process with C-c C-p. I mean --- is that the most polite thing to do? I feel like it's telling me --- go send this buffer yourself! I also don't know how to start a dedicated process. (Sometimes I want two REPLs. You know, you can get never get enough.) I would bet all of this and more is available, but I don't even know which book to read. Would you point me in the right direction? I would also be interested in a command that restarts the REPL afresh and reloads my buffer --- sort of like keyboard's [F5] of the IDLE. From nntp.mbourne at spamgourmet.com Mon Aug 29 17:38:37 2022 From: nntp.mbourne at spamgourmet.com (Mark Bourne) Date: Mon, 29 Aug 2022 22:38:37 +0100 Subject: What can I do about this? References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> <20220828233201.k3xmcpdnpn63wxeb@hjp.at> <96f5d626-5ebb-67a7-c7a7-1c6c5284fb1a@shentel.net> Message-ID: gene heskett wrote: > On 8/29/22 12:50, Mark Bourne wrote: >> Roel Schroeven wrote: >>> Op 29/08/2022 om 2:55 schreef gene heskett: >>>> On 8/28/22 19:39, Peter J. Holzer wrote: >>>>> On 2022-08-28 18:40:17 -0400, gene heskett wrote: >>>>>> Persuant to my claim the py3.10 is busted, here is a sample. This >>>>>> is me, >>>>>> trying to make >>>>>> pronterface, inside a venv: When the package manager version will >>>>>> only run >>>>>> the gui-less "pronsole" >>>>>> but nothing else from that all python kit runs as it should or at >>>>>> all. >>>>>> ?From the package-managers install in >>>>>> /usr/share/doc/printrun-common/ I >>>>>> copied requirements.txt >>>>>> into the venv, and ran this command line: >>>>>> >>>>>> gene at rock64:~/venv$ pip3 install -r requirements.txt >>>>> You are almost certainly *not* in a venv here. First, your prompt >>>>> doesn't show the name of the venv, >>>> I've created that several times, as octoprint won''t run without it >>>> either. >>>> I found a way to autostart it on reboots and octoprint seems happy >>>> with it >>> I agree with Peter: it doesn't look as if you are invoking the pip3 >>> in the venv. Just making the venv-directory the current directory >>> doesn't activate it. >>> >>> As a diagnostic, ask the OS which pip3 is actually used: >>> >>> $ type -a pip3 >>> >>> Does that show the pip3 installed in the venv? Or the system-wide >>> one? If it's not the pip3 in the venv, well, then that's the problem >>> (or at least part of the problem). Solution: first check whether the >>> venv really contains 'pip3' (as opposed to eg. just 'pip'): list the >>> contents of the bin subdirectory of the venv. If not, use 'pip' or >>> whatever instead. Then to make sure you use the one in the venv, >>> either activate the venv or explicitly specify the path when invoking >>> pip/pip3 (and likewise for python/python3). >>> >>> So either (assuming you're using bash): >>> >>> $ source {path_to_venv}/bin/pip3? # activate the venv >> >> I think this first line should probably be: >> >> $ source {path_to_venv}/bin/activate? # activate the venv >> >> i.e. with `activate` rather than `pip3`? >> >>> $ type -a pip3? # check whether now the correct pip3 is used >>> $ pip3 install -r requirements.txt? # finally invoke pip3 >>> >>> or: >>> >>> $ {path_to_venv}/bin/pip3 install -r requirements.txt > That got me to showstopper #2: (lengthy warniing) > > (venv) gene at rock64:~/printrun/Printrun$ ./venv/bin/pip3 install -r > requirements.txt > Ignoring pyobjc-framework-Cocoa: markers 'sys_platform == "darwin"' > don't match your environment > Ignoring pyreadline: markers 'sys_platform == "win32"' don't match your > environment > Requirement already satisfied: pyserial>=3.0 in > ./venv/lib/python3.10/site-packages (from -r requirements.txt (line 1)) > (3.5) > Collecting wxPython==4.1.0 > ? Using cached wxPython-4.1.0.tar.gz (65.8 MB) > ? Preparing metadata (setup.py) ... done > Collecting numpy>=1.8.2 > ? Using cached > numpy-1.23.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (13.9 > MB) > Requirement already satisfied: pyglet>=1.1 in > ./venv/lib/python3.10/site-packages (from -r requirements.txt (line 4)) > (1.5.26) > Collecting cffi > ? Using cached > cffi-1.15.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl > (449 kB) > Collecting cairocffi > ? Using cached cairocffi-1.3.0.tar.gz (88 kB) > ? Preparing metadata (setup.py) ... done > Collecting cairosvg>=1.0.9 > ? Using cached CairoSVG-2.5.2-py3-none-any.whl (45 kB) > Collecting psutil>=2.1 > ? Using cached psutil-5.9.1-cp310-cp310-linux_aarch64.whl > Collecting lxml>=2.9.1 > ? Using cached > lxml-4.9.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl > (6.6 MB) > Collecting appdirs>=1.4.0 > ? Using cached appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB) > Collecting dbus-python>=1.2.0 > ? Using cached dbus-python-1.2.18.tar.gz (578 kB) > ? Preparing metadata (setup.py) ... done > Collecting pillow > ? Using cached Pillow-9.2.0-cp310-cp310-manylinux_2_28_aarch64.whl (3.1 > MB) > Collecting six > ? Using cached six-1.16.0-py2.py3-none-any.whl (11 kB) > Collecting pycparser > ? Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB) > Collecting cssselect2 > ? Using cached cssselect2-0.6.0-py3-none-any.whl (15 kB) > Collecting tinycss2 > ? Using cached tinycss2-1.1.1-py3-none-any.whl (21 kB) > Collecting defusedxml > ? Using cached defusedxml-0.7.1-py2.py3-none-any.whl (25 kB) > Requirement already satisfied: webencodings in > ./venv/lib/python3.10/site-packages (from > cssselect2->cairosvg>=1.0.9->-r requirements.txt (line 7)) (0.5.1) > Using legacy 'setup.py install' for wxPython, since package 'wheel' is > not installed. > Using legacy 'setup.py install' for cairocffi, since package 'wheel' is > not installed. > Using legacy 'setup.py install' for dbus-python, since package 'wheel' > is not installed. > Installing collected packages: dbus-python, appdirs, tinycss2, six, > pycparser, psutil, pillow, numpy, lxml, defusedxml, wxPython, > cssselect2, cffi, cairocffi, cairosvg > ? Running setup.py install for dbus-python ... error > ? error: subprocess-exited-with-error > > ? ? Running setup.py install for dbus-python did not run successfully. > ? ? exit code: 1 > ? ??> [166 lines of output] > ????? running install > /home/gene/printrun/Printrun/venv/lib/python3.10/site-packages/setuptools/command/install.py:34: > SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build > and pip and other standards-based tools. > ??????? warnings.warn( > ????? running build > ????? creating > /tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/build > > ????? creating > /tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/build/temp.linux-aarch64-3.10 > > ????? checking whether make supports nested variables... yes > ????? checking whether to enable maintainer-specific portions of > Makefiles... no > ????? checking for gcc... gcc > ????? checking whether the C compiler works... yes > ????? checking for C compiler default output file name... a.out > ????? checking for suffix of executables... > ????? checking whether we are cross compiling... no > ????? checking for suffix of object files... o > ????? checking whether we are using the GNU C compiler... yes > ????? checking whether gcc accepts -g... yes > ????? checking for gcc option to accept ISO C89... none needed > ????? checking whether gcc understands -c and -o together... yes > ????? checking how to run the C preprocessor... gcc -E > ????? checking for grep that handles long lines and -e... /usr/bin/grep > ????? checking for egrep... /usr/bin/grep -E > ????? checking for ANSI C header files... yes > ????? checking for sys/types.h... yes > ????? checking for sys/stat.h... yes > ????? checking for stdlib.h... yes > ????? checking for string.h... yes > ????? checking for memory.h... yes > ????? checking for strings.h... yes > ????? checking for inttypes.h... yes > ????? checking for stdint.h... yes > ????? checking for unistd.h... yes > ????? checking minix/config.h usability... no > ????? checking minix/config.h presence... no > ????? checking for minix/config.h... no > ????? checking whether it is safe to define __EXTENSIONS__... yes > ????? checking for a BSD-compatible install... /usr/bin/install -c > ????? checking whether build environment is sane... yes > ????? checking for a thread-safe mkdir -p... /usr/bin/mkdir -p > ????? checking for gawk... no > ????? checking for mawk... mawk > ????? checking whether make sets $(MAKE)... yes > ????? checking whether make supports the include directive... yes (GNU > style) > ????? checking whether UID '1000' is supported by ustar format... yes > ????? checking whether GID '1000' is supported by ustar format... yes > ????? checking how to create a ustar tar archive... gnutar > ????? checking dependency style of gcc... gcc3 > ????? checking build system type... aarch64-unknown-linux-gnu > ????? checking host system type... aarch64-unknown-linux-gnu > ????? checking for native Windows host... no > ????? checking how to print strings... printf > ????? checking for a sed that does not truncate output... /usr/bin/sed > ????? checking for fgrep... /usr/bin/grep -F > ????? checking for ld used by gcc... /usr/bin/ld > ????? checking if the linker (/usr/bin/ld) is GNU ld... yes > ????? checking for BSD- or MS-compatible name lister (nm)... > /usr/bin/nm -B > ????? checking the name lister (/usr/bin/nm -B) interface... BSD nm > ????? checking whether ln -s works... yes > ????? checking the maximum length of command line arguments... 1572864 > ????? checking how to convert aarch64-unknown-linux-gnu file names to > aarch64-unknown-linux-gnu format... func_convert_file_noop > ????? checking how to convert aarch64-unknown-linux-gnu file names to > toolchain format... func_convert_file_noop > ????? checking for /usr/bin/ld option to reload object files... -r > ????? checking for objdump... objdump > ????? checking how to recognize dependent libraries... pass_all > ????? checking for dlltool... no > ????? checking how to associate runtime and link libraries... printf %s\n > ????? checking for ar... ar > ????? checking for archiver @FILE support... @ > ????? checking for strip... strip > ????? checking for ranlib... ranlib > ????? checking command to parse /usr/bin/nm -B output from gcc > object... ok > ????? checking for sysroot... no > ????? checking for a working dd... /usr/bin/dd > ????? checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1 > ????? checking for mt... mt > ????? checking if mt is a manifest tool... no > ????? checking for dlfcn.h... yes > ????? checking for objdir... .libs > ????? checking if gcc supports -fno-rtti -fno-exceptions... no > ????? checking for gcc option to produce PIC... -fPIC -DPIC > ????? checking if gcc PIC flag -fPIC -DPIC works... yes > ????? checking if gcc static flag -static works... yes > ????? checking if gcc supports -c -o file.o... yes > ????? checking if gcc supports -c -o file.o... (cached) yes > ????? checking whether the gcc linker (/usr/bin/ld) supports shared > libraries... yes > ????? checking whether -lc should be explicitly linked in... no > ????? checking dynamic linker characteristics... GNU/Linux ld.so > ????? checking how to hardcode library paths into programs... immediate > ????? checking whether stripping libraries is possible... yes > ????? checking if libtool supports shared libraries... yes > ????? checking whether to build shared libraries... yes > ????? checking whether to build static libraries... no > ????? checking for inline... inline > ????? checking for gawk... (cached) mawk > ????? checking for python... /home/gene/printrun/Printrun/venv/bin/python3 > ????? checking for a version of Python >= '2.1.0'... yes > ????? checking for a version of Python >= '2.7'... yes > ????? checking for the distutils Python package... yes > ????? checking for Python include path... :1: > DeprecationWarning: The distutils package is deprecated and slated for > removal in Python 3.12. Use setuptools or check PEP 632 for potential > alternatives > ????? :1: DeprecationWarning: The distutils.sysconfig module is > deprecated, use sysconfig instead > ????? :1: DeprecationWarning: The distutils package is > deprecated and slated for removal in Python 3.12. Use setuptools or > check PEP 632 for potential alternatives > ????? :1: DeprecationWarning: The distutils.sysconfig module is > deprecated, use sysconfig instead > ????? -I/usr/include/python3.10 > ????? checking for Python library path... :4: > DeprecationWarning: The distutils package is deprecated and slated for > removal in Python 3.12. Use setuptools or check PEP 632 for potential > alternatives > ????? :4: DeprecationWarning: The distutils.sysconfig module is > deprecated, use sysconfig instead > ????? :3: DeprecationWarning: The distutils package is > deprecated and slated for removal in Python 3.12. Use setuptools or > check PEP 632 for potential alternatives > ????? :3: DeprecationWarning: The distutils.sysconfig module is > deprecated, use sysconfig instead > ????? :2: DeprecationWarning: The distutils package is > deprecated and slated for removal in Python 3.12. Use setuptools or > check PEP 632 for potential alternatives > ????? :2: DeprecationWarning: The distutils.sysconfig module is > deprecated, use sysconfig instead > ????? -L/usr/lib/aarch64-linux-gnu -lpython3.10 > ????? checking for Python site-packages path... :1: > DeprecationWarning: The distutils package is deprecated and slated for > removal in Python 3.12. Use setuptools or check PEP 632 for potential > alternatives > ????? :1: DeprecationWarning: The distutils.sysconfig module is > deprecated, use sysconfig instead > ????? /home/gene/printrun/Printrun/venv/lib/python3.10/site-packages > ????? checking python extra libraries... :1: > DeprecationWarning: The distutils package is deprecated and slated for > removal in Python 3.12. Use setuptools or check PEP 632 for potential > alternatives > ????? :1: DeprecationWarning: The distutils.sysconfig module is > deprecated, use sysconfig instead > ????? -lcrypt -ldl? -lm -lm > ????? checking python extra linking flags... :1: > DeprecationWarning: The distutils package is deprecated and slated for > removal in Python 3.12. Use setuptools or check PEP 632 for potential > alternatives > ????? :1: DeprecationWarning: The distutils.sysconfig module is > deprecated, use sysconfig instead > ????? -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions > ????? checking consistency of all components of python development > environment... yes > ????? checking for python version... 3.10 > ????? checking for python platform... linux > ????? checking for python script directory... > ${prefix}/lib/python3.10/site-packages > ????? checking for python extension module directory... > ${exec_prefix}/lib/python3.10/site-packages > ????? :1: DeprecationWarning: The distutils package is > deprecated and slated for removal in Python 3.12. Use setuptools or > check PEP 632 for potential alternatives > ????? checking python3 module: sphinx... no > ????? checking python3 module: sphinx_rtd_theme... no > ????? checking for dbus-run-session... /usr/bin/dbus-run-session > ????? checking for pkg-config... /usr/bin/pkg-config > ????? checking pkg-config is at least version 0.9.0... yes > ????? checking for dbus-1 >= 1.8... no > ????? configure: error: Package requirements (dbus-1 >= 1.8) were not met: > > ????? No package 'dbus-1' found > > ????? Consider adjusting the PKG_CONFIG_PATH environment variable if you > ????? installed software in a non-standard prefix. > > ????? Alternatively, you may set the environment variables DBUS_CFLAGS > ????? and DBUS_LIBS to avoid the need to call pkg-config. > ????? See the pkg-config man page for more details. > ????? Traceback (most recent call last): > ??????? File "", line 2, in > ??????? File "", line 34, in > ??????? File > "/tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/setup.py", > line 85, in > ????????? setup( > ??????? File > "/home/gene/printrun/Printrun/venv/lib/python3.10/site-packages/setuptools/__init__.py", > line 153, in setup > ????????? return distutils.core.setup(**attrs) > ??????? File "/usr/lib/python3.10/distutils/core.py", line 148, in setup > ????????? dist.run_commands() > ??????? File "/usr/lib/python3.10/distutils/dist.py", line 966, in > run_commands > ????????? self.run_command(cmd) > ??????? File "/usr/lib/python3.10/distutils/dist.py", line 985, in > run_command > ????????? cmd_obj.run() > ??????? File > "/home/gene/printrun/Printrun/venv/lib/python3.10/site-packages/setuptools/command/install.py", > line 68, in run > ????????? return orig.install.run(self) > ??????? File "/usr/lib/python3.10/distutils/command/install.py", line > 619, in run > ????????? self.run_command('build') > ??????? File "/usr/lib/python3.10/distutils/cmd.py", line 313, in > run_command > ????????? self.distribution.run_command(command) > ??????? File "/usr/lib/python3.10/distutils/dist.py", line 985, in > run_command > ????????? cmd_obj.run() > ??????? File > "/tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/setup.py", > line 56, in run > ????????? subprocess.check_call([ > ??????? File "/usr/lib/python3.10/subprocess.py", line 369, in check_call > ????????? raise CalledProcessError(retcode, cmd) > ????? subprocess.CalledProcessError: Command > '['/tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/configure', > '--disable-maintainer-mode', > 'PYTHON=/home/gene/printrun/Printrun/venv/bin/python3', > '--prefix=/tmp/pip-install-2zqkrisr/dbus-python_6642a4f761e742d49b75c39a953ceb6b/build/temp.linux-aarch64-3.10/prefix']' > returned non-zero exit status 1. > ????? [end of output] > > ? note: This error originates from a subprocess, and is likely not a > problem with pip. > error: legacy-install-failure > > ? Encountered error while trying to install package. > ??> dbus-python > > note: This is an issue with the package mentioned above, not pip. > hint: See above for output from the failure. > (venv) gene at rock64:~/printrun/Printrun$ > > > There is help there, but to me its engrish. Next fix? >>> >>> Activating the venv is easier if you're going to use multiple >>> commands in the venv. Note that activating the venv only has effect >>> on the current shell; other shells are unaffected, and when you close >>> the current shell the venv is not activated anymore. >>> Explicitly using the path is easier for one-off calls, or in things >>> like crontab. >>> > > Thank you Mark Bourne, this looks like actual progress in what has > turned into a cast iron bitch. > I'll not touch that shell till the next advice is tendered. However > "echo $PKG_CONFIG_PATH" is > null in this venv. To be fair, it was Roel Schroeven who posted the steps and the part you're quoting here, and others had pointed in the direction of the venv not having been activated - I just posted a correction to one of Roel's commands. Sorry, I can't help much with your actual problem, but hopefully others can. -- Mark. From drsalists at gmail.com Mon Aug 29 19:43:37 2022 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 29 Aug 2022 16:43:37 -0700 Subject: Coffee In-Reply-To: <86fshe2a6a.fsf@levado.to> References: <86fshe2a6a.fsf@levado.to> Message-ID: On Mon, Aug 29, 2022 at 1:10 PM Meredith Montgomery wrote: > ram at zedat.fu-berlin.de (Stefan Ram) writes: > > > |Python's obviously a great tool for all kinds of programming things, > > |and I would say if you're only gonna use one programming > > |language in your live, Python will probably the right one. > > Brian Kernighan > > > > I transcribed this from the recent video > > "Coffee with Brian Kernighan". > > Sounds reasonable. I have been learning Python bit by bit simply > because there seems to be no other way to talk to university people. > But somehow I am so in love with Lisp that it makes me sort of blind > because sometimes I feel more productive in Python simply because I'm > always using it. When I can write Lisp, I do it, but often I feel like > I'm a role-playing TCP Slow Start or something like that. > ISTR hearing that Python and Lisp are pretty similar semantically - not because Python copied it, but because similar thinking went into the design of each. From gheskett at shentel.net Mon Aug 29 20:21:32 2022 From: gheskett at shentel.net (gene heskett) Date: Mon, 29 Aug 2022 20:21:32 -0400 Subject: What can I do about this? In-Reply-To: <20220829190621.yyktkpsxdci6foas@hjp.at> References: <38cb2d9f-9e89-39aa-341a-eee27296a523@shentel.net> <20220828233201.k3xmcpdnpn63wxeb@hjp.at> <96f5d626-5ebb-67a7-c7a7-1c6c5284fb1a@shentel.net> <20220829190621.yyktkpsxdci6foas@hjp.at> Message-ID: <493a141f-5c31-2abb-c424-a8355386bed9@shentel.net> On 8/29/22 15:12, Peter J. Holzer wrote: > On 2022-08-29 13:43:18 -0400, gene heskett wrote: >> On 8/29/22 12:50, Mark Bourne wrote: >>> Roel Schroeven wrote: >>>> $ pip3 install -r requirements.txt? # finally invoke pip3 >>>> >>>> or: >>>> >>>> $ {path_to_venv}/bin/pip3 install -r requirements.txt >> That got me to showstopper #2: (lengthy warniing) >> > [...] >> ????? checking for dbus-1 >= 1.8... no >> ????? configure: error: Package requirements (dbus-1 >= 1.8) were not met: >> >> ????? No package 'dbus-1' found > Since this message comes from configure, it is probably looking > for the development version of the dbus library here. > > apt search dbus-1 > > reveals (among other things): > > libdbus-1-dev/jammy 1.12.20-2ubuntu4 amd64 > simple interprocess messaging system (development headers) > > (this is on Ubuntu, so the version number is probably different, but the > package name should be the same as on Debian.) > > So you invoke > > apt install libdbus-1-dev > > and try again. At which point you will probably discove another missing > library. Rinse and repeat. You left out the wash, ;) The next missing dev was a gtk thingy, but search only returned one .dev. One for spice-gtk, and that pulled in around 100 more packages, and now its stuck on wxPython for about 35 minutes and, way into swap, like several hundred megs & growing. I even went to its keyboard and shut down chromium to give it more play room. Didn't seem to help though. But it hasn't errored, and swap is going? down a meg here and there. Pounding that poor, cheap sd card all to hell I expect. At some point, I'll unpack a startech usb3-sata cable and try an SSD. But I'll not disturb this just yet. Works well on an r-pi4b where I can build linuxcnc in half an hour from the git pull. I run a 3/4 ton, 80 yo Sheldon lathe with linuxcnc just to see if I could do it, first on an rpi3b. Had to build my own realtime kernel and figure out how to install it because I wanted to do it on a pi, got black holed on their forum. The amazing part is that the tarball to install it is only 28 megs uncompressed. > Ideally the README should mention such dependencies, but since the exact > names of the packages depend on the distribution, it will often be vague > unless you happen to use the same distribution as the developer. Your forgot to mention that each packager is working in his own sound proof booth, so each comes up with a somewhat different way to pound that square peg into a 7 point hole. ;o)> It was obviously going to take hours so I took a nap and 4 hours later it had left out a few things but kept on going until it hit another showstopper while building wxPython-4.1. At which point it spit out 2600 some lines of backtrace. Ending with this: ???? In file included from ../../../../sip/cpp/sip_glcanvaswxGLContext.cpp:10: ????? ../../../../sip/cpp/sipAPI_glcanvas.h:865:198: error: ?wxGLCanvasName? was not declared in this scope; did you mean ?wxGLCanvas?? ??????? 865 |???? wxGLCanvas(wxWindow *parent, const wxGLAttributes &dispAttrs, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxGLCanvasName, const wxPalette &palette=wxNullPalette) | ^~~~~~~~~~~~~~ | wxGLCanvas ????? Waf: Leaving directory `/tmp/pip-install-1myz6noi/wxpython_5fdcad39f0c544599dd49fdd522391f2/build/waf/3.1/gtk3' ????? Build failed ?????? -> task in '_glcanvas' failed with exit status 1 (run with -v to display more information) ?????? -> task in '_glcanvas' failed with exit status 1 (run with -v to display more information) ?????? -> task in '_glcanvas' failed with exit status 1 (run with -v to display more information) ?????? -> task in '_glcanvas' failed with exit status 1 (run with -v to display more information) ????? Command '"/home/gene/printrun/Printrun/venv/bin/python3" /tmp/pip-install-1myz6noi/wxpython_5fdcad39f0c544599dd49fdd522391f2/bin/waf-2.0.19 --wx_config=/tmp/pip-install-1myz6noi/wxpython_5fdcad39f0c544599dd49fdd522391f2/build/wxbld/gtk3/wx-config --gtk3 --python="/home/gene/printrun/Printrun/venv/bin/python3" --out=build/waf/3.1/gtk3 configure build ' failed with exit code 1. ????? Finished command: build_py (100m40.712s) ????? Finished command: build (171m37.482s) ????? Command '"/home/gene/printrun/Printrun/venv/bin/python3" -u build.py build' failed with exit code 1. ????? [end of output] ? note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure ? Encountered error while trying to install package. ??> wxPython note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure. ================ Now, I have the unpacked tarball of wxPython-4.2.0 sitting in /home/gene/src. Where would I mv it to to substituted for the 4.1 since 4.1 isn't quite ready for prime time? I changed the 1 to a 2 in requirements.txt, but that exited in a few seconds after it downloaded another copy of the tarball, with another error I have see before while trying to build it in /home/gene/src's/unpacked_tarball tree. paste of error: (venv) gene at rock64:~/printrun/Printrun$ ./venv/bin/pip3 install -r requirements.txt Ignoring pyobjc-framework-Cocoa: markers 'sys_platform == "darwin"' don't match your environment Ignoring pyreadline: markers 'sys_platform == "win32"' don't match your environment Requirement already satisfied: pyserial>=3.0 in ./venv/lib/python3.10/site-packages (from -r requirements.txt (line 1)) (3.5) Collecting wxPython==4.2.0 ? Using cached wxPython-4.2.0.tar.gz (71.0 MB) ? Preparing metadata (setup.py) ... error ? error: subprocess-exited-with-error ? ? python setup.py egg_info did not run successfully. ? ? exit code: 1 ? ??> [8 lines of output] ????? Traceback (most recent call last): ??????? File "", line 2, in ??????? File "", line 34, in ??????? File "/tmp/pip-install-x9vpdn0f/wxpython_75085d87ddc7455cb159bbbb95177417/setup.py", line 27, in ????????? from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName ??????? File "/tmp/pip-install-x9vpdn0f/wxpython_75085d87ddc7455cb159bbbb95177417/buildtools/config.py", line 30, in ????????? from attrdict import AttrDict ????? ModuleNotFoundError: No module named 'attrdict' ????? [end of output] ? note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed ? Encountered error while generating package metadata. ??> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. (venv) gene at rock64:~/printrun/Printrun$ I've found it , the src tarball.gz. In /home/gene/Downloads. Is that tarball updatable? Or should I ignore it & go back to wxPython-4.1? Is it fixable? > hp > Thanks Peter. Take care and stay well. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From jfong at ms4.hinet.net Mon Aug 29 21:02:53 2022 From: jfong at ms4.hinet.net (Jach Feng) Date: Mon, 29 Aug 2022 18:02:53 -0700 (PDT) Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> Message-ID: <6db8e7db-b3b9-46b9-a9c7-4cc608bc56een@googlegroups.com> Mark Bourne ? 2022?8?29? ?????6:40:59 [UTC+8] ?????? > Jach Feng wrote: > > Chris Angelico ? 2022?8?29? ?????1:58:58 [UTC+8] ?????? > >> On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > >>> > >>> Richard Damon ? 2022?8?29? ?????10:47:08 [UTC+8] ?????? > >>>> On 8/27/22 7:42 AM, Mark Bourne wrote: > >>>>> Jach Feng wrote: > >>>>>> I have two files: test.py and test2.py > >>>>>> --test.py-- > >>>>>> x = 2 > >>>>>> def foo(): > >>>>>> print(x) > >>>>>> foo() > >>>>>> > >>>>>> x = 3 > >>>>>> foo() > >>>>>> > >>>>>> --test2.py-- > >>>>>> from test import * > >>>>>> x = 4 > >>>>>> foo() > >>>>>> > >>>>>> ----- > >>>>>> Run test.py under Winows8.1, I get the expected result: > >>>>>> e:\MyDocument>py test.py > >>>>>> 2 > >>>>>> 3 > >>>>>> > >>>>>> But when run test2.py, the result is not my expected 2,3,4:-( > >>>>>> e:\MyDocument>py test2.py > >>>>>> 2 > >>>>>> 3 > >>>>>> 3 > >>>>>> > >>>>>> What to do? > >>>>> > >>>>> `from test import *` does not link the names in `test2` to those in > >>>>> `test`. It just binds objects bound to names in `test` to the same > >>>>> names in `test2`. A bit like doing: > >>>>> > >>>>> import test > >>>>> x = test.x > >>>>> foo = test.foo > >>>>> del test > >>>>> > >>>>> Subsequently assigning a different object to `x` in one module does > >>>>> not affect the object assigned to `x` in the other module. So `x = 4` > >>>>> in `test2.py` does not affect the object assigned to `x` in `test.py` > >>>>> - that's still `3`. If you want to do that, you need to import `test` > >>>>> and assign to `test.x`, for example: > >>>>> > >>>>> import test > >>>>> test.x = 4 > >>>>> test.foo() > >>>>> > >>>> Yes, fundamental issue is that the statement > >>>> > >>>> from x import y > >>>> > >>>> makes a binding in this module to the object CURRECTLY bound to x.y to > >>>> the name y, but if x.y gets rebound, this module does not track the changes. > >>>> > >>>> You can mutate the object x.y and see the changes, but not rebind it. > >>>> > >>>> If you need to see rebindings, you can't use the "from x import y" form, > >>>> or at a minimum do it as: > >>>> > >>>> > >>>> import x > >>>> > >>>> from x import y > >>>> > >>>> then later to get rebindings to x.y do a > >>>> > >>>> y = x.y > >>>> > >>>> to rebind to the current x.y object. > >>>> > >>>> -- > >>>> Richard Damon > >>> Yes, an extra "import x" will solve my problem too! Sometimes I am wondering why "from x import y" hides x? hum...can't figure out the reason:-) > >>> > >> "from x import y" doesn't hide x - it just grabs y. Python does what > >> you tell it to. :) > >> > >> ChrisA > > But I had heard people say that "from x import y" did import the whole x module into memory, just as "import x" did, not "grabs y" only. Is this correct? > `from x import y` does import the whole module x into memory, and adds > it to `sys.modules`. But it only binds the name `y` in the namespace of > module doing the import (and it binds it to the value of `x.y` at the > time the import is done - it doesn't magically keep them in sync if one > or the other is later reassigned). > > The point about the whole module being imported is that you don't save > any memory by using `from x import y` to avoid importing some very large > object `z` from `x`. Those other large objects might be needed by > functions which have been imported (e.g. your `foo` function still needs > `x` even if you haven't imported `x` - so it still needs to be loaded > into memory) or might be imported and used by other modules importing > `x`, so they still have to be loaded when any part of `x` is imported - > they just don't have to be bound to names in the importing module's > namespace. > > As Richard mentioned, if `x.y` is a mutable object (such as a list) you > can still mutate that object (e.g. add/remove items) and those changes > will be seen in both modules. That's because both are still bound to > the same object and you're mutating that existing object. If you assign > a new list to either, that won't be seen by the other. > > -- > Mark. When using dot notation to change variable, no matter if 'x.y' is a mutable or immutable object, the change will be seen in both modules except those early bindings. --Jach From gheskett at shentel.net Mon Aug 29 22:57:50 2022 From: gheskett at shentel.net (gene heskett) Date: Mon, 29 Aug 2022 22:57:50 -0400 Subject: venv questions Message-ID: Greetings all; The command to setup a venv, "python -m venv venv" has no man page that I have found. So I'm guessing that one of the venv's is the name of the one being created. Probably argv(3) in c parlance. What I am thinking about is setting up two venv's more or less named for the printer that copy of octoprint will administer, So how about some tutorial on creating the venv? But that might create another problem. how to differentiate the servers, both of which will want to use localhost:5000 to serve up their web pages we run things with. Suggested solutions? Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." ?-Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From rosuav at gmail.com Mon Aug 29 23:09:22 2022 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 30 Aug 2022 13:09:22 +1000 Subject: venv questions In-Reply-To: References: Message-ID: On Tue, 30 Aug 2022 at 12:59, gene heskett wrote: > > Greetings all; > > The command to setup a venv, "python -m venv venv" has no man page that > I have > found. > $ python3 -m venv --help usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear] [--upgrade] [--without-pip] [--prompt PROMPT] [--upgrade-deps] ENV_DIR [ENV_DIR ...] Creates virtual Python environments in one or more target directories. positional arguments: ENV_DIR A directory to create the environment in. (chomp all the explanation of options) ChrisA From rosuav at gmail.com Mon Aug 29 23:16:00 2022 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 30 Aug 2022 13:16:00 +1000 Subject: Running two separate servers (was Re: venv questions) In-Reply-To: References: Message-ID: On Tue, 30 Aug 2022 at 12:59, gene heskett wrote: > > But that might create another problem. how to differentiate the servers, > both of which > will want to use localhost:5000 to serve up their web pages we run > things with. > > Suggested solutions? This is nothing to do with venvs, so I'm forking the thread. By far the easiest way to differentiate them is to NOT have them both on localhost:5000. Depending on how you invoke the servers, you should be able to find a way to configure one (or both) of them to a different port; common methods include a "--port" argument, setting the PORT environment variable, and poking in the code to find the number 5000 and changing it to some other value. (Less common methods include poking in ctypes to find the number 5000 and changing it to some other value. Mentioned only because I realise the alternative interpretation of my previous comment.) Another method would be to change the "localhost" part. The standard for IP addresses is that 127.x.y.z means localhost, regardless of what x, y, and z are; so you could have one of them bind to 127.0.0.2 and the other to 127.0.0.3, which you could then use in your browser the same way (http://127.0.0.2:5000/ and http://127.0.0.3:5000/ respectively). But if you can't change anything else, you'll have to make the two processes cooperate in some way, or worst case, just make sure you shut one down before you start the other up. ChrisA From mmontgomery at levado.to Mon Aug 29 22:28:46 2022 From: mmontgomery at levado.to (Meredith Montgomery) Date: Mon, 29 Aug 2022 23:28:46 -0300 Subject: on GNU EMACS's python-mode, loading entire buffer References: <86y1v6zzf3.fsf@levado.to> <87zgfmyj0f.fsf@nightsong.com> Message-ID: <86sflezcpt.fsf@levado.to> Paul Rubin writes: > Meredith Montgomery writes: >> Now in 27.1, things are different. I say C-c C-c and it tells me to >> start the process with C-c C-p. I mean --- is that the most polite >> thing to do? I feel like it's telling me --- go send this buffer >> yourself! > > Hmm, I noticed that too, but I thought it was a change in python-mode > itself. I just got used to it. I didn't bother trying to chase it down. These little conveniences are so important. :-) > To start a new process, try C-u C-c C-p . Oh, thank you! From PythonList at DancesWithMice.info Tue Aug 30 00:05:43 2022 From: PythonList at DancesWithMice.info (dn) Date: Tue, 30 Aug 2022 16:05:43 +1200 Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: <20220829184512.ecfifxamjnqxmipz@hjp.at> References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> <20220829184512.ecfifxamjnqxmipz@hjp.at> Message-ID: <4dd1b949-cdd2-5b27-79ee-5f49fb26ea09@DancesWithMice.info> On 30/08/2022 06.45, Peter J. Holzer wrote: > The module is imported but it isn't bound to any name in the current > (global) namespace (obviously there must be some variable bound to it, but > that's probably a local variable in the importer and it isn't called > `x`). Then the object bound to the name `y` in the loaed module is bound > to the name `y` in the current namespace. Correct! Build module.py as: *** CONSTANT = 1 def func(): pass *** then in the terminal: *** Python 3.9.13 (main, May 18 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from module import func as f >>> locals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': , 'f': } >>> f >>> f.CONSTANT Traceback (most recent call last): File "", line 1, in AttributeError: 'function' object has no attribute 'CONSTANT' >>> module.CONSTANT Traceback (most recent call last): File "", line 1, in NameError: name 'module' is not defined # no mention of module and no access to CONSTANT >>> import module as m >>> locals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': , 'f': , 'm': } >>> m >>> m.func >>> m.CONSTANT 1 >>> module Traceback (most recent call last): File "", line 1, in NameError: name 'module' is not defined # name module is bound as m, and not available as module >>> import module >>> locals() {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': , '__spec__': None, '__annotations__': {}, '__builtins__': , 'f': , 'm': , 'module': } >>> module.func >>> module.CONSTANT 1 >>> module # now it is available # also notice how the function (func) now has three 'names'/access-methods but all lead to the same location *** -- Regards, =dn From gheskett at shentel.net Tue Aug 30 05:50:18 2022 From: gheskett at shentel.net (gene heskett) Date: Tue, 30 Aug 2022 05:50:18 -0400 Subject: Running two separate servers (was Re: venv questions) In-Reply-To: References: Message-ID: On 8/29/22 23:22, Chris Angelico wrote: > On Tue, 30 Aug 2022 at 12:59, gene heskett wrote: >> But that might create another problem. how to differentiate the servers, >> both of which >> will want to use localhost:5000 to serve up their web pages we run >> things with. >> >> Suggested solutions? > This is nothing to do with venvs, so I'm forking the thread. > > By far the easiest way to differentiate them is to NOT have them both > on localhost:5000. Depending on how you invoke the servers, you should > be able to find a way to configure one (or both) of them to a > different port; common methods include a "--port" argument, setting > the PORT environment variable, and poking in the code to find the > number 5000 and changing it to some other value. > > (Less common methods include poking in ctypes to find the number 5000 > and changing it to some other value. Mentioned only because I realise > the alternative interpretation of my previous comment.) > > Another method would be to change the "localhost" part. The standard > for IP addresses is that 127.x.y.z means localhost, regardless of what > x, y, and z are; so you could have one of them bind to 127.0.0.2 and > the other to 127.0.0.3, which you could then use in your browser the > same way (http://127.0.0.2:5000/ and http://127.0.0.3:5000/ > respectively). > > But if you can't change anything else, you'll have to make the two > processes cooperate in some way, or worst case, just make sure you > shut one down before you start the other up. > > ChrisA That is a limitation I'd druther not have to deal with Chris. I want two separate octoprint servers running with no interaction between them. So I'm thinking of venv's named rock64prusa, and rock64ender5+, each with "port#" on my local net. So chromium could have two tabs open, one to localhost:5000 and one to localhost:5001, totally independent of each other. I already have that in my /etc/hosts file. No dns resolving involved. And from snooping just now, the port # is set it /etc/default/octoprint, so copy /etc/default/octoprint to octoprint-prusa, and to octoprint-ender5+, do the same in /etc/init.d, and change the port # & venv name? in the -ender5+ version. Then reconfigure the ender5+ version to drive that printer. With the venv isolation, it should work, with a browser tab at localhost:5000 and another tab at localhost:5001, each pointing at its own directory tree in /home/gene. The separation is also because of the way linux finds usb facilities, the prusa is always /dev/ttyACM0 and the ender5+ is almost always /dev/ttyUSB0. in this case I've a 4 port usb hub with port disabling switches plugged into the rock64. One of the things I want to try is plugging in a startech usb3 to sata adapter with a small SSD plugged into it, and move the /tmp directory off that poor u-sd card to prolong its life. And each with its own input buffer that cura can see from here. The new cura 5.1 has its own set of problems, not being able to see octoprints defaulted input buffer hidden behind a dotted directory being a starter, toss in that it has no way to look at .. and that requires a user session of mc just to move the gcode produced to be printed from a local dir here to the input buffer of that instance of octoprint. Back at this come daylight.? Thank you Chris. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From rosuav at gmail.com Tue Aug 30 06:45:56 2022 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 30 Aug 2022 20:45:56 +1000 Subject: Running two separate servers (was Re: venv questions) In-Reply-To: References: Message-ID: On Tue, 30 Aug 2022 at 19:51, gene heskett wrote: > So I'm thinking of venv's named rock64prusa, and rock64ender5+, each with > "port#" on my local net. So chromium could have two tabs open, one to > localhost:5000 and one to localhost:5001, totally independent of each other. > As I said, that has absolutely nothing to do with venvs, so you'd have to figure out how to change their port numbers independently. (Although you could probably add an env var to the venv's activation script, if that would help.) ChrisA From Joseph.Schachner at Teledyne.com Tue Aug 30 13:26:24 2022 From: Joseph.Schachner at Teledyne.com (Schachner, Joseph (US)) Date: Tue, 30 Aug 2022 17:26:24 +0000 Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> <20220829184512.ecfifxamjnqxmipz@hjp.at> <4dd1b949-cdd2-5b27-79ee-5f49fb26ea09@DancesWithMice.info> Message-ID: The way we do this, is in main.py, call a "globalizer" function in each other file: # call globalizers to get shortcuts as global variables funcs.globalizer(interface, variable_dict) util.globalizer(interface, variable_dict) sd.globalizer(interface, variable_dict) tests.globalizer(interface, variable_dict) ut.globalizer(interface, variable_dict) Obviously, you may not need a shared interface in which case you can just pass the variable dictionary. In each file, you have a function: def globalizer(interface, variables_dict): # create global variables for this .py file for shared interface and the variables .... This works well, making sure separate python files shared exactly the same things we want to be global. ---- Joseph S. Teledyne Confidential; Commercially Sensitive Business Data -----Original Message----- From: Stefan Ram Sent: Tuesday, August 30, 2022 1:09 AM To: python-list at python.org Subject: Re: How to make a variable's late binding crosses the module boundary? dn writes: >Build module.py as: >*** >CONSTANT = 1 >def func(): > pass >*** >then in the terminal: >*** >Python 3.9.13 (main, May 18 2022, 00:00:00) [GCC 11.3.1 20220421 (Red >Hat 11.3.1-2)] on linux Type "help", "copyright", "credits" or >"license" for more information. >>>> from module import func as f In CPython one then can also: print( f.__globals__[ "CONSTANT" ]) import sys module = sys.modules[ f.__globals__[ "__name__" ]] print( module.CONSTANT ) CONSTANT = module.CONSTANT print( CONSTANT ) . From g.rwaga at gmail.com Tue Aug 30 11:09:21 2022 From: g.rwaga at gmail.com (George Rwaga) Date: Tue, 30 Aug 2022 10:09:21 -0500 Subject: Download Python 3.10.6 for windows Message-ID: I last installed an updated version of python more than a year back. I am trying to download (from https://www.python.org/downloads/ ) and install Python 3.10.6 for Windows - but I keep running into problems. 1. I installed Python 3.10.6 in the default directory C:\Users\xxxxx.xxxxx\AppData\local\programs\Python\Python310 After the installation, there was no shortcut on my desktop. I thought I would just go to Python310 and create a shortcut. But I am unable to find AppData. 2. I then decided to install Python3.10.6 in a customized directory C:\program files\Python\Python310 I am being asked to verify access to this directly. I went to properties, made what I thought were the relevant changes. But I keep getting asked to verify access. My R and RStudio are installed in C:\program files. How should I proceed? George -- From michael.stemper at gmail.com Tue Aug 30 12:49:34 2022 From: michael.stemper at gmail.com (Michael F. Stemper) Date: Tue, 30 Aug 2022 11:49:34 -0500 Subject: Coffee In-Reply-To: References: Message-ID: On 29/08/2022 07.16, Stefan Ram wrote: > |Python's obviously a great tool for all kinds of programming things, > |and I would say if you're only gonna use one programming > |language in your live, Python will probably the right one. > Brian Kernighan > > I transcribed this from the recent video > "Coffee with Brian Kernighan". For those who'd like to see the whole chat: -- Michael F. Stemper Deuteronomy 24:17 From python at mrabarnett.plus.com Tue Aug 30 16:18:03 2022 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 30 Aug 2022 21:18:03 +0100 Subject: Download Python 3.10.6 for windows In-Reply-To: References: Message-ID: <5c92ac75-0266-06cd-0c27-9251c8f4979b@mrabarnett.plus.com> On 2022-08-30 16:09, George Rwaga wrote: > I last installed an updated version of python more than a year back. I am > trying to download (from https://www.python.org/downloads/ ) and install > Python 3.10.6 for Windows - but I keep running into problems. > > 1. I installed Python 3.10.6 in the default directory > C:\Users\xxxxx.xxxxx\AppData\local\programs\Python\Python310 > After the installation, there was no shortcut on my desktop. I thought I > would just go to Python310 and create a shortcut. But I am unable to find > AppData. In the File Explorer window, select the View tab and turn on the Hidden Items checkbox. The AppData folder should then become visible. Alternatively, enter "%appdata%" in the path bar, and that should take you to a subfolder of the AppData folder. You can then navigate from there. > 2. I then decided to install Python3.10.6 in a customized directory > C:\program files\Python\Python310 > I am being asked to verify access to this directly. I went to properties, > made what I thought were the relevant changes. But I keep getting asked to > verify access. > > My R and RStudio are installed in C:\program files. > > How should I proceed? > From gheskett at shentel.net Tue Aug 30 16:58:37 2022 From: gheskett at shentel.net (gene heskett) Date: Tue, 30 Aug 2022 16:58:37 -0400 Subject: Running two separate servers (was Re: venv questions) In-Reply-To: References: Message-ID: <26159533-8cb9-8858-1ac3-e5397613ebce@shentel.net> On 8/30/22 06:52, Chris Angelico wrote: > On Tue, 30 Aug 2022 at 19:51, gene heskett wrote: >> So I'm thinking of venv's named rock64prusa, and rock64ender5+, each with >> "port#" on my local net. So chromium could have two tabs open, one to >> localhost:5000 and one to localhost:5001, totally independent of each other. >> > As I said, that has absolutely nothing to do with venvs, so you'd have > to figure out how to change their port numbers independently. > > (Although you could probably add an env var to the venv's activation > script, if that would help.) > > ChrisA The short script as /etc/default/octoprint has that PORT item. I see no reason it couldn't be renamed and edited to affect the desired separation. (venv) gene at rock64:~/printrun/Printrun/venv$ cat /etc/default/octoprint ============== # Configuration for /etc/init.d/octoprint # The init.d script will only run if this variable non-empty. OCTOPRINT_USER=gene # base directory to use, change this for cura in both copies so cura can see it on the /sshnet # make it unique and get rid of the dot. BASEDIR=/home/gene/.octoprint # configuration file to use, relocate this for uniqueness CONFIGFILE=/home/gene/.octoprint/config.yaml # On what port to run daemon, default is 5000, anything not it use for 2nd ender5+ version PORT=5000 # Path to the OctoPrint executable, you need to set this to match your installation! # change the venv to a unique name DAEMON=/home/gene/OctoPrint/venv/bin/octoprint # What arguments to pass to octoprint, usually no need to touch this DAEMON_ARGS="--port=$PORT" # Umask of files octoprint generates, Change this to 000 if running octoprint as its own, separate user UMASK=022 # Process priority, 0 here will result in a priority 20 process. # -2 ensures Octoprint has a slight priority over user processes. NICELEVEL=-2 # Should we run at startup? START=yes ====EOF==================== Edit two copies of this in defaults with individual names, Edit 2 copies of /etc/init.d/octoprint with unique names make two uniquely named venv's. The two should never meet nor interfere with each other. So far, I've got it running in a venv named prusa-mk3s. Now checking to see if it see's a gcode file uploaded directly from cura here on this machine. Short answer is no, octoprint cannot see an uploads directory in the prusa-mk3s directory. In fact, it cannot see, or even create a new uploads directory. But I made one with mc, put a gcode file there, not seen, got po'd and gave it 755 perms, bingo, it needed exec perms, and cura wasn't setting them. Chalk up another bitch at cura. Or at octoprint, gcode is a text file fur crying in the beer.? The rwXrwXrwX should not affect it IMO. I need another batch of cable clips to neaten up the ender5+, so let me see if it can do that. Now that I have the rules in hand, maybe I can make a second copy work at the same time. IF I can figure out how to make it use a unique name for its PID identifier . Might have to change a character in the launchers name w/o changing the script. Or better yet, rename the executable? IDK. And hour lateer, cable clips went nice and clean, so the first instance is working fine. And there isn't a PID for octoprint anyplace in /var unless its under the snakes umbrella. Progress, discovering bugs and work-arounds in octoprint. Now I'm waiting on the mail for parts. Among other things a bigger PSU for the rock64. See if that reduces the video glitches from usb activity. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From eryksun at gmail.com Tue Aug 30 17:06:32 2022 From: eryksun at gmail.com (Eryk Sun) Date: Tue, 30 Aug 2022 16:06:32 -0500 Subject: Download Python 3.10.6 for windows In-Reply-To: References: Message-ID: On 8/30/22, George Rwaga wrote: > > 1. I installed Python 3.10.6 in the default directory > C:\Users\xxxxx.xxxxx\AppData\local\programs\Python\Python310 > After the installation, there was no shortcut on my desktop. Shortcuts are created in the start menu. The installer doesn't modify the user's desktop or the desktop of all users, which many users don't want and would find annoying. Just copy the shortcuts from the start menu to the desktop if that's what you want. Right-click the icon in the start menu and choose to open the location. You can copy shortcuts from the opened Explorer window. > 2. I then decided to install Python3.10.6 in a customized directory > C:\program files\Python\Python310 > I am being asked to verify access to this directly. I went to properties, > made what I thought were the relevant changes. But I keep getting asked to > verify access. Installing to "Program Files" requires elevating to get administrator access. All users have the right to read and execute files in a directory created in "Program Files", but adding, removing, or deleting files and directories requires administrator access, as it should. From PythonList at DancesWithMice.info Tue Aug 30 17:52:03 2022 From: PythonList at DancesWithMice.info (dn) Date: Wed, 31 Aug 2022 09:52:03 +1200 Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> <20220829184512.ecfifxamjnqxmipz@hjp.at> <4dd1b949-cdd2-5b27-79ee-5f49fb26ea09@DancesWithMice.info> Message-ID: On 31/08/2022 05.26, Schachner, Joseph (US) wrote: > The way we do this, is in main.py, call a "globalizer" function in each other file: > > # call globalizers to get shortcuts as global variables > funcs.globalizer(interface, variable_dict) > util.globalizer(interface, variable_dict) > sd.globalizer(interface, variable_dict) > tests.globalizer(interface, variable_dict) > ut.globalizer(interface, variable_dict) > > Obviously, you may not need a shared interface in which case you can just pass the variable dictionary. > > In each file, you have a function: > def globalizer(interface, variables_dict): > # create global variables for this .py file for shared interface and the variables > .... > > This works well, making sure separate python files shared exactly the same things we want to be global. > > ---- Joseph S. > > Teledyne Confidential; Commercially Sensitive Business Data > > -----Original Message----- > From: Stefan Ram > Sent: Tuesday, August 30, 2022 1:09 AM > To: python-list at python.org > Subject: Re: How to make a variable's late binding crosses the module boundary? > > dn writes: >> Build module.py as: >> *** >> CONSTANT = 1 > >> def func(): >> pass >> *** > >> then in the terminal: >> *** >> Python 3.9.13 (main, May 18 2022, 00:00:00) [GCC 11.3.1 20220421 (Red >> Hat 11.3.1-2)] on linux Type "help", "copyright", "credits" or >> "license" for more information. >>>>> from module import func as f > > In CPython one then can also: > > print( f.__globals__[ "CONSTANT" ]) > import sys > module = sys.modules[ f.__globals__[ "__name__" ]] print( module.CONSTANT ) CONSTANT = module.CONSTANT print( CONSTANT ) The conversation seems to be wandering some way from the OP. Whereas both of these answers are clever (and I assume work), the question becomes: why would you want to do this? (especially as it looks ugly and 'smells' a bit convoluted). An example use-case from your experience? Delving into the list-archive, to get back to the OP: the first message in the thread quotes another message that's (apparently) not present. However, in there somewhere is: > from test import * So, the elephant-in-the-room has always been a very stinky 'code-smell' - which pretty much every text or web-tutorial will say is a bad idea. Why is a bad idea? Why is it there then? When to use it? [Socratic questioning] Same question, but the other way around: why has Python been equipped with modules, classes, functions, etc? To quote The Zen of Python: "Namespaces are one honking great idea -- let's do more of those!". Programming paradigms and architectural principles all contain reference and recommendation to independent code-units, coupling and cohesion, boundary crossing and interfaces (etc). Python doesn't enact a formal interface construct (thank you great, high, Python, gods!), but that doesn't remove the issues behind them (as the OP-code demonstrates). Instead it requires a Python-idiomatic approach. Should the question be: "how to I smash two namespaces into one and have it work 'my way'?", or should the question become "how does Python enable passing/retention of values between namespaces?". NB The OP likely reduced the 'problem' to 'minimum-code' for the benefit of the list, but what is the motivation behind it? Why would one want to be able to do this? Rationale? Use-case? Enquiring minds and all that... -- Regards, =dn From wlfraed at ix.netcom.com Tue Aug 30 16:07:25 2022 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Tue, 30 Aug 2022 16:07:25 -0400 Subject: venv questions References: Message-ID: On Mon, 29 Aug 2022 22:57:50 -0400, gene heskett declaimed the following: >Greetings all; > >The command to setup a venv, "python -m venv venv" has no man page that >I have >found. > https://docs.python.org/3/library/venv.html -- Wulfraed Dennis Lee Bieber AF6VN wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ From antoon.pardon at vub.be Wed Aug 31 03:38:19 2022 From: antoon.pardon at vub.be (Antoon Pardon) Date: Wed, 31 Aug 2022 09:38:19 +0200 Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> <20220829184512.ecfifxamjnqxmipz@hjp.at> <4dd1b949-cdd2-5b27-79ee-5f49fb26ea09@DancesWithMice.info> Message-ID: Op 30/08/2022 om 23:52 schreef dn: > The conversation seems to be wandering some way from the OP. Whereas > both of these answers are clever (and I assume work), the question > becomes: why would you want to do this? (especially as it looks ugly and > 'smells' a bit convoluted). An example use-case from your experience? > > > Delving into the list-archive, to get back to the OP: the first message > in the thread quotes another message that's (apparently) not present. > > However, in there somewhere is: > >> from test import * > So, the elephant-in-the-room has always been a very stinky 'code-smell' > - which pretty much every text or web-tutorial will say is a bad idea. No that is a red herring. If for some reason a variable in a module has to be (re)set after import time, it doesn't matter whether someone uses from module import * or from module import resetable_variable in both cases the module that did the import will not notice the change in the original module. focussing on the code smell, is leading the attention away from the problem. -- Antoon Pardon From PythonList at DancesWithMice.info Wed Aug 31 03:53:49 2022 From: PythonList at DancesWithMice.info (dn) Date: Wed, 31 Aug 2022 19:53:49 +1200 Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> <20220829184512.ecfifxamjnqxmipz@hjp.at> <4dd1b949-cdd2-5b27-79ee-5f49fb26ea09@DancesWithMice.info> Message-ID: <415b58d8-1994-5dc7-8212-268dc8de2893@DancesWithMice.info> On 31/08/2022 19.38, Antoon Pardon wrote: > > > Op 30/08/2022 om 23:52 schreef dn: >> The conversation seems to be wandering some way from the OP. Whereas >> both of these answers are clever (and I assume work), the question >> becomes: why would you want to do this? (especially as it looks ugly and >> 'smells' a bit convoluted). An example use-case from your experience? >> >> >> Delving into the list-archive, to get back to the OP: the first message >> in the thread quotes another message that's (apparently) not present. >> >> However, in there somewhere is: >> >>> from test import * >> So, the elephant-in-the-room has always been a very stinky 'code-smell' >> - which pretty much every text or web-tutorial will say is a bad idea. > > No that is a red herring. If for some reason a variable in a module has > to be (re)set after import time, it doesn't matter whether someone uses > > ??? from module import * > > or > > ??? from module import resetable_variable > > in both cases the module that did the import will not notice the change > in the original module. > > focussing on the code smell, is leading the attention away from the > problem. Are you the OP? The behavior has been shown to be exactly that which is (should be) expected. -- Regards, =dn From antoon.pardon at vub.be Wed Aug 31 04:06:56 2022 From: antoon.pardon at vub.be (Antoon Pardon) Date: Wed, 31 Aug 2022 10:06:56 +0200 Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: <415b58d8-1994-5dc7-8212-268dc8de2893@DancesWithMice.info> References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> <20220829184512.ecfifxamjnqxmipz@hjp.at> <4dd1b949-cdd2-5b27-79ee-5f49fb26ea09@DancesWithMice.info> <415b58d8-1994-5dc7-8212-268dc8de2893@DancesWithMice.info> Message-ID: <6d2ea0e5-8efe-4fbd-1395-a1d419b2fa79@vub.be> Op 31/08/2022 om 09:53 schreef dn: > On 31/08/2022 19.38, Antoon Pardon wrote: >> >> Op 30/08/2022 om 23:52 schreef dn: >>> The conversation seems to be wandering some way from the OP. Whereas >>> both of these answers are clever (and I assume work), the question >>> becomes: why would you want to do this? (especially as it looks ugly and >>> 'smells' a bit convoluted). An example use-case from your experience? >>> >>> >>> Delving into the list-archive, to get back to the OP: the first message >>> in the thread quotes another message that's (apparently) not present. >>> >>> However, in there somewhere is: >>> >>>> from test import * >>> So, the elephant-in-the-room has always been a very stinky 'code-smell' >>> - which pretty much every text or web-tutorial will say is a bad idea. >> No that is a red herring. If for some reason a variable in a module has >> to be (re)set after import time, it doesn't matter whether someone uses >> >> ??? from module import * >> >> or >> >> ??? from module import resetable_variable >> >> in both cases the module that did the import will not notice the change >> in the original module. >> >> focussing on the code smell, is leading the attention away from the >> problem. > Are you the OP? > > The behavior has been shown to be exactly that which is (should be) > expected. That doesn't contradict that the behaviour is a problem. What is expected (viewed as a language specification) and what is desired (viewed from what would solve the problem easily) can be at odds. -- Antoon Pardon. From g.rwaga at gmail.com Wed Aug 31 13:16:11 2022 From: g.rwaga at gmail.com (George Rwaga) Date: Wed, 31 Aug 2022 12:16:11 -0500 Subject: Download Python 3.10.6 for windows In-Reply-To: References: Message-ID: Thanks for the suggestions, Mrab and Eryk. Because my R and RStudio are under program files, for consistency I installed Python in C:\program files\Python\Python310. I updated to the latest version of Spyder in C:\program files\Spyder\Spyder5.3.3. As with R and RStudio, some Python and Spyder files were automatically installed in C:\Users\George.Rwaga\AppData\Local. I am not sure why the default for installing Python is C:\Users\xxxxx.xxxxx\AppData\local\programs\Python\Python310. Initial tests suggest Spyder 5.3.3 is working fine. The real test will probably come when I try to run some of my old code based on such sources as Python for Finance by Yves Hilpisch, a book by the same title by Yuxing Yan, Python for Data Analysis by Wes McKinney, etc. Again, thanks. George -- On Tue, Aug 30, 2022 at 4:06 PM Eryk Sun wrote: > On 8/30/22, George Rwaga wrote: > > > > 1. I installed Python 3.10.6 in the default directory > > C:\Users\xxxxx.xxxxx\AppData\local\programs\Python\Python310 > > After the installation, there was no shortcut on my desktop. > > Shortcuts are created in the start menu. The installer doesn't modify > the user's desktop or the desktop of all users, which many users don't > want and would find annoying. Just copy the shortcuts from the start > menu to the desktop if that's what you want. Right-click the icon in > the start menu and choose to open the location. You can copy shortcuts > from the opened Explorer window. > > > 2. I then decided to install Python3.10.6 in a customized directory > > C:\program files\Python\Python310 > > I am being asked to verify access to this directly. I went to properties, > > made what I thought were the relevant changes. But I keep getting asked > to > > verify access. > > Installing to "Program Files" requires elevating to get administrator > access. All users have the right to read and execute files in a > directory created in "Program Files", but adding, removing, or > deleting files and directories requires administrator access, as it > should. > From mmontgomery at levado.to Wed Aug 31 09:34:32 2022 From: mmontgomery at levado.to (Meredith Montgomery) Date: Wed, 31 Aug 2022 10:34:32 -0300 Subject: Coffee References: Message-ID: <86h71szgd3.fsf@levado.to> "Michael F. Stemper" writes: > On 29/08/2022 07.16, Stefan Ram wrote: >> |Python's obviously a great tool for all kinds of programming things, >> |and I would say if you're only gonna use one programming >> |language in your live, Python will probably the right one. >> Brian Kernighan >> I transcribed this from the recent video >> "Coffee with Brian Kernighan". > > For those who'd like to see the whole chat: > So kind of you! Thank you! From mmontgomery at levado.to Wed Aug 31 09:40:13 2022 From: mmontgomery at levado.to (Meredith Montgomery) Date: Wed, 31 Aug 2022 10:40:13 -0300 Subject: on GNU EMACS's python-mode, loading entire buffer References: <86y1v6zzf3.fsf@levado.to> Message-ID: <868rn4zg3m.fsf@levado.to> Meredith Montgomery writes: [...] > I would also be interested in a command that restarts the REPL afresh > and reloads my buffer --- sort of like keyboard's [F5] of the IDLE. A partial solution for this is the following procedure. --8<---------------cut here---------------start------------->8--- (defun python-revert-and-send-buffer-to-repl () "Revert current buffer and sends it to the Python REPL." (interactive) (revert-buffer "ignore-auto-no" "no-confirm") (python-shell-send-buffer)) --8<---------------cut here---------------end--------------->8--- We can map this to the F5-key and that improves things. But a restart of the REPL would be the ideal. (Sometimes we really want to start afresh. Sometimes. Most often we don't want that.) From nntp.mbourne at spamgourmet.com Wed Aug 31 14:43:09 2022 From: nntp.mbourne at spamgourmet.com (Mark Bourne) Date: Wed, 31 Aug 2022 19:43:09 +0100 Subject: How to make a variable's late binding crosses the module boundary? References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> <6db8e7db-b3b9-46b9-a9c7-4cc608bc56een@googlegroups.com> Message-ID: Jach Feng wrote: > Mark Bourne ? 2022?8?29? ?????6:40:59 [UTC+8] ?????? >> Jach Feng wrote: >>> Chris Angelico ? 2022?8?29? ?????1:58:58 [UTC+8] ?????? >>>> On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: >>>>> >>>>> Richard Damon ? 2022?8?29? ?????10:47:08 [UTC+8] ?????? >>>>>> On 8/27/22 7:42 AM, Mark Bourne wrote: >>>>>>> Jach Feng wrote: >>>>>>>> I have two files: test.py and test2.py >>>>>>>> --test.py-- >>>>>>>> x = 2 >>>>>>>> def foo(): >>>>>>>> print(x) >>>>>>>> foo() >>>>>>>> >>>>>>>> x = 3 >>>>>>>> foo() >>>>>>>> >>>>>>>> --test2.py-- >>>>>>>> from test import * >>>>>>>> x = 4 >>>>>>>> foo() >>>>>>>> >>>>>>>> ----- >>>>>>>> Run test.py under Winows8.1, I get the expected result: >>>>>>>> e:\MyDocument>py test.py >>>>>>>> 2 >>>>>>>> 3 >>>>>>>> >>>>>>>> But when run test2.py, the result is not my expected 2,3,4:-( >>>>>>>> e:\MyDocument>py test2.py >>>>>>>> 2 >>>>>>>> 3 >>>>>>>> 3 >>>>>>>> >>>>>>>> What to do? >>>>>>> >>>>>>> `from test import *` does not link the names in `test2` to those in >>>>>>> `test`. It just binds objects bound to names in `test` to the same >>>>>>> names in `test2`. A bit like doing: >>>>>>> >>>>>>> import test >>>>>>> x = test.x >>>>>>> foo = test.foo >>>>>>> del test >>>>>>> >>>>>>> Subsequently assigning a different object to `x` in one module does >>>>>>> not affect the object assigned to `x` in the other module. So `x = 4` >>>>>>> in `test2.py` does not affect the object assigned to `x` in `test.py` >>>>>>> - that's still `3`. If you want to do that, you need to import `test` >>>>>>> and assign to `test.x`, for example: >>>>>>> >>>>>>> import test >>>>>>> test.x = 4 >>>>>>> test.foo() >>>>>>> >>>>>> Yes, fundamental issue is that the statement >>>>>> >>>>>> from x import y >>>>>> >>>>>> makes a binding in this module to the object CURRECTLY bound to x.y to >>>>>> the name y, but if x.y gets rebound, this module does not track the changes. >>>>>> >>>>>> You can mutate the object x.y and see the changes, but not rebind it. >>>>>> >>>>>> If you need to see rebindings, you can't use the "from x import y" form, >>>>>> or at a minimum do it as: >>>>>> >>>>>> >>>>>> import x >>>>>> >>>>>> from x import y >>>>>> >>>>>> then later to get rebindings to x.y do a >>>>>> >>>>>> y = x.y >>>>>> >>>>>> to rebind to the current x.y object. >>>>>> >>>>>> -- >>>>>> Richard Damon >>>>> Yes, an extra "import x" will solve my problem too! Sometimes I am wondering why "from x import y" hides x? hum...can't figure out the reason:-) >>>>> >>>> "from x import y" doesn't hide x - it just grabs y. Python does what >>>> you tell it to. :) >>>> >>>> ChrisA >>> But I had heard people say that "from x import y" did import the whole x module into memory, just as "import x" did, not "grabs y" only. Is this correct? >> `from x import y` does import the whole module x into memory, and adds >> it to `sys.modules`. But it only binds the name `y` in the namespace of >> module doing the import (and it binds it to the value of `x.y` at the >> time the import is done - it doesn't magically keep them in sync if one >> or the other is later reassigned). >> >> The point about the whole module being imported is that you don't save >> any memory by using `from x import y` to avoid importing some very large >> object `z` from `x`. Those other large objects might be needed by >> functions which have been imported (e.g. your `foo` function still needs >> `x` even if you haven't imported `x` - so it still needs to be loaded >> into memory) or might be imported and used by other modules importing >> `x`, so they still have to be loaded when any part of `x` is imported - >> they just don't have to be bound to names in the importing module's >> namespace. >> >> As Richard mentioned, if `x.y` is a mutable object (such as a list) you >> can still mutate that object (e.g. add/remove items) and those changes >> will be seen in both modules. That's because both are still bound to >> the same object and you're mutating that existing object. If you assign >> a new list to either, that won't be seen by the other. >> >> -- >> Mark. > When using dot notation to change variable, no matter if 'x.y' is a mutable or immutable object, the change > will be seen in both modules except those early bindings. > > --Jach Yes, sorry, I'd used `x.y` as a way of referring to the variable `y` in module `x` as opposed to `y` in the current module. It doesn't help that I added the second paragraph and didn't notice that the third was then out of context. If you use `import x` and assign to `x.y`, that will as you say be seen in both modules. On the other hand, if you use `from x import y`, then (as has been discussed) assigning to `y` in the module which has the import won't affect the value seen in module `x`. However, if `y` is mutable (e.g. a list), and no new object is assigned to it, then `y` still points to the same object in both modules, so mutating that existing object (e.g. `y.append(123)`) *will* affect what's seen in both modules - they're both referencing the same object, and you've modified that object, as opposed to assigning a new object to `y` in one of the modules. -- Mark. From eryksun at gmail.com Wed Aug 31 18:15:57 2022 From: eryksun at gmail.com (Eryk Sun) Date: Wed, 31 Aug 2022 17:15:57 -0500 Subject: Download Python 3.10.6 for windows In-Reply-To: References: Message-ID: On 8/31/22, George Rwaga wrote: > > I am not sure why the default for installing Python is > C:\Users\xxxxx.xxxxx\AppData\local\programs\Python\Python310. The "programs" folder in the above path is the default location to install programs just for user "xxxxx.xxxxx." More precisely, the default location is "%LOCALAPPDATA%\Programs". A user can easily change this path to a custom location in Explorer, so one shouldn't rely on the default value in general. Instead, use the shell protocol path, shell:userprogramfiles. You can use the latter directly in Explorer, such as the Win+R dialog. From the command line in CMD or PowerShell, use the `start` command. For example: >start shell:userprogramfiles Python's installer defaults to the user program files directory when installing just for the current user. When the setup is changed to install for all users, it automatically switches to using "%ProgramFiles%" or "%ProgramFiles(x86)%" (e.g. "C:\Program Files"). It will try to elevate to get administrator access when installing for all users. From jfong at ms4.hinet.net Wed Aug 31 21:53:55 2022 From: jfong at ms4.hinet.net (Jach Feng) Date: Wed, 31 Aug 2022 18:53:55 -0700 (PDT) Subject: How to make a variable's late binding crosses the module boundary? In-Reply-To: References: <06fa821a-2c33-49a2-81e3-6f76dd0a7317n@googlegroups.com> <1e81aff1-d1e4-48e0-9b48-bc2fcebe38dfn@googlegroups.com> <6db8e7db-b3b9-46b9-a9c7-4cc608bc56een@googlegroups.com> Message-ID: Mark Bourne ? 2022?9?1? ?????2:43:40 [UTC+8] ?????? > Jach Feng wrote: > > Mark Bourne ? 2022?8?29? ?????6:40:59 [UTC+8] ?????? > >> Jach Feng wrote: > >>> Chris Angelico ? 2022?8?29? ?????1:58:58 [UTC+8] ?????? > >>>> On Mon, 29 Aug 2022 at 15:54, Jach Feng wrote: > >>>>> > >>>>> Richard Damon ? 2022?8?29? ?????10:47:08 [UTC+8] ?????? > >>>>>> On 8/27/22 7:42 AM, Mark Bourne wrote: > >>>>>>> Jach Feng wrote: > >>>>>>>> I have two files: test.py and test2.py > >>>>>>>> --test.py-- > >>>>>>>> x = 2 > >>>>>>>> def foo(): > >>>>>>>> print(x) > >>>>>>>> foo() > >>>>>>>> > >>>>>>>> x = 3 > >>>>>>>> foo() > >>>>>>>> > >>>>>>>> --test2.py-- > >>>>>>>> from test import * > >>>>>>>> x = 4 > >>>>>>>> foo() > >>>>>>>> > >>>>>>>> ----- > >>>>>>>> Run test.py under Winows8.1, I get the expected result: > >>>>>>>> e:\MyDocument>py test.py > >>>>>>>> 2 > >>>>>>>> 3 > >>>>>>>> > >>>>>>>> But when run test2.py, the result is not my expected 2,3,4:-( > >>>>>>>> e:\MyDocument>py test2.py > >>>>>>>> 2 > >>>>>>>> 3 > >>>>>>>> 3 > >>>>>>>> > >>>>>>>> What to do? > >>>>>>> > >>>>>>> `from test import *` does not link the names in `test2` to those in > >>>>>>> `test`. It just binds objects bound to names in `test` to the same > >>>>>>> names in `test2`. A bit like doing: > >>>>>>> > >>>>>>> import test > >>>>>>> x = test.x > >>>>>>> foo = test.foo > >>>>>>> del test > >>>>>>> > >>>>>>> Subsequently assigning a different object to `x` in one module does > >>>>>>> not affect the object assigned to `x` in the other module. So `x = 4` > >>>>>>> in `test2.py` does not affect the object assigned to `x` in `test.py` > >>>>>>> - that's still `3`. If you want to do that, you need to import `test` > >>>>>>> and assign to `test.x`, for example: > >>>>>>> > >>>>>>> import test > >>>>>>> test.x = 4 > >>>>>>> test.foo() > >>>>>>> > >>>>>> Yes, fundamental issue is that the statement > >>>>>> > >>>>>> from x import y > >>>>>> > >>>>>> makes a binding in this module to the object CURRECTLY bound to x.y to > >>>>>> the name y, but if x.y gets rebound, this module does not track the changes. > >>>>>> > >>>>>> You can mutate the object x.y and see the changes, but not rebind it. > >>>>>> > >>>>>> If you need to see rebindings, you can't use the "from x import y" form, > >>>>>> or at a minimum do it as: > >>>>>> > >>>>>> > >>>>>> import x > >>>>>> > >>>>>> from x import y > >>>>>> > >>>>>> then later to get rebindings to x.y do a > >>>>>> > >>>>>> y = x.y > >>>>>> > >>>>>> to rebind to the current x.y object. > >>>>>> > >>>>>> -- > >>>>>> Richard Damon > >>>>> Yes, an extra "import x" will solve my problem too! Sometimes I am wondering why "from x import y" hides x? hum...can't figure out the reason:-) > >>>>> > >>>> "from x import y" doesn't hide x - it just grabs y. Python does what > >>>> you tell it to. :) > >>>> > >>>> ChrisA > >>> But I had heard people say that "from x import y" did import the whole x module into memory, just as "import x" did, not "grabs y" only. Is this correct? > >> `from x import y` does import the whole module x into memory, and adds > >> it to `sys.modules`. But it only binds the name `y` in the namespace of > >> module doing the import (and it binds it to the value of `x.y` at the > >> time the import is done - it doesn't magically keep them in sync if one > >> or the other is later reassigned). > >> > >> The point about the whole module being imported is that you don't save > >> any memory by using `from x import y` to avoid importing some very large > >> object `z` from `x`. Those other large objects might be needed by > >> functions which have been imported (e.g. your `foo` function still needs > >> `x` even if you haven't imported `x` - so it still needs to be loaded > >> into memory) or might be imported and used by other modules importing > >> `x`, so they still have to be loaded when any part of `x` is imported - > >> they just don't have to be bound to names in the importing module's > >> namespace. > >> > >> As Richard mentioned, if `x.y` is a mutable object (such as a list) you > >> can still mutate that object (e.g. add/remove items) and those changes > >> will be seen in both modules. That's because both are still bound to > >> the same object and you're mutating that existing object. If you assign > >> a new list to either, that won't be seen by the other. > >> > >> -- > >> Mark. > > When using dot notation to change variable, no matter if 'x.y' is a mutable or immutable object, the change > > will be seen in both modules except those early bindings. > > > > --Jach > Yes, sorry, I'd used `x.y` as a way of referring to the variable `y` in > module `x` as opposed to `y` in the current module. It doesn't help > that I added the second paragraph and didn't notice that the third was > then out of context. > > If you use `import x` and assign to `x.y`, that will as you say be seen > in both modules. On the other hand, if you use `from x import y`, then > (as has been discussed) assigning to `y` in the module which has the > import won't affect the value seen in module `x`. However, if `y` is > mutable (e.g. a list), and no new object is assigned to it, then `y` > still points to the same object in both modules, so mutating that > existing object (e.g. `y.append(123)`) *will* affect what's seen in both > modules - they're both referencing the same object, and you've modified > that object, as opposed to assigning a new object to `y` in one of the > modules. > > -- > Mark. Good Point! I learn from it:-) I found that using "from test import *" in test2.py makes test2's relation to "test" almost like the function's relation to the module where it is defined. You can refer to all the variables of the module, even modify the mutable objects, but just can't change them. The only way to change it is to declare it a "global." The same situation is in Test 2, but unfortunately there is no "super-global" to declare. The only way to make changes is to "import test" (again? it looks like a redundant statement to me:-) and use dot notation to do it. --Jach