From balbdrbhatchhetri at gmail.com Sun Mar 1 00:53:59 2020 From: balbdrbhatchhetri at gmail.com (balbdrbhatchhetri at gmail.com) Date: Sat, 29 Feb 2020 21:53:59 -0800 (PST) Subject: php to python code converter In-Reply-To: References: Message-ID: <8b3d0661-a33f-4057-8d27-d0805ef408b3@googlegroups.com> On Friday, May 8, 2009 at 3:38:25 AM UTC-7, bvidinli wrote: > if anybody needs: > http://code.google.com/p/phppython/ this link doesn't work From adam.preble at gmail.com Sun Mar 1 04:49:30 2020 From: adam.preble at gmail.com (Adam Preble) Date: Sun, 1 Mar 2020 01:49:30 -0800 (PST) Subject: Data model and attribute resolution in subclasses In-Reply-To: <584c712a-2476-44a6-b3e0-9b58c5695eea@googlegroups.com> References: <584c712a-2476-44a6-b3e0-9b58c5695eea@googlegroups.com> Message-ID: Based on what I was seeing here, I did some experiments to try to understand better what is going on: class BaseClass: def __init__(self): self.a = 1 def base_method(self): return self.a def another_base_method(self): return self.a + 1 class SubClass(BaseClass): def __init__(self): super().__init__() self.b = 2 c = SubClass() print(c.__dict__) print(c.__class__.__dict__) print(c.__class__.__subclasses__()) print(c.__class__.mro()) print(c.__class__.mro()[1].__dict__) print(getattr(c, "base_method")) print(c.b) print(c.a) With some notes: print(c.__dict__) {'a': 1, 'b': 2} So the instance directly has a. I am guessing that the object's own dictionary is directly getting these are both __init__'s are run. print(c.__class__.__dict__) {'__module__': '__main__', '__init__': , '__doc__': None} I am guessing this is what is found and stuffed into the class' namespace when the class is built; that's specifically the BUILD_CLASS opcode doing its thing. print(c.__class__.__subclasses__()) [] What?! Why isn't this []? print(c.__class__.mro()) [, , ] This is more like what I expected to find with subclasses. Okay, no, method resolution order is showing the entire order. print(c.__class__.mro()[1].__dict__) {'__module__': '__main__', '__init__': , 'base_method': , 'another_base_method': , '__dict__': , '__weakref__': , '__doc__': None} No instance-level stuff. Looks like it's the base class namespace when the BUILD_CLASS opcode saw it. Okay, looking good. print(getattr(c, "base_method")) > I'm guessing here it didn't find it in the object's __dict__ nor the class' __dict__ so it went in mro and found it in BaseClass. So I need a __dict__ for the class based on the code defined for it when the class is defined. That's associated with the class. I need another dictionary for each instance. That will get stuffed with whatever started getting dumped into it in __init__ (and possibly elsewhere afterwards). What __dict__ actually is can vary. The mappingproxy helps make sure that strings are given as keys (among other things?). From gigipepe80 at free.fr Sun Mar 1 04:54:55 2020 From: gigipepe80 at free.fr (Giuseppe) Date: Sun, 1 Mar 2020 10:54:55 +0100 Subject: Multiple turtles Message-ID: <5e5b866f$0$31410$426a74cc@news.free.fr> Hi, I am new to Python. I already tried turtle and it works well for my needs. I would like to draw fractals using turtle module. There are many ways to do that but I would like to use multiple turtles drawing in parallel but I don't know how. My first idea is to use clones as I do with Scratch (the problem with Scratch is the maximum number of simultaneous clones is set to 300) : each clone draw a part of the fractal and each clone (before being deleted) create clones who do the same thing and so on and so on... 1/ Is it possible to clone turtles ? 2/ Is it possible to make them work simultaneously ? 3/ Should I use multiple turtles instead ? 4/ Are there special things I should read first ? Thank you. Giuseppe From souvik.viksou at gmail.com Sun Mar 1 09:44:00 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Sun, 1 Mar 2020 20:14:00 +0530 Subject: php to python code converter In-Reply-To: <8b3d0661-a33f-4057-8d27-d0805ef408b3@googlegroups.com> References: <8b3d0661-a33f-4057-8d27-d0805ef408b3@googlegroups.com> Message-ID: Use this instead (I know the name is misleading) https://pypi.org/project/convert2php/ On Sun, Mar 1, 2020, 11:25 AM wrote: > On Friday, May 8, 2009 at 3:38:25 AM UTC-7, bvidinli wrote: > > if anybody needs: > > http://code.google.com/p/phppython/ > > this link doesn't work > -- > https://mail.python.org/mailman/listinfo/python-list > From souvik.viksou at gmail.com Sun Mar 1 09:47:44 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Sun, 1 Mar 2020 20:17:44 +0530 Subject: EuroPython 2020: Call for Proposals opens on March 9th In-Reply-To: References: Message-ID: I would like to see a bit of modernisation of the tkinter module. Like use of style sheets and opening images in a better way like not relying on bitmaps and thing like that. I would also like pip to check for PGP signature as that would certainly ensure security. And I generally use python for making apps. Thank you. On Wed, Feb 26, 2020, 10:21 PM M.-A. Lemburg wrote: > We are happy to announce that the Call for Proposals will open on > March 9. It will be left open for three weeks and then close on: > > Sunday, March 29 23:59:59 CEST > > While you wait for submissions to open, please check out the Call for > Proposals details on our pre-launch website: > > https://ep2020.europython.eu/call-for-proposals/ > > We?re looking for proposals on every aspect of Python: all levels of > programming from novice to advanced, applications, frameworks, data > science, Python projects, internals or topics which you?re excited > about, your experiences with Python and its ecosystem, creative or > artistic things you?ve done with Python, to name a few. > > EuroPython is a community conference and we are eager to hear about > your use of Python. > > Since feedback shows that our audience is very interested in advanced > topics, we?d appreciate more entries in this category for EuroPython > 2020. > > Please help spread word about Call for Proposals to anyone who might > be interested. Thanks. > > > Some additional updates: > ------------------------ > > - We?re working on launching the website, CfP and ticket sales in > March. > > - We are also preparing the sponsorship packages and should have them > ready early in March as well. Early bird sponsors will again receive > a 10% discount on the package price. If you?re interested in > becoming a launch sponsor, please contact our sponsor team at > sponsoring at europython.eu. > > > Help spread the word > -------------------- > > Please help us spread this message by sharing it on your social > networks as widely as possible. Thank you ! > > Link to the blog post: > > > https://blog.europython.eu/post/611042486524280832/europython-2020-call-for-proposals-opens-on-march > > Tweet: > > https://twitter.com/europython/status/1232708258525302784 > > > Enjoy, > -- > EuroPython 2020 Team > https://ep2020.europython.eu/ > https://www.europython-society.org/ > > -- > https://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Sun Mar 1 04:06:43 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 1 Mar 2020 04:06:43 -0500 Subject: php to python code converter In-Reply-To: <8b3d0661-a33f-4057-8d27-d0805ef408b3@googlegroups.com> References: <8b3d0661-a33f-4057-8d27-d0805ef408b3@googlegroups.com> Message-ID: On 3/1/2020 12:53 AM, balbdrbhatchhetri at gmail.com wrote: > On Friday, May 8, 2009 at 3:38:25 AM UTC-7, bvidinli wrote: >> if anybody needs: >> http://code.google.com/p/phppython/ > > this link doesn't work I believe free code.google.com was shut down a few years ago. I have a file there and was emailed to make sure I had a copy before it was deleted. -- Terry Jan Reedy From mail.python.org at marco.sulla.e4ward.com Sun Mar 1 14:48:27 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Sun, 1 Mar 2020 20:48:27 +0100 Subject: Have you some experience / link about difference between Python builded with gcc and clang? Message-ID: As title. Currently I'm using gcc 9.2.0 and its compilation seems to work well and fast. But I would know by your experience if clang can produce, on a *nix system, a "faster Python". From tjreedy at udel.edu Sun Mar 1 15:32:07 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 1 Mar 2020 15:32:07 -0500 Subject: Multiple turtles In-Reply-To: <5e5b866f$0$31410$426a74cc@news.free.fr> References: <5e5b866f$0$31410$426a74cc@news.free.fr> Message-ID: On 3/1/2020 4:54 AM, Giuseppe wrote: > Hi, > > I am new to Python. > I already tried turtle and it works well for my needs. > > I would like to draw fractals using turtle module. There are many ways > to do that but I would like to use multiple turtles drawing in parallel > but I don't know how. > > My first idea is to use clones as I do with Scratch (the problem with > Scratch is the maximum number of simultaneous clones is set to 300) : > each clone draw a part of the fractal and each clone (before being > deleted) create clones who do the same thing and so on and so on... > > 1/ Is it possible to clone turtles ? > 2/ Is it possible to make them work simultaneously ? > 3/ Should I use multiple turtles instead ? > 4/ Are there special things I should read first ? 1 & 3. I don't know what a Scratch clone is so I don't know the difference between 1 and 3. I suspect the answer is 3. Note that turtle provides a default turtle. Then one can create more with Turtle(). 2. Truly in parallel? no. Turtle module uses a tk Canvas and one can only draw to a canvas from one process. One can instead rotate among turtles so it looks like they move 'simultaneously'. 4. Run 'python -m turtle' and watch the two demos, especially the last part of the second. Then read demo2() starting with tri = getturtle() # Default turtle, chaser. tri.resizemode("auto") # New turtle, chased. # ... and loop. while tri.distance(turtle) > 4: turtle.fd(3.5) turtle.lt(0.6) tri.setheading(tri.towards(turtle)) tri.fd(4) For your purpose, you should, for instance, make a Turtle subclass with additional data and an extra 'tick' method to move according to the extra instance data. Remember that modifying collections while iterating through them is either prohibited or tricky. -- Terry Jan Reedy From tjreedy at udel.edu Sun Mar 1 15:36:48 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 1 Mar 2020 15:36:48 -0500 Subject: Data model and attribute resolution in subclasses In-Reply-To: References: <584c712a-2476-44a6-b3e0-9b58c5695eea@googlegroups.com> Message-ID: On 3/1/2020 4:49 AM, Adam Preble wrote: > Based on what I was seeing here, I did some experiments to try to understand better what is going on: > > class BaseClass: > def __init__(self): > self.a = 1 > > def base_method(self): > return self.a > > def another_base_method(self): > return self.a + 1 > > > class SubClass(BaseClass): > def __init__(self): > super().__init__() > self.b = 2 > > > c = SubClass() > print(c.__dict__) > print(c.__class__.__dict__) > print(c.__class__.__subclasses__()) > print(c.__class__.mro()) > print(c.__class__.mro()[1].__dict__) > print(getattr(c, "base_method")) > print(c.b) > print(c.a) > print(c.__class__.__subclasses__()) > [] > What?! Why isn't this []? Because BaseClass is the superclass of SubClass. -- Terry Jan Reedy From barry at barrys-emacs.org Sun Mar 1 16:22:22 2020 From: barry at barrys-emacs.org (Barry) Date: Sun, 1 Mar 2020 21:22:22 +0000 Subject: EuroPython 2020: Call for Proposals opens on March 9th In-Reply-To: References: Message-ID: <537E46BB-30F0-4904-B852-D3DBAE240982@barrys-emacs.org> > On 1 Mar 2020, at 14:51, Souvik Dutta wrote: > > ?I would like to see a bit of modernisation of the tkinter module. Like use > of style sheets and opening images in a better way like not relying on > bitmaps and thing like that. I would also like pip to check for PGP > signature as that would certainly ensure security. And I generally use > python for making apps. Thank you. Have a look at PyQt5. It OO and cross platform with few quirks. Barry > >> On Wed, Feb 26, 2020, 10:21 PM M.-A. Lemburg wrote: >> >> We are happy to announce that the Call for Proposals will open on >> March 9. It will be left open for three weeks and then close on: >> >> Sunday, March 29 23:59:59 CEST >> >> While you wait for submissions to open, please check out the Call for >> Proposals details on our pre-launch website: >> >> https://ep2020.europython.eu/call-for-proposals/ >> >> We?re looking for proposals on every aspect of Python: all levels of >> programming from novice to advanced, applications, frameworks, data >> science, Python projects, internals or topics which you?re excited >> about, your experiences with Python and its ecosystem, creative or >> artistic things you?ve done with Python, to name a few. >> >> EuroPython is a community conference and we are eager to hear about >> your use of Python. >> >> Since feedback shows that our audience is very interested in advanced >> topics, we?d appreciate more entries in this category for EuroPython >> 2020. >> >> Please help spread word about Call for Proposals to anyone who might >> be interested. Thanks. >> >> >> Some additional updates: >> ------------------------ >> >> - We?re working on launching the website, CfP and ticket sales in >> March. >> >> - We are also preparing the sponsorship packages and should have them >> ready early in March as well. Early bird sponsors will again receive >> a 10% discount on the package price. If you?re interested in >> becoming a launch sponsor, please contact our sponsor team at >> sponsoring at europython.eu. >> >> >> Help spread the word >> -------------------- >> >> Please help us spread this message by sharing it on your social >> networks as widely as possible. Thank you ! >> >> Link to the blog post: >> >> >> https://blog.europython.eu/post/611042486524280832/europython-2020-call-for-proposals-opens-on-march >> >> Tweet: >> >> https://twitter.com/europython/status/1232708258525302784 >> >> >> Enjoy, >> -- >> EuroPython 2020 Team >> https://ep2020.europython.eu/ >> https://www.europython-society.org/ >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > -- > https://mail.python.org/mailman/listinfo/python-list From skip.montanaro at gmail.com Sun Mar 1 17:48:09 2020 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Sun, 1 Mar 2020 16:48:09 -0600 Subject: Have you some experience / link about difference between Python builded with gcc and clang? In-Reply-To: References: Message-ID: > As title. Currently I'm using gcc 9.2.0 and its compilation seems to > work well and fast. But I would know by your experience if clang can > produce, on a *nix system, a "faster Python". I took a quick run at this as I was wanting to give pyperformance a try. Comparing GCC 9 with CLANG 8 on my Ubuntu laptop here's what I got. It seems that GCC was a bit faster than CLANG pretty much across the board. +-------------------------+---------+-------------------------------+ | Benchmark | gcc | clang | +=========================+=========+===============================+ | 2to3 | 403 ms | 440 ms: 1.09x slower (+9%) | +-------------------------+---------+-------------------------------+ | chameleon | 12.6 ms | 13.5 ms: 1.07x slower (+7%) | +-------------------------+---------+-------------------------------+ | chaos | 148 ms | 169 ms: 1.14x slower (+14%) | +-------------------------+---------+-------------------------------+ | crypto_pyaes | 145 ms | 157 ms: 1.08x slower (+8%) | +-------------------------+---------+-------------------------------+ | deltablue | 9.79 ms | 11.4 ms: 1.17x slower (+17%) | +-------------------------+---------+-------------------------------+ | django_template | 69.9 ms | 77.6 ms: 1.11x slower (+11%) | +-------------------------+---------+-------------------------------+ | dulwich_log | 89.3 ms | 92.6 ms: 1.04x slower (+4%) | +-------------------------+---------+-------------------------------+ | fannkuch | 590 ms | 602 ms: 1.02x slower (+2%) | +-------------------------+---------+-------------------------------+ | float | 150 ms | 160 ms: 1.07x slower (+7%) | +-------------------------+---------+-------------------------------+ | genshi_text | 35.9 ms | 39.4 ms: 1.10x slower (+10%) | +-------------------------+---------+-------------------------------+ | genshi_xml | 74.8 ms | 81.8 ms: 1.09x slower (+9%) | +-------------------------+---------+-------------------------------+ | go | 339 ms | 390 ms: 1.15x slower (+15%) | +-------------------------+---------+-------------------------------+ | hexiom | 12.9 ms | 14.3 ms: 1.11x slower (+11%) | +-------------------------+---------+-------------------------------+ | json_dumps | 16.4 ms | 17.6 ms: 1.07x slower (+7%) | +-------------------------+---------+-------------------------------+ | json_loads | 32.9 us | 34.6 us: 1.05x slower (+5%) | +-------------------------+---------+-------------------------------+ | logging_format | 13.9 us | 15.2 us: 1.09x slower (+9%) | +-------------------------+---------+-------------------------------+ | logging_silent | 253 ns | 298 ns: 1.18x slower (+18%) | +-------------------------+---------+-------------------------------+ | logging_simple | 12.6 us | 14.1 us: 1.12x slower (+12%) | +-------------------------+---------+-------------------------------+ | mako | 21.8 ms | 24.2 ms: 1.11x slower (+11%) | +-------------------------+---------+-------------------------------+ | meteor_contest | 128 ms | 133 ms: 1.04x slower (+4%) | +-------------------------+---------+-------------------------------+ | nbody | 181 ms | 190 ms: 1.05x slower (+5%) | +-------------------------+---------+-------------------------------+ | nqueens | 128 ms | 135 ms: 1.05x slower (+5%) | +-------------------------+---------+-------------------------------+ | pathlib | 26.3 ms | 27.1 ms: 1.03x slower (+3%) | +-------------------------+---------+-------------------------------+ | pickle | 13.3 us | 13.5 us: 1.01x slower (+1%) | +-------------------------+---------+-------------------------------+ | pickle_dict | 33.8 us | 33.6 us: 1.01x faster (-1%) | +-------------------------+---------+-------------------------------+ | pickle_list | 4.82 us | 5.18 us: 1.07x slower (+7%) | +-------------------------+---------+-------------------------------+ | pickle_pure_python | 613 us | 725 us: 1.18x slower (+18%) | +-------------------------+---------+-------------------------------+ | pidigits | 210 ms | 218 ms: 1.04x slower (+4%) | +-------------------------+---------+-------------------------------+ | pyflate | 871 ms | 1.00 sec: 1.15x slower (+15%) | +-------------------------+---------+-------------------------------+ | python_startup | 10.3 ms | 10.4 ms: 1.01x slower (+1%) | +-------------------------+---------+-------------------------------+ | python_startup_no_site | 7.16 ms | 7.39 ms: 1.03x slower (+3%) | +-------------------------+---------+-------------------------------+ | raytrace | 686 ms | 800 ms: 1.17x slower (+17%) | +-------------------------+---------+-------------------------------+ | regex_compile | 223 ms | 240 ms: 1.07x slower (+7%) | +-------------------------+---------+-------------------------------+ | regex_effbot | 3.70 ms | 3.85 ms: 1.04x slower (+4%) | +-------------------------+---------+-------------------------------+ | regex_v8 | 27.9 ms | 28.7 ms: 1.03x slower (+3%) | +-------------------------+---------+-------------------------------+ | richards | 95.4 ms | 114 ms: 1.19x slower (+19%) | +-------------------------+---------+-------------------------------+ | scimark_fft | 470 ms | 538 ms: 1.14x slower (+14%) | +-------------------------+---------+-------------------------------+ | scimark_lu | 205 ms | 210 ms: 1.03x slower (+3%) | +-------------------------+---------+-------------------------------+ | scimark_monte_carlo | 138 ms | 151 ms: 1.09x slower (+9%) | +-------------------------+---------+-------------------------------+ | scimark_sor | 257 ms | 297 ms: 1.15x slower (+15%) | +-------------------------+---------+-------------------------------+ | scimark_sparse_mat_mult | 6.19 ms | 6.24 ms: 1.01x slower (+1%) | +-------------------------+---------+-------------------------------+ | spectral_norm | 177 ms | 216 ms: 1.22x slower (+22%) | +-------------------------+---------+-------------------------------+ | sqlalchemy_declarative | 199 ms | 205 ms: 1.03x slower (+3%) | +-------------------------+---------+-------------------------------+ | sqlalchemy_imperative | 39.7 ms | 40.2 ms: 1.01x slower (+1%) | +-------------------------+---------+-------------------------------+ | sqlite_synth | 3.74 us | 3.86 us: 1.03x slower (+3%) | +-------------------------+---------+-------------------------------+ | sympy_expand | 638 ms | 671 ms: 1.05x slower (+5%) | +-------------------------+---------+-------------------------------+ | sympy_integrate | 30.3 ms | 31.7 ms: 1.05x slower (+5%) | +-------------------------+---------+-------------------------------+ | sympy_sum | 270 ms | 282 ms: 1.04x slower (+4%) | +-------------------------+---------+-------------------------------+ | sympy_str | 423 ms | 440 ms: 1.04x slower (+4%) | +-------------------------+---------+-------------------------------+ | telco | 8.44 ms | 8.35 ms: 1.01x faster (-1%) | +-------------------------+---------+-------------------------------+ | tornado_http | 210 ms | 221 ms: 1.05x slower (+5%) | +-------------------------+---------+-------------------------------+ | unpack_sequence | 65.1 ns | 60.8 ns: 1.07x faster (-7%) | +-------------------------+---------+-------------------------------+ | unpickle | 17.6 us | 19.0 us: 1.08x slower (+8%) | +-------------------------+---------+-------------------------------+ | unpickle_list | 5.46 us | 5.32 us: 1.03x faster (-3%) | +-------------------------+---------+-------------------------------+ | unpickle_pure_python | 423 us | 478 us: 1.13x slower (+13%) | +-------------------------+---------+-------------------------------+ | xml_etree_parse | 176 ms | 191 ms: 1.09x slower (+9%) | +-------------------------+---------+-------------------------------+ | xml_etree_iterparse | 123 ms | 133 ms: 1.08x slower (+8%) | +-------------------------+---------+-------------------------------+ | xml_etree_generate | 118 ms | 125 ms: 1.06x slower (+6%) | +-------------------------+---------+-------------------------------+ | xml_etree_process | 95.5 ms | 100 ms: 1.05x slower (+5%) | +-------------------------+---------+-------------------------------+ Skip From mail.python.org at marco.sulla.e4ward.com Sun Mar 1 18:23:09 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 2 Mar 2020 00:23:09 +0100 Subject: Have you some experience / link about difference between Python builded with gcc and clang? In-Reply-To: References: Message-ID: Good! Have you compiled it optimized (--enable-optimizations --with-lto)? On Sun, 1 Mar 2020 at 23:48, Skip Montanaro wrote: > > > As title. Currently I'm using gcc 9.2.0 and its compilation seems to > > work well and fast. But I would know by your experience if clang can > > produce, on a *nix system, a "faster Python". > > I took a quick run at this as I was wanting to give pyperformance a try. Comparing GCC 9 with CLANG 8 on my Ubuntu laptop here's what I got. It seems that GCC was a bit faster than CLANG pretty much across the board. > > +-------------------------+---------+-------------------------------+ > | Benchmark | gcc | clang | > +=========================+=========+===============================+ > | 2to3 | 403 ms | 440 ms: 1.09x slower (+9%) | > +-------------------------+---------+-------------------------------+ > | chameleon | 12.6 ms | 13.5 ms: 1.07x slower (+7%) | > +-------------------------+---------+-------------------------------+ > | chaos | 148 ms | 169 ms: 1.14x slower (+14%) | > +-------------------------+---------+-------------------------------+ > | crypto_pyaes | 145 ms | 157 ms: 1.08x slower (+8%) | > +-------------------------+---------+-------------------------------+ > | deltablue | 9.79 ms | 11.4 ms: 1.17x slower (+17%) | > +-------------------------+---------+-------------------------------+ > | django_template | 69.9 ms | 77.6 ms: 1.11x slower (+11%) | > +-------------------------+---------+-------------------------------+ > | dulwich_log | 89.3 ms | 92.6 ms: 1.04x slower (+4%) | > +-------------------------+---------+-------------------------------+ > | fannkuch | 590 ms | 602 ms: 1.02x slower (+2%) | > +-------------------------+---------+-------------------------------+ > | float | 150 ms | 160 ms: 1.07x slower (+7%) | > +-------------------------+---------+-------------------------------+ > | genshi_text | 35.9 ms | 39.4 ms: 1.10x slower (+10%) | > +-------------------------+---------+-------------------------------+ > | genshi_xml | 74.8 ms | 81.8 ms: 1.09x slower (+9%) | > +-------------------------+---------+-------------------------------+ > | go | 339 ms | 390 ms: 1.15x slower (+15%) | > +-------------------------+---------+-------------------------------+ > | hexiom | 12.9 ms | 14.3 ms: 1.11x slower (+11%) | > +-------------------------+---------+-------------------------------+ > | json_dumps | 16.4 ms | 17.6 ms: 1.07x slower (+7%) | > +-------------------------+---------+-------------------------------+ > | json_loads | 32.9 us | 34.6 us: 1.05x slower (+5%) | > +-------------------------+---------+-------------------------------+ > | logging_format | 13.9 us | 15.2 us: 1.09x slower (+9%) | > +-------------------------+---------+-------------------------------+ > | logging_silent | 253 ns | 298 ns: 1.18x slower (+18%) | > +-------------------------+---------+-------------------------------+ > | logging_simple | 12.6 us | 14.1 us: 1.12x slower (+12%) | > +-------------------------+---------+-------------------------------+ > | mako | 21.8 ms | 24.2 ms: 1.11x slower (+11%) | > +-------------------------+---------+-------------------------------+ > | meteor_contest | 128 ms | 133 ms: 1.04x slower (+4%) | > +-------------------------+---------+-------------------------------+ > | nbody | 181 ms | 190 ms: 1.05x slower (+5%) | > +-------------------------+---------+-------------------------------+ > | nqueens | 128 ms | 135 ms: 1.05x slower (+5%) | > +-------------------------+---------+-------------------------------+ > | pathlib | 26.3 ms | 27.1 ms: 1.03x slower (+3%) | > +-------------------------+---------+-------------------------------+ > | pickle | 13.3 us | 13.5 us: 1.01x slower (+1%) | > +-------------------------+---------+-------------------------------+ > | pickle_dict | 33.8 us | 33.6 us: 1.01x faster (-1%) | > +-------------------------+---------+-------------------------------+ > | pickle_list | 4.82 us | 5.18 us: 1.07x slower (+7%) | > +-------------------------+---------+-------------------------------+ > | pickle_pure_python | 613 us | 725 us: 1.18x slower (+18%) | > +-------------------------+---------+-------------------------------+ > | pidigits | 210 ms | 218 ms: 1.04x slower (+4%) | > +-------------------------+---------+-------------------------------+ > | pyflate | 871 ms | 1.00 sec: 1.15x slower (+15%) | > +-------------------------+---------+-------------------------------+ > | python_startup | 10.3 ms | 10.4 ms: 1.01x slower (+1%) | > +-------------------------+---------+-------------------------------+ > | python_startup_no_site | 7.16 ms | 7.39 ms: 1.03x slower (+3%) | > +-------------------------+---------+-------------------------------+ > | raytrace | 686 ms | 800 ms: 1.17x slower (+17%) | > +-------------------------+---------+-------------------------------+ > | regex_compile | 223 ms | 240 ms: 1.07x slower (+7%) | > +-------------------------+---------+-------------------------------+ > | regex_effbot | 3.70 ms | 3.85 ms: 1.04x slower (+4%) | > +-------------------------+---------+-------------------------------+ > | regex_v8 | 27.9 ms | 28.7 ms: 1.03x slower (+3%) | > +-------------------------+---------+-------------------------------+ > | richards | 95.4 ms | 114 ms: 1.19x slower (+19%) | > +-------------------------+---------+-------------------------------+ > | scimark_fft | 470 ms | 538 ms: 1.14x slower (+14%) | > +-------------------------+---------+-------------------------------+ > | scimark_lu | 205 ms | 210 ms: 1.03x slower (+3%) | > +-------------------------+---------+-------------------------------+ > | scimark_monte_carlo | 138 ms | 151 ms: 1.09x slower (+9%) | > +-------------------------+---------+-------------------------------+ > | scimark_sor | 257 ms | 297 ms: 1.15x slower (+15%) | > +-------------------------+---------+-------------------------------+ > | scimark_sparse_mat_mult | 6.19 ms | 6.24 ms: 1.01x slower (+1%) | > +-------------------------+---------+-------------------------------+ > | spectral_norm | 177 ms | 216 ms: 1.22x slower (+22%) | > +-------------------------+---------+-------------------------------+ > | sqlalchemy_declarative | 199 ms | 205 ms: 1.03x slower (+3%) | > +-------------------------+---------+-------------------------------+ > | sqlalchemy_imperative | 39.7 ms | 40.2 ms: 1.01x slower (+1%) | > +-------------------------+---------+-------------------------------+ > | sqlite_synth | 3.74 us | 3.86 us: 1.03x slower (+3%) | > +-------------------------+---------+-------------------------------+ > | sympy_expand | 638 ms | 671 ms: 1.05x slower (+5%) | > +-------------------------+---------+-------------------------------+ > | sympy_integrate | 30.3 ms | 31.7 ms: 1.05x slower (+5%) | > +-------------------------+---------+-------------------------------+ > | sympy_sum | 270 ms | 282 ms: 1.04x slower (+4%) | > +-------------------------+---------+-------------------------------+ > | sympy_str | 423 ms | 440 ms: 1.04x slower (+4%) | > +-------------------------+---------+-------------------------------+ > | telco | 8.44 ms | 8.35 ms: 1.01x faster (-1%) | > +-------------------------+---------+-------------------------------+ > | tornado_http | 210 ms | 221 ms: 1.05x slower (+5%) | > +-------------------------+---------+-------------------------------+ > | unpack_sequence | 65.1 ns | 60.8 ns: 1.07x faster (-7%) | > +-------------------------+---------+-------------------------------+ > | unpickle | 17.6 us | 19.0 us: 1.08x slower (+8%) | > +-------------------------+---------+-------------------------------+ > | unpickle_list | 5.46 us | 5.32 us: 1.03x faster (-3%) | > +-------------------------+---------+-------------------------------+ > | unpickle_pure_python | 423 us | 478 us: 1.13x slower (+13%) | > +-------------------------+---------+-------------------------------+ > | xml_etree_parse | 176 ms | 191 ms: 1.09x slower (+9%) | > +-------------------------+---------+-------------------------------+ > | xml_etree_iterparse | 123 ms | 133 ms: 1.08x slower (+8%) | > +-------------------------+---------+-------------------------------+ > | xml_etree_generate | 118 ms | 125 ms: 1.06x slower (+6%) | > +-------------------------+---------+-------------------------------+ > | xml_etree_process | 95.5 ms | 100 ms: 1.05x slower (+5%) | > +-------------------------+---------+-------------------------------+ > > Skip > From mail.python.org at marco.sulla.e4ward.com Sun Mar 1 19:50:47 2020 From: mail.python.org at marco.sulla.e4ward.com (Skip Montanaro) Date: Sun, 1 Mar 2020 18:50:47 -0600 Subject: Have you some experience / link about difference between Python builded with gcc and clang? In-Reply-To: References: Message-ID: I didn't have clang installed. It was just "sudo apt install clang-8". From there all I had to do was build Python from scratch twice, install pyperformance using pip after the first build, then run it after each build. It's not difficult. Going beyond that right now is not an itch I need to scratch though. I have other things on my plate. Skip On Sun, Mar 1, 2020, 6:11 PM Marco Sulla < mail.python.org at marco.sulla.e4ward.com> wrote: > Oooohhh.... uff, I have to install latest clang... or better, compile > it as I did for gcc. And I have to read the install docs to see if > there's some trick to optimize it... and I have to read the docs of > pyperformance too (I only used pyperf until now)... > > Oh well, tomorrow :-D > > On Mon, 2 Mar 2020 at 00:58, Skip Montanaro > wrote: > >> > >> Have you compiled it optimized (--enable-optimizations --with-lto)? > > > > > > Nope, just ./configure. Further investigation is left as an exercise for > the reader. :-) > > > > Skip > From cs at cskk.id.au Sun Mar 1 22:13:51 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Mon, 2 Mar 2020 14:13:51 +1100 Subject: =?utf-8?Q?=E3=80=90Regarding_Performan?= =?utf-8?B?Y2Ugb2YgYSBQeXRob24gU2NyaXB0Li4uLuOAkQ==?= In-Reply-To: References: Message-ID: <20200302031351.GA40409@cskk.homeip.net> On 28Feb2020 19:24, Kenzi wrote: > I have a question regarding a simple code snippet in Python: > >from subprocess import check_output >for i in range(1024): > check_output(['/bin/bash', '-c', 'echo 42'], close_fds=True) > >*I wonder why running it in Python 3.7 is much faster than Python 2.7? * >(Python 3.7 is still faster, after I used *xrange * in Python 2.7) On a lot of UNIX systems you can use the strace command to inspect what is happening. I am personally surprised there's a significant difference between the Pythons because I'd expect the expense of invoking bash to dominate the cost here (consider using /bin/sh, which on many systems isn't bash but something smaller/faster for noninteractive shell scripting). Write a script running just the check_output() call one, and strace it: strace python -c "from subprocess import check_output; check_output(['/bin/bash', '-c', 'echo 42'], close_fds=True)" See if your 2 Pythons are doing something difference at the system call level. Cheers, Cameron Simpson From adam.preble at gmail.com Mon Mar 2 02:45:03 2020 From: adam.preble at gmail.com (Adam Preble) Date: Sun, 1 Mar 2020 23:45:03 -0800 (PST) Subject: Data model and attribute resolution in subclasses In-Reply-To: References: <584c712a-2476-44a6-b3e0-9b58c5695eea@googlegroups.com> Message-ID: On Sunday, March 1, 2020 at 3:08:29 PM UTC-6, Terry Reedy wrote: > Because BaseClass is the superclass of SubClass. So there's a mechanism for parent classes to know all their children? From gigipepe80 at free.fr Mon Mar 2 03:09:46 2020 From: gigipepe80 at free.fr (Giuseppe) Date: Mon, 2 Mar 2020 09:09:46 +0100 Subject: Multiple turtles In-Reply-To: <5e5b866f$0$31410$426a74cc@news.free.fr> References: <5e5b866f$0$31410$426a74cc@news.free.fr> Message-ID: <5e5cbf4b$0$21585$426a74cc@news.free.fr> Thank you. Giuseppe From mail.python.org at marco.sulla.e4ward.com Sun Mar 1 19:09:50 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 2 Mar 2020 01:09:50 +0100 Subject: Have you some experience / link about difference between Python builded with gcc and clang? In-Reply-To: References: Message-ID: Oooohhh.... uff, I have to install latest clang... or better, compile it as I did for gcc. And I have to read the install docs to see if there's some trick to optimize it... and I have to read the docs of pyperformance too (I only used pyperf until now)... Oh well, tomorrow :-D On Mon, 2 Mar 2020 at 00:58, Skip Montanaro wrote: >> >> Have you compiled it optimized (--enable-optimizations --with-lto)? > > > Nope, just ./configure. Further investigation is left as an exercise for the reader. :-) > > Skip From mail.python.org at marco.sulla.e4ward.com Sun Mar 1 18:57:56 2020 From: mail.python.org at marco.sulla.e4ward.com (Skip Montanaro) Date: Sun, 1 Mar 2020 17:57:56 -0600 Subject: Have you some experience / link about difference between Python builded with gcc and clang? In-Reply-To: References: Message-ID: > > Have you compiled it optimized (--enable-optimizations --with-lto)? > Nope, just ./configure. Further investigation is left as an exercise for the reader. :-) Skip > From lele at metapensiero.it Mon Mar 2 05:25:25 2020 From: lele at metapensiero.it (Lele Gaifax) Date: Mon, 02 Mar 2020 11:25:25 +0100 Subject: Data model and attribute resolution in subclasses References: <584c712a-2476-44a6-b3e0-9b58c5695eea@googlegroups.com> Message-ID: <8736arnje2.fsf@metapensiero.it> Adam Preble writes: > On Sunday, March 1, 2020 at 3:08:29 PM UTC-6, Terry Reedy wrote: > >> Because BaseClass is the superclass of SubClass. > > So there's a mechanism for parent classes to know all their children? Yes, you just used it, although you may have confused its meaning: >>> class Base: ... pass ... >>> class Derived(Base): ... pass ... >>> print(Base.__subclasses__()) [] ciao, lele. -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From mail.python.org at marco.sulla.e4ward.com Mon Mar 2 16:10:56 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 2 Mar 2020 22:10:56 +0100 Subject: Data model and attribute resolution in subclasses In-Reply-To: <584c712a-2476-44a6-b3e0-9b58c5695eea@googlegroups.com> References: <584c712a-2476-44a6-b3e0-9b58c5695eea@googlegroups.com> Message-ID: On Fri, 28 Feb 2020 at 08:28, Adam Preble wrote: > > I have been making some progress on my custom interpreter project Is your project published somewhere? What changes have you done to the interpreter? From mail.python.org at marco.sulla.e4ward.com Mon Mar 2 16:01:01 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 2 Mar 2020 22:01:01 +0100 Subject: Why this message was rejected? Message-ID: One of my post on this list was rejected. The reason is: > Blind carbon copies or other implicit destinations are not allowed. >Try reposting your message by explicitly including the list address in > the To: or Cc: fields. I rechecked my mail and I added the user to the To: field, and the python list address to the Cc field. I don't added any Bcc. I do not understand why my message was blocked. From ethan at stoneleaf.us Mon Mar 2 16:32:40 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 2 Mar 2020 13:32:40 -0800 Subject: Why this message was rejected? In-Reply-To: References: Message-ID: On 03/02/2020 01:01 PM, Marco Sulla via Python-list wrote: > One of my post on this list was rejected. The reason is: > >> Blind carbon copies or other implicit destinations are not allowed. >> Try reposting your message by explicitly including the list address in >> the To: or Cc: fields. > > I rechecked my mail and I added the user to the To: field, and the > python list address to the Cc field. I don't added any Bcc. I do not > understand why my message was blocked. > Questions like this should go to python-list-owner at python dot org. If this message hadn't been flagged we may not have noticed it. When the mailing list software received your post, the python-list address was not in the To: nor Cc: headers. Try the same steps you did before and I'll keep a copy of the message for further debugging. -- ~Ethan~ From mail.python.org at marco.sulla.e4ward.com Mon Mar 2 16:48:05 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 2 Mar 2020 22:48:05 +0100 Subject: Why this message was rejected? In-Reply-To: References: Message-ID: On Mon, 2 Mar 2020 at 22:36, Ethan Furman wrote: > Questions like this should go to python-list-owner at python dot org. If this message hadn't been flagged we may not have noticed it. Sorry, I posted to python-list-owner before reading this message. > When the mailing list software received your post, the python-list address was not in the To: nor Cc: headers Well, this is quite strange, since I rechecked my mails and the python-list address is in Cc. I think the problem was caused by the fact I added the user concerned to To:, and the list to Cc. All the rejected messages has this in common. Indeed, this message was not rejected because I added only the list to the To: field. > Try the same steps you did before and I'll keep a copy of the message for further debugging. As you wish :-) From mail.python.org at marco.sulla.e4ward.com Mon Mar 2 16:53:53 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 2 Mar 2020 22:53:53 +0100 Subject: Why this message was rejected? In-Reply-To: References: Message-ID: Ok, I sent a message as I did before to the discussion "Re: Friday Finking: Poly more thick", with only "test" as body. On Mon, 2 Mar 2020 at 22:48, Marco Sulla wrote: > > On Mon, 2 Mar 2020 at 22:36, Ethan Furman wrote: > > Questions like this should go to python-list-owner at python dot org. If this message hadn't been flagged we may not have noticed it. > > Sorry, I posted to python-list-owner before reading this message. > > > When the mailing list software received your post, the python-list address was not in the To: nor Cc: headers > > Well, this is quite strange, since I rechecked my mails and the > python-list address is in Cc. > I think the problem was caused by the fact I added the user concerned > to To:, and the list to Cc. All the rejected messages has this in > common. Indeed, this message was not rejected because I added only the > list to the To: field. > > > Try the same steps you did before and I'll keep a copy of the message for further debugging. > > As you wish :-) From mail.python.org at marco.sulla.e4ward.com Mon Mar 2 16:31:12 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 2 Mar 2020 22:31:12 +0100 Subject: Why there's no __json__()? Message-ID: As title. For example, `copy.copy` can use the __copy__() method of a class, if defined. Is this not possible with `json`? From kwa at kuwata-lab.com Mon Mar 2 20:31:47 2020 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Tue, 3 Mar 2020 10:31:47 +0900 Subject: Changing local vars via `locals()` Message-ID: Hi, folks. I know that it is not possible to change local vars via `locals()` (except in module-level). ``` import sys def f1(): x = 1 d = locals() d['x'] = 2 print(x) #=> 1 (not changed) f1() ``` But I found that it is possible in class definition. ``` import sys class Foo: x = 1 d = locals() d['x'] = 2 print(x) #=> 2 (changed!!!) ``` Can anyone explain about difference between above two? Why it is possiable to change local var via `locals()` only in class definition? From ethan at stoneleaf.us Mon Mar 2 20:38:22 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 2 Mar 2020 17:38:22 -0800 Subject: Changing local vars via `locals()` In-Reply-To: References: Message-ID: <968a706e-c0bd-1423-1523-739afa936fe8@stoneleaf.us> On 03/02/2020 05:31 PM, Makoto Kuwata wrote: > Can anyone explain about difference between above two? > Why it is possiable to change local var via `locals()` only in class > definition? My Stackoverflow answer (https://stackoverflow.com/q/7969949/208880): Each of `globals()`, `locals()`, and `vars()` return a dictionary: globals() always returns the dictionary of the module namespace locals() always returns a dictionary of the current namespace vars() returns either a dictionary of the current namespace (if called with no argument) or the dictionary of the argument. locals and vars could use some more explanation. If locals() is called inside a function, it updates a dict with the values of the current local variable namespace (plus any closure variables) as of that moment and returns it. Multiple calls to locals() in the same stack frame return the same dict each time - it's attached to the stack frame object as its f_locals attribute. The dict's contents are updated on each locals() call and each f_locals attribute access, but only on such calls or attribute accesses. It does not automatically update when variables are assigned, and assigning entries in the dict will not assign the corresponding local variables: import inspect def f(): x = 1 l = locals() print(l) locals() print(l) x = 2 print(x, l['x']) l['x'] = 3 print(x, l['x']) inspect.currentframe().f_locals print(x, l['x']) f() gives us: {'x': 1} {'x': 1, 'l': {...}} 2 1 2 3 2 2 The first print(l) only shows an 'x' entry, because the assignment to l happens after the locals() call. The second print(l), after calling locals() again, shows an l entry, even though we didn't save the return value. The third and fourth prints show that assigning variables doesn't update l and vice versa, but after we access f_locals, local variables are copied into locals() again. Two notes: This behavior is CPython specific -- other Pythons may allow the updates to make it back to the local namespace automatically. In CPython 2.x it is possible to make this work by putting an exec "pass" line in the function. This switches the function to an older, slower execution mode that uses the locals() dict as the canonical representation of local variables. If locals() is called outside a function it returns the actual dictionary that is the current namespace. Further changes to the namespace are reflected in the dictionary, and changes to the dictionary are reflected in the namespace: class Test(object): a = 'one' b = 'two' huh = locals() c = 'three' huh['d'] = 'four' print huh gives us: { 'a': 'one', 'b': 'two', 'c': 'three', 'd': 'four', 'huh': {...}, '__module__': '__main__', } So far, everything I've said about locals() is also true for vars()... here's the difference: vars() accepts a single object as its argument, and if you give it an object it returns the __dict__ of that object. For a typical object, its __dict__ is where most of its attribute data is stored. This includes class variables and module globals: class Test(object): a = 'one' b = 'two' def frobber(self): print self.c t = Test() huh = vars(t) huh['c'] = 'three' t.frobber() which gives us: three Note that a function's __dict__ is its attribute namespace, not local variables. It wouldn't make sense for a function's __dict__ to store local variables, since recursion and multithreading mean there can be multiple calls to a function at the same time, each with their own locals: def f(outer): if outer: f(False) print('Outer call locals:', locals()) print('f.__dict__:', f.__dict__) else: print('Inner call locals:', locals()) print('f.__dict__:', f.__dict__) f.x = 3 f(True) which gives us: Inner call locals: {'outer': False} f.__dict__: {'x': 3} Outer call locals: {'outer': True} f.__dict__: {'x': 3} Here, f calls itself recursively, so the inner and outer calls overlap. Each one sees its own local variables when it calls locals(), but both calls see the same f.__dict__, and f.__dict__ doesn't have any local variables in it. From mail.python.org at marco.sulla.e4ward.com Mon Mar 2 22:24:43 2020 From: mail.python.org at marco.sulla.e4ward.com (Mr. Lee Chiffre) Date: Mon, 2 Mar 2020 19:24:43 -0800 Subject: Help building python application from source In-Reply-To: References: Message-ID: > I think I have the solution, but can I ask you why are you creating a > bitcoin server? > Yes. I am a crypto anarchist. I have a bitcoin node to do my part to running the bitcoin network and help remain it decentralized and resilient. The more people that run a node the better it is. When it comes to hosting servers I believe I am able to do so in a highly secure manner. So I am doing my part in secure the bitcoin network and documenting what I do to help others do the same thing. I support the bitcoin project because it is a liberty enhancing technology to counter act over reaching government and expanding tyranny. People have a right to financial privacy. And the world needs a secure financial network to replace the existing institutional one that suffers from fraud and theft. In a cyber dystopian world we live in there is a war on cash and privacy to push us into a digital monetary system where governments are able to spy on and control everything and everyone. If there is a need for digital money let it be one that supports liberty instead of weakening it. It is vital that cypher tech outpaces the police state. What we do determines the future. We can let ourselves be enslaved and passive. Or we can be active and support the solutions that create a better world and preserve what is good. Right now it is a full node and not used for any other services or purposes. If possible I would like to add electrumx so users of the electrum wallet can use my server. Electrum is a very popular wallet and is what comes pre installed with TAILS. -- lee.chiffre at secmail.pro PGP 97F0C3AE985A191DA0556BCAA82529E2025BDE35 From adam.preble at gmail.com Tue Mar 3 01:12:19 2020 From: adam.preble at gmail.com (Adam Preble) Date: Mon, 2 Mar 2020 22:12:19 -0800 (PST) Subject: Data model and attribute resolution in subclasses In-Reply-To: References: <584c712a-2476-44a6-b3e0-9b58c5695eea@googlegroups.com> <8736arnje2.fsf@metapensiero.it> Message-ID: On Monday, March 2, 2020 at 7:09:24 AM UTC-6, Lele Gaifax wrote: > Yes, you just used it, although you may have confused its meaning: > Yeah I absolutely got it backwards. That's a fun one I have to fix in my project now! From adam.preble at gmail.com Tue Mar 3 01:15:28 2020 From: adam.preble at gmail.com (Adam Preble) Date: Mon, 2 Mar 2020 22:15:28 -0800 (PST) Subject: Data model and attribute resolution in subclasses In-Reply-To: References: <584c712a-2476-44a6-b3e0-9b58c5695eea@googlegroups.com> Message-ID: <3a839f6b-991c-488f-966b-a4bc0fb122a9@googlegroups.com> On Monday, March 2, 2020 at 3:12:33 PM UTC-6, Marco Sulla wrote: > Is your project published somewhere? What changes have you done to the > interpreter? I'm writing my own mess: https://github.com/rockobonaparte/cloaca It's a .NET Pythonish interpreter with the distinction of using a whole lot of async-await so I can do expressive game scripting with it in one thread. If IronPython had a handle on async-await then I'd probably not be doing this at all. Well, it was also a personal education project to learn me some Python internals for an internal company job change, but they aren't interested in me at all. :( I still hack with it because I got far enough to have a REPL I could dump into Unity and it immediately looked very useful. From voodoo.bender at gmail.com Tue Mar 3 11:39:17 2020 From: voodoo.bender at gmail.com (alberto) Date: Tue, 3 Mar 2020 08:39:17 -0800 (PST) Subject: HYDRASPA error Message-ID: hi, my name is Alberto Now I'm trying to install and use the code hydraspa (https://pypi.org/project/hydraspa/) I'm installing from source with command python 3.5 setup.py install but when I run hydraspa create -s IRMOF-1 -g CO2 -f UFF -o myCO2sim as reported in documentation I obtain TEST_RASPA $ hydraspa create -s IRMOF-1.cif -g CO2.def -f uff.def -o myCO2sim Traceback (most recent call last): File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 417, in get_provider module = sys.modules[moduleOrReq] KeyError: None During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/bin/hydraspa", line 4, in __import__('pkg_resources').run_script('hydraspa==0.3.1', 'hydraspa') File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 719, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1511, in run_script exec(script_code, namespace, namespace) File "/usr/local/lib/python3.5/dist-packages/hydraspa-0.3.1-py3.5.egg/EGG-INFO/scripts/hydraspa", line 7, in File "", line 969, in _find_and_load File "", line 958, in _find_and_load_unlocked File "", line 664, in _load_unlocked File "", line 634, in _load_backward_compatible File "/usr/local/lib/python3.5/dist-packages/hydraspa-0.3.1-py3.5.egg/hydraspa/__init__.py", line 5, in File "", line 969, in _find_and_load File "", line 958, in _find_and_load_unlocked File "", line 664, in _load_unlocked File "", line 634, in _load_backward_compatible File "/usr/local/lib/python3.5/dist-packages/hydraspa-0.3.1-py3.5.egg/hydraspa/files.py", line 28, in File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1189, in resource_listdir return get_provider(package_or_requirement).resource_listdir( File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 419, in get_provider __import__(moduleOrReq) TypeError: __import__() argument 1 must be str, not None regards Alberto From rosuav at gmail.com Tue Mar 3 13:10:08 2020 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 4 Mar 2020 05:10:08 +1100 Subject: HYDRASPA error In-Reply-To: References: Message-ID: On Wed, Mar 4, 2020 at 3:41 AM alberto wrote: > > hi, > my name is Alberto > > Now I'm trying to install and use the code hydraspa (https://pypi.org/project/hydraspa/) > > I'm installing from source with command python 3.5 setup.py install > The README says "Hydraspa is actively being used and developed, if you encounter any issues drop me a line on the issue tracker." but that's no longer true. The last commit was in August 2018. I had to dig around quite a bit to find what Python versions it was tested against, since the README merely says "pip" without saying anything about versions (which is often a bad sign - it implies Py2). My best guess at the moment is that it was tested against 3.5 and/or 3.6, but probably only on Windows, using Anaconda. Given that the project has not been touched in two years, you're probably going to have to do a lot of manual digging around. Are you sure you need to use this exact package? ChrisA From mail.python.org at marco.sulla.e4ward.com Tue Mar 3 18:52:26 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Wed, 4 Mar 2020 00:52:26 +0100 Subject: `async def` breaks encapsulation? Message-ID: I worked a lot with `asyncio` many years ago, when `aiohttp` was first born. Now I'm working again with it, since a library that I need requires it. asyncio is much more simple to use now, but there's something that still make me doubtful: the require of the `async` keyword for coroutines. When I developed the aiohttp app, many times I changed my mind and an async function turned back to be a normal one. But in the meanwhile I'd used it for a bunch of coroutines, that I used for a bunch of coroutines etc... so I had to check all the affected coroutines and remove the `async` keyword from them. This recall me checked exceptions in Java. If you add to a Java method messTheCode() a `throws SomeException`, and subsequently you refactor the code so the exception is no more raised, you have to remove the `throws SomeException` from the function signature and to all the functions that used `messTheCode()` that decided to not handle the exception. (This is why I do not use checked exceptions in Java... I wrap them in unchecked ones. Yes, I'm an heretical :-D) The fact that puzzles me is that no additional keyword for coroutines was needed. A coroutines was simply a function with a `yield`. If it quacks... Why can't an asynchronous coroutine be simply a coroutine that has an `async` or an `await` in its code, without `async` in the signature? From larry.martell at gmail.com Wed Mar 4 10:20:11 2020 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 4 Mar 2020 15:20:11 +0000 Subject: pyodbc slowness Message-ID: I have some Python code that uses pyodbc to talk to a SQL Server database. In that code I do an INSERT INTO xxxx SELECT * FROM yyyy That query takes around 3 times longer to run when invoked from Python with pyodbc than when run with direct SQL. On one system we have 1,667 rows and the timings are direct sql 1.7s pyodbc 4.6s. On another system we have 15,000 rows and it's 15s vs 48s In both cases, I am running from the same machine over the same network talking to the same SQL Server. The only difference I can find is the driver. When I run the direct SQL the client I have uses the driver net.sourceforge.jtds.jdbc.Driver jtds12.jar where as pyodbc uses {ODBC Driver 17 for SQL Server}. Could this be the cause of the difference? Is there a different driver I can use with pyodbc that would be faster? From larry.martell at gmail.com Wed Mar 4 11:53:15 2020 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 4 Mar 2020 16:53:15 +0000 Subject: pyodbc slowness In-Reply-To: References: Message-ID: On Wed, Mar 4, 2020 at 3:20 PM Larry Martell wrote: > > I have some Python code that uses pyodbc to talk to a SQL Server database. In that code I do an INSERT INTO xxxx SELECT * FROM yyyy > > That query takes around 3 times longer to run when invoked from Python with pyodbc than when run with direct SQL. > > On one system we have 1,667 rows and the timings are direct sql 1.7s pyodbc 4.6s. On another system we have 15,000 rows and it's 15s vs 48s > > In both cases, I am running from the same machine over the same network talking to the same SQL Server. > > The only difference I can find is the driver. When I run the direct SQL the client I have uses the driver net.sourceforge.jtds.jdbc.Driver jtds12.jar where as pyodbc uses {ODBC Driver 17 for SQL Server}. > > Could this be the cause of the difference? Is there a different driver I can use with pyodbc that would be faster? I discovered the issue is that I am selecting from a view. When selecting from a table the time is the same. So what about a view would make it take longer when accessed from pyodbc? From adam.preble at gmail.com Wed Mar 4 12:12:53 2020 From: adam.preble at gmail.com (Adam Preble) Date: Wed, 4 Mar 2020 09:12:53 -0800 (PST) Subject: How does the super type present itself and do lookups? Message-ID: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com> Months ago, I asked a bunch of stuff about super() and managed to fake it well enough to move on to other things for awhile. The day of reckoning came this week and I was forced to implement it better for my personal Python project. I have a hack in place that makes it work well-enough but I found myself frustrated with how shift the super type is. It's both the self and the parent class, but not. If you don't know, you can trap what super() returns some time and poke it with a stick. If you print it you'll be able to tell it's definitely unique: , > If you try to invoke methods on it, it'll invoke the superclass' methods. That's what is supposed to happen and basically what already happens when you do super().invoke_this_thing() anyways. Okay, so how is it doing the lookup for that? The child instance and the super types' __dict__ are the same. The contents pass an equality comparison and are the same if you print them. They have the same __getattribute__ method wrapper. However, if you dir() them you definitely get different stuff. For one, the super type has its special variables __self__, __self_class__, and __thisclass__. It's missing __dict__ from the dir output. But wait, I just looked at that! So I'm thinking that __getattr__ is involved, but it's not listed in anything. If I use getattr on the super, I'll get the parent methods. If I use __getattribute__, I get the child's methods. I get errors every way I've conceived of trying to pull out a __getattr__ dunder. No love. I guess the fundamental question is: what different stuff happens when LOAD_ATTR is performed on a super object versus a regular object? If you are curious about what I'm doing right now, I overrode __getattribute__ since that's primarily what I use for attribute lookups right now. It defer to the superclass' __getattribute__. If a method pops out, it replaces the self with the super's __self__ before kicking it out. I feel kind of dirty doing it: https://github.com/rockobonaparte/cloaca/blob/312758b2abb80320fb3bf344ba540a034875bc4b/LanguageImplementation/DataTypes/PySuperType.cs#L36 If you want to see how I was experimenting with super, here's the code and output: class Parent: def __init__(self): self.a = 1 def stuff(self): print("Parent stuff!") class Child(Parent): def __init__(self): super().__init__() self.b = 2 self.super_instance = super() def stuff(self): print("Child stuff!") def only_in_child(self): print("Only in child!") c = Child() c.super_instance.__init__() c.stuff() c.super_instance.stuff() print(c) print(c.super_instance) print(c.__init__) print(c.super_instance.__init__) print(c.stuff) print(c.super_instance.stuff) print(c.__getattribute__) print(c.super_instance.__getattribute__) print(dir(c)) print(dir(c.super_instance)) print(c.__dict__ == c.super_instance.__dict__) print(getattr(c, "__init__")) print(getattr(c.super_instance, "__init__")) print(c.__getattribute__("__init__")) print(c.super_instance.__getattribute__("__init__")) Child stuff! Parent stuff! <__main__.Child object at 0x0000026854D99828> , > > > > > ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'a', 'b', 'only_in_child', 'stuff', 'super_instance'] ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__self_class__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__thisclass__', 'a', 'b', 'super_instance'] True > > > > From nad at python.org Wed Mar 4 12:58:05 2020 From: nad at python.org (Ned Deily) Date: Wed, 4 Mar 2020 12:58:05 -0500 Subject: [RELEASE] Python 3.7.7rc1 is now available for testing Message-ID: Details here: https://discuss.python.org/t/python-3-7-7rc1-is-now-available-for-testing/3638 https://www.python.org/downloads/release/python-377rc1/ -- Ned Deily nad at python.org -- [] From mail.python.org at marco.sulla.e4ward.com Tue Mar 3 16:50:06 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Tue, 3 Mar 2020 22:50:06 +0100 Subject: Help building python application from source In-Reply-To: References: Message-ID: Mh. I hoped not, but unluckily I expected a response like this. People of Python List, I strongly discourage you to support this user. He is quite suspicious for the following reasons: 1. he go so far as he offers money for, IMHO, a trivial task 2. he does not trust binaries from pip. He is so careful that he wants to freeze the libraries he will use and he want to compile them, so he can see the code and be sure that the binary was generated by that code. A lack of trust in open source projects that is quite unusual 3. I don't trust any cryptocurrency. I believe in privacy, but not in financial privacy. Yes, cryptocurrencies can be useful for circumvent bans from tyrannic states. But they can, and _are_ used, primarily to: - wash dirty money, by criminals and mafias - evade taxes - buy highly unethical "products", like weapons... and who know what other - finance tyrannies. I do _not_ think that all people that uses cryptocurrencies are criminals. I had, for example, some co-workers that invested in BitCoins, only for profit. But I do not trust this man, and I hope no one will offer support to him. By my side, I'll report this discussion to moderators. On Tue, 3 Mar 2020 at 04:24, Mr. Lee Chiffre wrote: > > > > I think I have the solution, but can I ask you why are you creating a > > bitcoin server? > > > Yes. I am a crypto anarchist. I have a bitcoin node to do my part to > running the bitcoin network and help remain it decentralized and > resilient. The more people that run a node the better it is. When it comes > to hosting servers I believe I am able to do so in a highly secure manner. > So I am doing my part in secure the bitcoin network and documenting what I > do to help others do the same thing. > > I support the bitcoin project because it is a liberty enhancing technology > to counter act over reaching government and expanding tyranny. People have > a right to financial privacy. And the world needs a secure financial > network to replace the existing institutional one that suffers from fraud > and theft. In a cyber dystopian world we live in there is a war on cash > and privacy to push us into a digital monetary system where governments > are able to spy on and control everything and everyone. If there is a need > for digital money let it be one that supports liberty instead of weakening > it. It is vital that cypher tech outpaces the police state. What we do > determines the future. We can let ourselves be enslaved and passive. Or we > can be active and support the solutions that create a better world and > preserve what is good. > > Right now it is a full node and not used for any other services or > purposes. If possible I would like to add electrumx so users of the > electrum wallet can use my server. Electrum is a very popular wallet and > is what comes pre installed with TAILS. > > -- > lee.chiffre at secmail.pro > PGP 97F0C3AE985A191DA0556BCAA82529E2025BDE35 > From pfreixes at gmail.com Wed Mar 4 16:29:20 2020 From: pfreixes at gmail.com (Pau Freixes) Date: Wed, 4 Mar 2020 22:29:20 +0100 Subject: How to solve a deadlock in an orthodox way Message-ID: Hi folks, During the development of a Python library which uses under the hood a C++ library - using Cyhton - we found a deadlock issue between a lock maintained by the C++ library and the GIL lock. The problem started to appear at the moment that we tried to offload all IO operations into an isolated thread. Basically, a thread running an Asyncio loop. Once this thread was added, we had to start using call_soon_threadsafe for scheduling new functions into the IO loop, hereby is when deadlocks start appearing. Why? Before adding the new thread for offloading the IO operations we were not releasing the GIL at each call to the C++ library, and in the very beginning tried to be stick to that plan which resulted to be nocive with the appearance of deadlocks. Two threads might have the following behaviour, which would result in a deadlock: 1 - (thread 1) (Cython) call a C++ function 2 - (thread 1) (C++ code) create a mutex X 3 - (thread 1) (C++ code) calls cython callback 4 - (thread 1) (Cython) calls call_son_threadsafe 5 - (thread 1) (Python) releases the GIL 6 - (thread 1) (Python) sock.sends(...) 7 - (thread 2) (Python) acquires GIL 8 - (thread 2) (Cython) call a C++ function 9 - (thread 2) (C++ code) tries to acquire the mutex X (gets locked) 10 - (thread 1) (Python) acuqires GIL (gets locked) The IO thread synchronization, which was done by writing to a specific FD, was releasing the GIL which would give the chance to other threads to be executed and have the chance on getting locked into the already locked mutex, ending up in a fatal deadlock. For addressing the situation we explicitly released the GIL at each C++ call, which solved the issue with some none negligible performance sacrificing. Do you have any idea how this deadlock could be prevented without having to release the GIL at each C++ call? Considering that we do not have any freedom on modifying the C++ code. We have a solution that might work but it's not easy to implement, or at least not for all of the environments. The idea is basically not running the piece of code that is implicitly releasing the GIL and deferring its execution to after the C++ code function. It seems to work quite well since the C++ code is basically an asynchronous framework that only needs to schedule a callback. This is doable in environments where we already have an Asyncio thread, its a matter of make a call to `call_soon(offload_io_work_into_another_thread, cb)`, but for environments where we do not have an automatic mechanism for deferring the execution of code we would need to implement them which could be a none straightforward task. Thoughts? Thanks! -- --pau From jim_ferraro at comcast.net Wed Mar 4 18:25:06 2020 From: jim_ferraro at comcast.net (Jim Ferraro) Date: Wed, 4 Mar 2020 23:25:06 +0000 Subject: What is the correct interpreter Message-ID: Where is the correct interpreter? I have installed python several times Pycharm all ways selects C:\ProgramFiles\JetBrains\PyCharm Community Edition 2019.3.3\bin\pycharm64.exe But when I run a simple code it objects to the interpreter??? Sent from Mail for Windows 10 From jayrod84 at gmail.com Wed Mar 4 18:51:13 2020 From: jayrod84 at gmail.com (J A) Date: Wed, 4 Mar 2020 18:51:13 -0500 Subject: Application setup like windows msi Message-ID: I was wondering g if there was a way to distribute an application that took advantage of user input like a windows .msi does. On linux of course. From torriem at gmail.com Wed Mar 4 20:48:59 2020 From: torriem at gmail.com (Michael Torrie) Date: Wed, 4 Mar 2020 18:48:59 -0700 Subject: Application setup like windows msi In-Reply-To: References: Message-ID: <039e166c-807b-31e7-d5dc-d68bc2b26456@gmail.com> On 3/4/20 4:51 PM, J A wrote: > I was wondering g if there was a way to distribute an application that took > advantage of user input like a windows .msi does. On linux of course. Several installer frameworks can make interactive installers for Linux. There's the NullSoft installer and InstallerVICE. And quite a few commercial packages have rolled their own installers. Although I find installers of any kind of annoying on Linux and don't seem all that necessary. From nad at python.org Wed Mar 4 22:05:51 2020 From: nad at python.org (Ned Deily) Date: Wed, 4 Mar 2020 22:05:51 -0500 Subject: [Python-Dev] [RELEASE] Python 3.7.7rc1 is now available for testing In-Reply-To: References: Message-ID: <040D4EFF-490B-48FE-89BB-BDB69671FA5E@python.org> On Mar 4, 2020, at 17:17, Jonathan Goble wrote: > On Wed, Mar 4, 2020 at 1:02 PM Ned Deily wrote: > Details here: > >> https://discuss.python.org/t/python-3-7-7rc1-is-now-available-for-testing/3638 >> >> "Assuming no critical problems are found prior to 2020-02-10..." > I would like to know how you expect people to travel back in time to report problems. :P python3.7 -m pip install guidos_time_machine If, for some reason that doesn't work, let's wait until 2020-03-10! -- Ned Deily nad at python.org -- [] From jcgoble3 at gmail.com Wed Mar 4 17:17:22 2020 From: jcgoble3 at gmail.com (Jonathan Goble) Date: Wed, 4 Mar 2020 17:17:22 -0500 Subject: [Python-Dev] [RELEASE] Python 3.7.7rc1 is now available for testing In-Reply-To: References: Message-ID: On Wed, Mar 4, 2020 at 1:02 PM Ned Deily wrote: > Details here: > > > https://discuss.python.org/t/python-3-7-7rc1-is-now-available-for-testing/3638 "Assuming no critical problems are found prior to *2020-02-10*..." I would like to know how you expect people to travel back in time to report problems. :P From nad at python.org Thu Mar 5 00:14:38 2020 From: nad at python.org (Ned Deily) Date: Thu, 5 Mar 2020 00:14:38 -0500 Subject: [Python-Dev] [RELEASE] Python 3.7.7rc1 is now available for testing In-Reply-To: References: Message-ID: <441D6E7A-9871-41D7-988A-AEBEDB38CDD0@python.org> On Mar 4, 2020, at 23:39, Jonathan Goble wrote: >> On Wed, Mar 4, 2020 at 10:05 PM Ned Deily wrote: >> On Mar 4, 2020, at 17:17, Jonathan Goble wrote: >> > On Wed, Mar 4, 2020 at 1:02 PM Ned Deily wrote: >> > Details here: >> >> https://discuss.python.org/t/python-3-7-7rc1-is-now-available-for-testing/3638 >> >> "Assuming no critical problems are found prior to 2020-02-10..." >> > I would like to know how you expect people to travel back in time to report problems. :P >> >> python3.7 -m pip install guidos_time_machine >> >> If, for some reason that doesn't work, let's wait until 2020-03-10! > > Well, it works now! (if you substitute dashes for the underscores) > > https://pypi.org/project/guidos-time-machine/ > > Brand new package uploaded by Guido 36 minutes ago. Python is great for just-in-time agile development, especially in future tenths. -- Ned Deily nad at python.org -- [] From miki.tebeka at gmail.com Thu Mar 5 00:40:43 2020 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 4 Mar 2020 21:40:43 -0800 (PST) Subject: What is the correct interpreter In-Reply-To: References: Message-ID: <8eafab40-8415-4b69-b209-6bd1ff9f8412@googlegroups.com> Hi, > Where is the correct interpreter? > I have installed python several times > Pycharm all ways selects > > C:\ProgramFiles\JetBrains\PyCharm Community Edition 2019.3.3\bin\pycharm64.exe This is the PyCharm executable, not the Python one. See https://www.jetbrains.com/help/pycharm/configuring-local-python-interpreters.html on how to configure the interpreter. > But when I run a simple code it objects to the interpreter??? I order to help we'll need more information. What is the code you're trying to run and what is the error? Happy hacking, Miki From ben.lists at bsb.me.uk Thu Mar 5 07:20:23 2020 From: ben.lists at bsb.me.uk (Ben Bacarisse) Date: Thu, 05 Mar 2020 12:20:23 +0000 Subject: =?iso-8859-1?Q?=FF?= in Unicode References: Message-ID: <87y2sfngc8.fsf@bsb.me.uk> moi writes: >>>> '?'.encode('utf-8') > b'\xc3\xbf' >>>> '?'.encode('utf-16-le') > b'\xff\x00' >>>> '?'.encode('utf-32-le') > b'\xff\x00\x00\x00' That all looks as expected. Is there something about the output that puzzles you? Did you have a question? -- Ben. From skip.montanaro at gmail.com Thu Mar 5 11:14:52 2020 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Thu, 5 Mar 2020 10:14:52 -0600 Subject: Pip borks the #! line when installing pylint from Python sandbox In-Reply-To: References: Message-ID: I originally sent this to the code-quality list, but in retrospect (and considering the crickets), I think c.l.py would have been a better starting point. ------------------------------------------------ I'm working on Python from GitHub, so have a fork which I check out and keep synced with the main repo. I run pylint on my code (which is nominally aimed at finding its way into Python someday), so installed it using pip: ./python -m pip install --user pylint (I prefer to tie pylint to the Python version I'm working on, if for no other reason than that as Python 3.9alpha moves along, this might flag something needing the Pylint team's attention.) This downloads whatever is necessary and installs it. Unfortunately, instead of creating a #! line of something like #!/home/skip/src/python/cpython/python it generates #!/usr/local/bin/python3.9 I didn't specify any sort of --prefix location when I configured, as I don't intend to install the code I'm working on. Mostly I just run "make test." I saw nothing like an --inplace flag in either Python's configure or pip's help output. It's not at all clear that I should give --prefix=$(pwd) to pip as I think that would install all subsidiary modules (pylint, astroid, etc) inside my Python sandbox. Is there some way coax pip into referencing my sandbox python executable, or will I be forced to edit the relevant command scripts once they are installed in ~/.local/bin? Thanks, Skip Montanaro From souvik.viksou at gmail.com Thu Mar 5 11:25:29 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Thu, 5 Mar 2020 21:55:29 +0530 Subject: Pip borks the #! line when installing pylint from Python sandbox In-Reply-To: References: Message-ID: The directory you stated is indeed the default directory as stated here https://unix.stackexchange.com/questions/240037/why-did-pip-install-a-package-into-local-bin What happens when you explicitly state the location where you want to store the package? Have you tried it? On Thu, Mar 5, 2020, 9:45 PM Skip Montanaro wrote: > I originally sent this to the code-quality list, but in retrospect (and > considering the crickets), I think c.l.py would have been a better > starting > point. > > ------------------------------------------------ > > I'm working on Python from GitHub, so have a fork which I check out > and keep synced with the main repo. I run pylint on my code (which is > nominally aimed at finding its way into Python someday), so installed > it using pip: > > ./python -m pip install --user pylint > > (I prefer to tie pylint to the Python version I'm working on, if for > no other reason than that as Python 3.9alpha moves along, this might > flag something needing the Pylint team's attention.) This downloads > whatever is necessary and installs it. Unfortunately, instead of > creating a #! line of something like > > #!/home/skip/src/python/cpython/python > > it generates > > #!/usr/local/bin/python3.9 > > I didn't specify any sort of --prefix location when I configured, as I > don't intend to install the code I'm working on. Mostly I just run > "make test." I saw nothing like an --inplace flag in either Python's > configure or pip's help output. It's not at all clear that I should > give --prefix=$(pwd) to pip as I think that would install all > subsidiary modules (pylint, astroid, etc) inside my Python sandbox. Is > there some way coax pip into referencing my sandbox python executable, > or will I be forced to edit the relevant command scripts once they are > installed in ~/.local/bin? > > Thanks, > > Skip Montanaro > -- > https://mail.python.org/mailman/listinfo/python-list > From souvik.viksou at gmail.com Thu Mar 5 11:29:14 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Thu, 5 Mar 2020 21:59:14 +0530 Subject: What is the correct interpreter In-Reply-To: References: Message-ID: You might try checking windows app management aliases by just tpying app management aliases in the search bar. There you should find two different version of python. One is the python which was available earlier in windows Store and the other one is the one you have installed in your machine. Try switching on and off alternatively till you drop facing your problem. On Thu, Mar 5, 2020, 4:59 AM Jim Ferraro wrote: > Where is the correct interpreter? > I have installed python several times > Pycharm all ways selects > > C:\ProgramFiles\JetBrains\PyCharm Community Edition > 2019.3.3\bin\pycharm64.exe > But when I run a simple code it objects to the interpreter??? > > > Sent from Mail for > Windows 10 > > -- > https://mail.python.org/mailman/listinfo/python-list > From skip.montanaro at gmail.com Thu Mar 5 11:46:15 2020 From: skip.montanaro at gmail.com (Skip Montanaro) Date: Thu, 5 Mar 2020 10:46:15 -0600 Subject: Pip borks the #! line when installing pylint from Python sandbox In-Reply-To: References: Message-ID: > > The directory you stated is indeed the default directory as stated here > > https://unix.stackexchange.com/questions/240037/why-did-pip-install-a-package-into-local-bin > What happens when you explicitly state the location where you want to > store the package? Have you tried it? > >> > > I had not, but as I expected, setting prefix to my sandbox, I wound up with everything installed inside my sandbox. In addition, the pylint command (as well as others in $PWD/bin) still referenced #!/usr/local/bin/python3.9. It's okay. I kind of thought I might be stuck. After all, I'm asking pip to do something for which it wasn't designed. I was hoping I'd missed something. (A --executable=/path/to/python/executable option would be nice.) Skip From auriocus at gmx.de Thu Mar 5 14:50:40 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Thu, 5 Mar 2020 20:50:40 +0100 Subject: Application setup like windows msi In-Reply-To: References: <039e166c-807b-31e7-d5dc-d68bc2b26456@gmail.com> Message-ID: Am 05.03.20 um 02:48 schrieb Michael Torrie: > On 3/4/20 4:51 PM, J A wrote: >> I was wondering g if there was a way to distribute an application that took >> advantage of user input like a windows .msi does. On linux of course. > > Several installer frameworks can make interactive installers for Linux. > There's the NullSoft installer and InstallerVICE. And quite a few > commercial packages have rolled their own installers. Although I find > installers of any kind of annoying on Linux and don't seem all that > necessary. > +1! On Linux, the most reasonable binary distribution is a .tar.bz2 package which extracts a folder with a startup script. This works on every Linux distribution and is one of the most common ways for Firefox etc. Of course, if you can afford to offer several packages, the other recommended way is packages for the system package manager - but this means it is system-dependent - or the newer things like flatpak and snap. However the tarball is the thing that always works, even for me as a user without root access. Christian From grant.b.edwards at gmail.com Thu Mar 5 14:46:27 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 5 Mar 2020 19:46:27 -0000 (UTC) Subject: Application setup like windows msi References: <039e166c-807b-31e7-d5dc-d68bc2b26456@gmail.com> Message-ID: On 2020-03-05, Michael Torrie wrote: > On 3/4/20 4:51 PM, J A wrote: >> I was wondering g if there was a way to distribute an application that took >> advantage of user input like a windows .msi does. On linux of course. > > Several installer frameworks can make interactive installers for Linux. > There's the NullSoft installer and InstallerVICE. And quite a few > commercial packages have rolled their own installers. Although I find > installers of any kind of annoying on Linux and don't seem all that > necessary. I prefer a .tar file and a readme.txt file that says to run setup.py. But then again, I run Gentoo. ;) -- Grant Edwards grant.b.edwards Yow! I guess it was all a at DREAM ... or an episode of gmail.com HAWAII FIVE-O ... From ben.usenet at bsb.me.uk Fri Mar 6 05:28:32 2020 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Fri, 06 Mar 2020 10:28:32 +0000 Subject: =?iso-8859-1?Q?=FF?= in Unicode References: <87y2sfngc8.fsf@bsb.me.uk> <039cd461-4e64-4d3f-b51e-4ee85bc97bb8@googlegroups.com> Message-ID: <87tv3122wf.fsf@bsb.me.uk> moi writes: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ?crit?: >> moi writes: >> >> >>>> '?'.encode('utf-8') >> > b'\xc3\xbf' >> >>>> '?'.encode('utf-16-le') >> > b'\xff\x00' >> >>>> '?'.encode('utf-32-le') >> > b'\xff\x00\x00\x00' >> > >> That all looks as expected. > Yes > >>Is there something about the output that puzzles you? > No > >>Did you have a question? > No, only a comment > > This buggy language is very amusing. Whilst I am happy that you are entertained by Python, the ability to encode strings in various transfer formats does not strike me as being particularly amusing. But there's little enough happiness in the world, so take it where you can! -- Ben. From rosuav at gmail.com Fri Mar 6 06:25:59 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 6 Mar 2020 22:25:59 +1100 Subject: =?UTF-8?Q?Re=3A_=C3=BF_in_Unicode?= In-Reply-To: <87tv3122wf.fsf@bsb.me.uk> References: <87y2sfngc8.fsf@bsb.me.uk> <039cd461-4e64-4d3f-b51e-4ee85bc97bb8@googlegroups.com> <87tv3122wf.fsf@bsb.me.uk> Message-ID: On Fri, Mar 6, 2020 at 9:31 PM Ben Bacarisse wrote: > > moi writes: > > > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ?crit : > >> moi writes: > >> > >> >>>> '?'.encode('utf-8') > >> > b'\xc3\xbf' > >> >>>> '?'.encode('utf-16-le') > >> > b'\xff\x00' > >> >>>> '?'.encode('utf-32-le') > >> > b'\xff\x00\x00\x00' > >> > > > >> That all looks as expected. > > Yes > > > >>Is there something about the output that puzzles you? > > No > > > >>Did you have a question? > > No, only a comment > > > > This buggy language is very amusing. > > Whilst I am happy that you are entertained by Python, the ability to > encode strings in various transfer formats does not strike me as being > particularly amusing. But there's little enough happiness in the world, > so take it where you can! > FYI he's blocked from the mailing list and is in most people's killfiles. Ignore him - he never has anything useful to say, and his idea of "buggy" disagrees with, well, the whole rest of the world. ChrisA From jon+usenet at unequivocal.eu Fri Mar 6 07:52:45 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Fri, 6 Mar 2020 12:52:45 -0000 (UTC) Subject: =?UTF-8?Q?=C3=BF?= in Unicode References: <87y2sfngc8.fsf@bsb.me.uk> <039cd461-4e64-4d3f-b51e-4ee85bc97bb8@googlegroups.com> Message-ID: On 2020-03-06, moi wrote: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ?crit?: >> moi writes: >> >>>> '?'.encode('utf-8') >> > b'\xc3\xbf' >> >>>> '?'.encode('utf-16-le') >> > b'\xff\x00' >> >>>> '?'.encode('utf-32-le') >> > b'\xff\x00\x00\x00' > >> That all looks as expected. > Yes > >>Is there something about the output that puzzles you? > No > >>Did you have a question? > No, only a comment > > This buggy language is very amusing. What's the bug, or source of amusement? From sinndhhu at gmail.com Fri Mar 6 07:59:26 2020 From: sinndhhu at gmail.com (sinndhhu at gmail.com) Date: Fri, 6 Mar 2020 04:59:26 -0800 (PST) Subject: iterate through an irregular nested list in Python Message-ID: <0e1f3b5b-9a08-4d30-919e-919b4df8de0d@googlegroups.com> Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] expected output: 2,jkj,,,kite,88,ooo,pop,push,pull,hello From vergos.nikolas at gmail.com Fri Mar 6 08:33:46 2020 From: vergos.nikolas at gmail.com (=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?=) Date: Fri, 6 Mar 2020 05:33:46 -0800 (PST) Subject: How to POST html data to be handled by a route endpoint Message-ID: <1a4558c4-a05d-4e6b-9426-2ddc70398c26@googlegroups.com> First i must say i use Bottle, but the same may also be the case in Flask too. I ask here and not in sub Bottle because there are only a few people there and i receive no responses. Actualy since i started here let me say what i have found. Iam just trying to post html form data to the following endpoint. @app.route( '/mailform', method=['POST'] ) IF i try to post the html form data using the the endpoint url way, i get "Method NOT Allowed" error:
WHILE if i try the following way, i receive no error. ...html...
''' % app.get_url( '/mailform ) Can someone explain why?! From pieter-l at vanoostrum.org Fri Mar 6 09:35:45 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Fri, 06 Mar 2020 15:35:45 +0100 Subject: =?utf-8?Q?=C3=BF?= in Unicode References: <87y2sfngc8.fsf@bsb.me.uk> <039cd461-4e64-4d3f-b51e-4ee85bc97bb8@googlegroups.com> Message-ID: Jon Ribbens writes: > On 2020-03-06, moi wrote: >> Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ?crit?: >>> moi writes: >>> >>>> '?'.encode('utf-8') >>> > b'\xc3\xbf' >>> >>>> '?'.encode('utf-16-le') >>> > b'\xff\x00' >>> >>>> '?'.encode('utf-32-le') >>> > b'\xff\x00\x00\x00' >> >>> That all looks as expected. >> Yes >> >>>Is there something about the output that puzzles you? >> No >> >>>Did you have a question? >> No, only a comment >> >> This buggy language is very amusing. > > What's the bug, or source of amusement? The bug is in the mental world of the OP. -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From pieter-l at vanoostrum.org Fri Mar 6 09:54:40 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Fri, 06 Mar 2020 15:54:40 +0100 Subject: iterate through an irregular nested list in Python References: <0e1f3b5b-9a08-4d30-919e-919b4df8de0d@googlegroups.com> Message-ID: sinndhhu at gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > Use a recursive iterator/generator: It becomes a bit peculiar because you want special treatment for empty lists inside, but otherwise it is quite standard Python: aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] def reclist(aList): for item in aList: if isinstance(item, list): if item == []: yield '' else: yield from reclist(item) else: yield item for i in reclist(aList): print(i, end=',') This gives you an extra comma at the end, unfortunately. But it is the pattern for other types of processing. Or use it like this: print (','.join(str(i) for i in reclist(aList))) -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From lee.chiffre at secmail.pro Thu Mar 5 23:49:14 2020 From: lee.chiffre at secmail.pro (Mr. Lee Chiffre) Date: Thu, 5 Mar 2020 20:49:14 -0800 Subject: Python question In-Reply-To: References: Message-ID: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> Thank you Marco for at least taking the time to read my message even if you do not agree with me on things. And no disrespect to you. But I came here for python related questions and help. Not to be called suspicious and untrustworthy only because I am concerned about security of users and for being a advocate of privacy. Then to call for me to be censored is just ludicrous. > People of Python List, I strongly discourage you to support this user. > He is quite suspicious for the following reasons: > > 1. he go so far as he offers money for, IMHO, a trivial task I said I am a python noob. This is why I asked for help. And I see no issue in offering payment for a programming task. > 2. he does not trust binaries from pip. What is the point of open source if you cannot compile from source code? > code. A lack of trust in open source projects that is quite unusual > 3. I don't trust any cryptocurrency. Not unusual. People use open source because they dont trust closed source. Binaries that someone else compiled is not open source. > I believe in privacy, but not in financial privacy. Yes, > cryptocurrencies can be useful for circumvent bans from tyrannic > states. But they can, and _are_ used, primarily to: > - wash dirty money, by criminals and mafias > - evade taxes > - buy highly unethical "products", like weapons... and who know what > other > - finance tyrannies. Roads and cars are used by drug dealers. Stop using roads and cars. Cash is used by criminals. Stop using cash. Internet is used by child abusers. Stop supporting the internet. I am offended that you group me with criminals and baddies because I support technological privacy. > > I do _not_ think that all people that uses cryptocurrencies are > criminals. I had, for example, some co-workers that invested in > BitCoins, only for profit. > > But I do not trust this man, and I hope no one will offer support to > him. By my side, I'll report this discussion to moderators. That is fine if you dont like something. You dont have to help me out if you dont want to. But trying to censor me is unethical. Hopefully other people will have the logic to make decisions for themselves and give me help on python if they choose to do so. I hope my reply does not get censored. I am being reasonable here. And if you are wondering why I am "paranoid", you would be too if you are dealing with a server that might host a hot wallet. I dont want my server getting hacked just because I was too lazy to compile my own code. And it is not uncommon for binaries of open source projects to be injected with malware. From ethan at stoneleaf.us Fri Mar 6 10:59:58 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 6 Mar 2020 07:59:58 -0800 Subject: Help building python application from source In-Reply-To: References: Message-ID: On 03/03/2020 01:50 PM, Marco Sulla via Python-list wrote: > People of Python List, I strongly discourage you to support this user. > He is quite suspicious for the following reasons: Marco, this is not an appropriate response. If you have concerns about list behavior then email the list owners. If you have evidence of wrong-doing then email the list owners and do what you can to contact the appropriate authorities. Asking the list to not help someone because you disagree with their beliefs will not be tolerated. Consider this your warning. -- ~Ethan~ From souvik.viksou at gmail.com Fri Mar 6 11:18:13 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Fri, 6 Mar 2020 21:48:13 +0530 Subject: iterate through an irregular nested list in Python In-Reply-To: <0e1f3b5b-9a08-4d30-919e-919b4df8de0d@googlegroups.com> References: <0e1f3b5b-9a08-4d30-919e-919b4df8de0d@googlegroups.com> Message-ID: A better way would be to just do nestedl = [[2], [], [], [l, b, n]] #nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which we can be easily overcome by using an if statement to check the elements type. On Fri, 6 Mar, 2020, 6:30 pm , wrote: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > -- > https://mail.python.org/mailman/listinfo/python-list > On Fri, 6 Mar, 2020, 6:30 pm , wrote: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > -- > https://mail.python.org/mailman/listinfo/python-list > From jon+usenet at unequivocal.eu Fri Mar 6 11:15:35 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Fri, 6 Mar 2020 16:15:35 -0000 (UTC) Subject: =?UTF-8?Q?=C3=BF?= in Unicode References: <87y2sfngc8.fsf@bsb.me.uk> <039cd461-4e64-4d3f-b51e-4ee85bc97bb8@googlegroups.com> Message-ID: On 2020-03-06, Pieter van Oostrum wrote: > Jon Ribbens writes: >> On 2020-03-06, moi wrote: >>> Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ?crit?: >>>> moi writes: >>>> >>>> '?'.encode('utf-8') >>>> > b'\xc3\xbf' >>>> >>>> '?'.encode('utf-16-le') >>>> > b'\xff\x00' >>>> >>>> '?'.encode('utf-32-le') >>>> > b'\xff\x00\x00\x00' >>> >>>> That all looks as expected. >>> Yes >>> >>>>Is there something about the output that puzzles you? >>> No >>> >>>>Did you have a question? >>> No, only a comment >>> >>> This buggy language is very amusing. >> >> What's the bug, or source of amusement? > > The bug is in the mental world of the OP. Quite possibly. I must admit I was just interested to learn what they thought was wrong or amusing in the above. There's plenty of room to have reasonable differing opinions on Unicode strings and how they're implemented in languages, but it's not at all obvious what could be different in those specific expressions. From souvik.viksou at gmail.com Fri Mar 6 11:24:59 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Fri, 6 Mar 2020 21:54:59 +0530 Subject: Python question In-Reply-To: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> Message-ID: This is not a place to quarrel our only task is to discuss and help other learn and learn ourselves. To Mr. Marco what Mr. Lee says is correct. Since he is working on a cryptocurrency project and he might use our original code in his final project I don't think offering money is bad. After all there have been times when a person demands his name to included in the credits page. Our sole task is to help. And you cannot form opinions for other people's by saying them not to support a person. That is injustice and rude. On Fri, 6 Mar, 2020, 9:14 pm Mr. Lee Chiffre, wrote: > Thank you Marco for at least taking the time to read my message even if > you do not agree with me on things. And no disrespect to you. But I came > here for python related questions and help. Not to be called suspicious > and untrustworthy only because I am concerned about security of users and > for being a advocate of privacy. Then to call for me to be censored is > just ludicrous. > > > > People of Python List, I strongly discourage you to support this user. > > He is quite suspicious for the following reasons: > > > > 1. he go so far as he offers money for, IMHO, a trivial task > > I said I am a python noob. This is why I asked for help. And I see no > issue in offering payment for a programming task. > > > 2. he does not trust binaries from pip. > > What is the point of open source if you cannot compile from source code? > > > code. A lack of trust in open source projects that is quite unusual > > 3. I don't trust any cryptocurrency. > > Not unusual. People use open source because they dont trust closed source. > Binaries that someone else compiled is not open source. > > > I believe in privacy, but not in financial privacy. Yes, > > cryptocurrencies can be useful for circumvent bans from tyrannic > > states. But they can, and _are_ used, primarily to: > > - wash dirty money, by criminals and mafias > > - evade taxes > > - buy highly unethical "products", like weapons... and who know what > > other > > - finance tyrannies. > > Roads and cars are used by drug dealers. Stop using roads and cars. Cash > is used by criminals. Stop using cash. Internet is used by child abusers. > Stop supporting the internet. I am offended that you group me with > criminals and baddies because I support technological privacy. > > > > > > I do _not_ think that all people that uses cryptocurrencies are > > criminals. I had, for example, some co-workers that invested in > > BitCoins, only for profit. > > > > But I do not trust this man, and I hope no one will offer support to > > him. By my side, I'll report this discussion to moderators. > > That is fine if you dont like something. You dont have to help me out if > you dont want to. But trying to censor me is unethical. Hopefully other > people will have the logic to make decisions for themselves and give me > help on python if they choose to do so. > > I hope my reply does not get censored. I am being reasonable here. And if > you are wondering why I am "paranoid", you would be too if you are dealing > with a server that might host a hot wallet. I dont want my server getting > hacked just because I was too lazy to compile my own code. And it is not > uncommon for binaries of open source projects to be injected with malware. > > > > -- > https://mail.python.org/mailman/listinfo/python-list > From drsalists at gmail.com Fri Mar 6 13:00:50 2020 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 6 Mar 2020 10:00:50 -0800 Subject: iterate through an irregular nested list in Python In-Reply-To: References: <0e1f3b5b-9a08-4d30-919e-919b4df8de0d@googlegroups.com> Message-ID: On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinndhhu at gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in advance. > > > > Sample Ex > > > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > > > expected output: > > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > > > Use a recursive iterator/generator: > It becomes a bit peculiar because you want special treatment for empty > lists inside, > but otherwise it is quite standard Python: > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > def reclist(aList): > for item in aList: > if isinstance(item, list): > if item == []: > yield '' > else: > yield from reclist(item) > else: > yield item > > for i in reclist(aList): > print(i, end=',') > > This gives you an extra comma at the end, unfortunately. > But it is the pattern for other types of processing. > > Or use it like this: > > print (','.join(str(i) for i in reclist(aList))) > If your lists are nested to inconsistent depth, and you're on a modern version of Python (3.3 and up), recursion with yield from (as above) is the way to go. If your lists are nested to a consistent depth (as your example seems to suggest), you can just: for sublist in aList: for element in sublist: yield element If you need inconsistent depth and you're on an old version of python, yield from is unavailable. In that case, it's best to write it out recursively (even though that won't work really), and modify that to be nonrecursive using an explicit stack or stacks. There's an example of this at: http://stromberg.dnsalias.org/svn/treap/trunk/m4_treap.m4 See iterator_macro. Don't let the m4 throw you - it's just a way of deriving pure python and cython from the same file. You can generate the pure python form the .m4 file with simply: m4 -Dpy=1 < m4_treap.m4 > py_treap.py ...if you install an m4 binary. HTH. From pieter-l at vanoostrum.org Fri Mar 6 15:54:40 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Fri, 06 Mar 2020 15:54:40 -0500 Subject: iterate through an irregular nested list in Python References: Message-ID: sinndhhu at gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > Use a recursive iterator/generator: It becomes a bit peculiar because you want special treatment for empty lists inside, but otherwise it is quite standard Python: aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] def reclist(aList): for item in aList: if isinstance(item, list): if item == []: yield '' else: yield from reclist(item) else: yield item for i in reclist(aList): print(i, end=',') This gives you an extra comma at the end, unfortunately. But it is the pattern for other types of processing. Or use it like this: print (','.join(str(i) for i in reclist(aList))) -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From ethan at stoneleaf.us Fri Mar 6 07:59:58 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 06 Mar 2020 07:59:58 -0500 Subject: Help building python application from source Message-ID: On 03/03/2020 01:50 PM, Marco Sulla via Python-list wrote: > People of Python List, I strongly discourage you to support this user. > He is quite suspicious for the following reasons: Marco, this is not an appropriate response. If you have concerns about list behavior then email the list owners. If you have evidence of wrong-doing then email the list owners and do what you can to contact the appropriate authorities. Asking the list to not help someone because you disagree with their beliefs will not be tolerated. Consider this your warning. -- ~Ethan~ From jon+usenet at unequivocal.eu Fri Mar 6 16:15:34 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Fri, 06 Mar 2020 16:15:34 -0500 Subject: =?UTF-8?Q?=C3=BF?= in Unicode References: Message-ID: On 2020-03-06, Pieter van Oostrum wrote: > Jon Ribbens writes: >> On 2020-03-06, moi wrote: >>> Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ?Ccrit? : >>>> moi writes: >>>> >>>> '??'.encode('utf-8') >>>> > b'\xc3\xbf' >>>> >>>> '??'.encode('utf-16-le') >>>> > b'\xff\x00' >>>> >>>> '??'.encode('utf-32-le') >>>> > b'\xff\x00\x00\x00' >>> >>>> That all looks as expected. >>> Yes >>> >>>>Is there something about the output that puzzles you? >>> No >>> >>>>Did you have a question? >>> No, only a comment >>> >>> This buggy language is very amusing. >> >> What's the bug, or source of amusement? > > The bug is in the mental world of the OP. Quite possibly. I must admit I was just interested to learn what they thought was wrong or amusing in the above. There's plenty of room to have reasonable differing opinions on Unicode strings and how they're implemented in languages, but it's not at all obvious what could be different in those specific expressions. From souvik.viksou at gmail.com Fri Mar 6 21:48:12 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Fri, 06 Mar 2020 21:48:12 -0500 Subject: iterate through an irregular nested list in Python Message-ID: A better way would be to just do nestedl = [[2], [], [], [l, b, n]] #nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which we can be easily overcome by using an if statement to check the elements type. On Fri, 6 Mar, 2020, 6:30 pm , wrote: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > -- > https://mail.python.org/mailman/listinfo/python-list > On Fri, 6 Mar, 2020, 6:30 pm , wrote: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > -- > https://mail.python.org/mailman/listinfo/python-list > From auriocus at gmx.de Thu Mar 5 20:50:40 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Thu, 05 Mar 2020 20:50:40 -0500 Subject: Application setup like windows msi Message-ID: Am 05.03.20 um 02:48 schrieb Michael Torrie: > On 3/4/20 4:51 PM, J A wrote: >> I was wondering g if there was a way to distribute an application that took >> advantage of user input like a windows .msi does. On linux of course. > > Several installer frameworks can make interactive installers for Linux. > There's the NullSoft installer and InstallerVICE. And quite a few > commercial packages have rolled their own installers. Although I find > installers of any kind of annoying on Linux and don't seem all that > necessary. > +1! On Linux, the most reasonable binary distribution is a .tar.bz2 package which extracts a folder with a startup script. This works on every Linux distribution and is one of the most common ways for Firefox etc. Of course, if you can afford to offer several packages, the other recommended way is packages for the system package manager - but this means it is system-dependent - or the newer things like flatpak and snap. However the tarball is the thing that always works, even for me as a user without root access. Christian From grant.b.edwards at gmail.com Thu Mar 5 19:46:26 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 05 Mar 2020 19:46:26 -0500 Subject: Application setup like windows msi Message-ID: On 2020-03-05, Michael Torrie wrote: > On 3/4/20 4:51 PM, J A wrote: >> I was wondering g if there was a way to distribute an application that took >> advantage of user input like a windows .msi does. On linux of course. > > Several installer frameworks can make interactive installers for Linux. > There's the NullSoft installer and InstallerVICE. And quite a few > commercial packages have rolled their own installers. Although I find > installers of any kind of annoying on Linux and don't seem all that > necessary. I prefer a .tar file and a readme.txt file that says to run setup.py. But then again, I run Gentoo. ;) -- Grant Edwards grant.b.edwards Yow! I guess it was all a at DREAM ... or an episode of gmail.com HAWAII FIVE-O ... From ben.usenet at bsb.me.uk Fri Mar 6 10:28:32 2020 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Fri, 06 Mar 2020 10:28:32 -0500 Subject: =?utf-8?B?w78=?= in Unicode References: Message-ID: moi writes: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ?crit : >> moi writes: >> >> >>>> '?'.encode('utf-8') >> > b'\xc3\xbf' >> >>>> '?'.encode('utf-16-le') >> > b'\xff\x00' >> >>>> '?'.encode('utf-32-le') >> > b'\xff\x00\x00\x00' >> > >> That all looks as expected. > Yes > >>Is there something about the output that puzzles you? > No > >>Did you have a question? > No, only a comment > > This buggy language is very amusing. Whilst I am happy that you are entertained by Python, the ability to encode strings in various transfer formats does not strike me as being particularly amusing. But there's little enough happiness in the world, so take it where you can! -- Ben. From souvik.viksou at gmail.com Fri Mar 6 21:54:58 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Fri, 06 Mar 2020 21:54:58 -0500 Subject: Python question Message-ID: This is not a place to quarrel our only task is to discuss and help other learn and learn ourselves. To Mr. Marco what Mr. Lee says is correct. Since he is working on a cryptocurrency project and he might use our original code in his final project I don't think offering money is bad. After all there have been times when a person demands his name to included in the credits page. Our sole task is to help. And you cannot form opinions for other people's by saying them not to support a person. That is injustice and rude. On Fri, 6 Mar, 2020, 9:14 pm Mr. Lee Chiffre, wrote: > Thank you Marco for at least taking the time to read my message even if > you do not agree with me on things. And no disrespect to you. But I came > here for python related questions and help. Not to be called suspicious > and untrustworthy only because I am concerned about security of users and > for being a advocate of privacy. Then to call for me to be censored is > just ludicrous. > > > > People of Python List, I strongly discourage you to support this user. > > He is quite suspicious for the following reasons: > > > > 1. he go so far as he offers money for, IMHO, a trivial task > > I said I am a python noob. This is why I asked for help. And I see no > issue in offering payment for a programming task. > > > 2. he does not trust binaries from pip. > > What is the point of open source if you cannot compile from source code? > > > code. A lack of trust in open source projects that is quite unusual > > 3. I don't trust any cryptocurrency. > > Not unusual. People use open source because they dont trust closed source. > Binaries that someone else compiled is not open source. > > > I believe in privacy, but not in financial privacy. Yes, > > cryptocurrencies can be useful for circumvent bans from tyrannic > > states. But they can, and _are_ used, primarily to: > > - wash dirty money, by criminals and mafias > > - evade taxes > > - buy highly unethical "products", like weapons... and who know what > > other > > - finance tyrannies. > > Roads and cars are used by drug dealers. Stop using roads and cars. Cash > is used by criminals. Stop using cash. Internet is used by child abusers. > Stop supporting the internet. I am offended that you group me with > criminals and baddies because I support technological privacy. > > > > > > I do _not_ think that all people that uses cryptocurrencies are > > criminals. I had, for example, some co-workers that invested in > > BitCoins, only for profit. > > > > But I do not trust this man, and I hope no one will offer support to > > him. By my side, I'll report this discussion to moderators. > > That is fine if you dont like something. You dont have to help me out if > you dont want to. But trying to censor me is unethical. Hopefully other > people will have the logic to make decisions for themselves and give me > help on python if they choose to do so. > > I hope my reply does not get censored. I am being reasonable here. And if > you are wondering why I am "paranoid", you would be too if you are dealing > with a server that might host a hot wallet. I dont want my server getting > hacked just because I was too lazy to compile my own code. And it is not > uncommon for binaries of open source projects to be injected with malware. > > > > -- > https://mail.python.org/mailman/listinfo/python-list > From jon+usenet at unequivocal.eu Fri Mar 6 12:52:44 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Fri, 06 Mar 2020 12:52:44 -0500 Subject: =?UTF-8?Q?=C3=BF?= in Unicode References: Message-ID: On 2020-03-06, moi wrote: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ?Ccrit? : >> moi writes: >> >>>> '??'.encode('utf-8') >> > b'\xc3\xbf' >> >>>> '??'.encode('utf-16-le') >> > b'\xff\x00' >> >>>> '??'.encode('utf-32-le') >> > b'\xff\x00\x00\x00' > >> That all looks as expected. > Yes > >>Is there something about the output that puzzles you? > No > >>Did you have a question? > No, only a comment > > This buggy language is very amusing. What's the bug, or source of amusement? From rosuav at gmail.com Fri Mar 6 22:25:58 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 06 Mar 2020 22:25:58 -0500 Subject: =?UTF-8?Q?Re=3A_=C3=BF_in_Unicode?= Message-ID: On Fri, Mar 6, 2020 at 9:31 PM Ben Bacarisse wrote: > > moi writes: > > > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ?Ccrit : > >> moi writes: > >> > >> >>>> '??'.encode('utf-8') > >> > b'\xc3\xbf' > >> >>>> '??'.encode('utf-16-le') > >> > b'\xff\x00' > >> >>>> '??'.encode('utf-32-le') > >> > b'\xff\x00\x00\x00' > >> > > > >> That all looks as expected. > > Yes > > > >>Is there something about the output that puzzles you? > > No > > > >>Did you have a question? > > No, only a comment > > > > This buggy language is very amusing. > > Whilst I am happy that you are entertained by Python, the ability to > encode strings in various transfer formats does not strike me as being > particularly amusing. But there's little enough happiness in the world, > so take it where you can! > FYI he's blocked from the mailing list and is in most people's killfiles. Ignore him - he never has anything useful to say, and his idea of "buggy" disagrees with, well, the whole rest of the world. ChrisA From vergos.nikolas at gmail.com Fri Mar 6 05:33:46 2020 From: vergos.nikolas at gmail.com (=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?=) Date: Fri, 06 Mar 2020 05:33:46 -0500 Subject: How to POST html data to be handled by a route endpoint Message-ID: First i must say i use Bottle, but the same may also be the case in Flask too. I ask here and not in sub Bottle because there are only a few people there and i receive no responses. Actualy since i started here let me say what i have found. Iam just trying to post html form data to the following endpoint. @app.route( '/mailform', method=['POST'] ) IF i try to post the html form data using the the endpoint url way, i get "Method NOT Allowed" error:
WHILE if i try the following way, i receive no error. ...html...
''' % app.get_url( '/mailform ) Can someone explain why?! From sinndhhu at gmail.com Fri Mar 6 04:59:26 2020 From: sinndhhu at gmail.com (sinndhhu) Date: Fri, 06 Mar 2020 04:59:26 -0500 Subject: iterate through an irregular nested list in Python Message-ID: Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] expected output: 2,jkj,,,kite,88,ooo,pop,push,pull,hello From pieter-l at vanoostrum.org Fri Mar 6 15:35:44 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Fri, 06 Mar 2020 15:35:44 -0500 Subject: =?utf-8?Q?=C3=BF?= in Unicode References: Message-ID: Jon Ribbens writes: > On 2020-03-06, moi wrote: >> Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ?Ccrit? : >>> moi writes: >>> >>>> '??'.encode('utf-8') >>> > b'\xc3\xbf' >>> >>>> '??'.encode('utf-16-le') >>> > b'\xff\x00' >>> >>>> '??'.encode('utf-32-le') >>> > b'\xff\x00\x00\x00' >> >>> That all looks as expected. >> Yes >> >>>Is there something about the output that puzzles you? >> No >> >>>Did you have a question? >> No, only a comment >> >> This buggy language is very amusing. > > What's the bug, or source of amusement? The bug is in the mental world of the OP. -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From drsalists at gmail.com Fri Mar 6 10:00:50 2020 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 06 Mar 2020 10:00:50 -0500 Subject: iterate through an irregular nested list in Python Message-ID: On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinndhhu at gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in advance. > > > > Sample Ex > > > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > > > expected output: > > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > > > Use a recursive iterator/generator: > It becomes a bit peculiar because you want special treatment for empty > lists inside, > but otherwise it is quite standard Python: > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > def reclist(aList): > for item in aList: > if isinstance(item, list): > if item == []: > yield '' > else: > yield from reclist(item) > else: > yield item > > for i in reclist(aList): > print(i, end=',') > > This gives you an extra comma at the end, unfortunately. > But it is the pattern for other types of processing. > > Or use it like this: > > print (','.join(str(i) for i in reclist(aList))) > If your lists are nested to inconsistent depth, and you're on a modern version of Python (3.3 and up), recursion with yield from (as above) is the way to go. If your lists are nested to a consistent depth (as your example seems to suggest), you can just: for sublist in aList: for element in sublist: yield element If you need inconsistent depth and you're on an old version of python, yield from is unavailable. In that case, it's best to write it out recursively (even though that won't work really), and modify that to be nonrecursive using an explicit stack or stacks. There's an example of this at: http://stromberg.dnsalias.org/svn/treap/trunk/m4_treap.m4 See iterator_macro. Don't let the m4 throw you - it's just a way of deriving pure python and cython from the same file. You can generate the pure python form the .m4 file with simply: m4 -Dpy=1 < m4_treap.m4 > py_treap.py ...if you install an m4 binary. HTH. From pieter-l at vanoostrum.org Fri Mar 6 15:35:44 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Fri, 06 Mar 2020 15:35:44 -0500 Subject: =?utf-8?Q?=C3=BF?= in Unicode References: Message-ID: Jon Ribbens writes: > On 2020-03-06, moi wrote: >> Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ??Ccrit?? : >>> moi writes: >>> >>>> '????'.encode('utf-8') >>> > b'\xc3\xbf' >>> >>>> '????'.encode('utf-16-le') >>> > b'\xff\x00' >>> >>>> '????'.encode('utf-32-le') >>> > b'\xff\x00\x00\x00' >> >>> That all looks as expected. >> Yes >> >>>Is there something about the output that puzzles you? >> No >> >>>Did you have a question? >> No, only a comment >> >> This buggy language is very amusing. > > What's the bug, or source of amusement? The bug is in the mental world of the OP. -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From jon+usenet at unequivocal.eu Fri Mar 6 16:15:34 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Fri, 06 Mar 2020 16:15:34 -0500 Subject: =?UTF-8?Q?=C3=BF?= in Unicode References: Message-ID: On 2020-03-06, Pieter van Oostrum wrote: > Jon Ribbens writes: >> On 2020-03-06, moi wrote: >>> Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ??Ccrit?? : >>>> moi writes: >>>> >>>> '????'.encode('utf-8') >>>> > b'\xc3\xbf' >>>> >>>> '????'.encode('utf-16-le') >>>> > b'\xff\x00' >>>> >>>> '????'.encode('utf-32-le') >>>> > b'\xff\x00\x00\x00' >>> >>>> That all looks as expected. >>> Yes >>> >>>>Is there something about the output that puzzles you? >>> No >>> >>>>Did you have a question? >>> No, only a comment >>> >>> This buggy language is very amusing. >> >> What's the bug, or source of amusement? > > The bug is in the mental world of the OP. Quite possibly. I must admit I was just interested to learn what they thought was wrong or amusing in the above. There's plenty of room to have reasonable differing opinions on Unicode strings and how they're implemented in languages, but it's not at all obvious what could be different in those specific expressions. From jon+usenet at unequivocal.eu Fri Mar 6 12:52:44 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Fri, 06 Mar 2020 12:52:44 -0500 Subject: =?UTF-8?Q?=C3=BF?= in Unicode References: Message-ID: On 2020-03-06, moi wrote: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ??Ccrit?? : >> moi writes: >> >>>> '????'.encode('utf-8') >> > b'\xc3\xbf' >> >>>> '????'.encode('utf-16-le') >> > b'\xff\x00' >> >>>> '????'.encode('utf-32-le') >> > b'\xff\x00\x00\x00' > >> That all looks as expected. > Yes > >>Is there something about the output that puzzles you? > No > >>Did you have a question? > No, only a comment > > This buggy language is very amusing. What's the bug, or source of amusement? From pieter-l at vanoostrum.org Fri Mar 6 15:54:40 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Fri, 06 Mar 2020 15:54:40 -0500 Subject: iterate through an irregular nested list in Python References: Message-ID: sinndhhu at gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > Use a recursive iterator/generator: It becomes a bit peculiar because you want special treatment for empty lists inside, but otherwise it is quite standard Python: aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] def reclist(aList): for item in aList: if isinstance(item, list): if item == []: yield '' else: yield from reclist(item) else: yield item for i in reclist(aList): print(i, end=',') This gives you an extra comma at the end, unfortunately. But it is the pattern for other types of processing. Or use it like this: print (','.join(str(i) for i in reclist(aList))) -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From souvik.viksou at gmail.com Fri Mar 6 21:48:12 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Fri, 06 Mar 2020 21:48:12 -0500 Subject: iterate through an irregular nested list in Python Message-ID: A better way would be to just do nestedl = [[2], [], [], [l, b, n]] #nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which we can be easily overcome by using an if statement to check the elements type. On Fri, 6 Mar, 2020, 6:30 pm , wrote: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > -- > https://mail.python.org/mailman/listinfo/python-list > On Fri, 6 Mar, 2020, 6:30 pm , wrote: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > -- > https://mail.python.org/mailman/listinfo/python-list > From ethan at stoneleaf.us Fri Mar 6 07:59:58 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 06 Mar 2020 07:59:58 -0500 Subject: Help building python application from source Message-ID: On 03/03/2020 01:50 PM, Marco Sulla via Python-list wrote: > People of Python List, I strongly discourage you to support this user. > He is quite suspicious for the following reasons: Marco, this is not an appropriate response. If you have concerns about list behavior then email the list owners. If you have evidence of wrong-doing then email the list owners and do what you can to contact the appropriate authorities. Asking the list to not help someone because you disagree with their beliefs will not be tolerated. Consider this your warning. -- ~Ethan~ From =?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?= Fri Mar 6 05:33:46 2020 From: =?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?= (=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs) Date: Fri, 06 Mar 2020 05:33:46 -0500 Subject: How to POST html data to be handled by a route endpoint Message-ID: First i must say i use Bottle, but the same may also be the case in Flask too. I ask here and not in sub Bottle because there are only a few people there and i receive no responses. Actualy since i started here let me say what i have found. Iam just trying to post html form data to the following endpoint. @app.route( '/mailform', method=['POST'] ) IF i try to post the html form data using the the endpoint url way, i get "Method NOT Allowed" error:
WHILE if i try the following way, i receive no error. ...html...
''' % app.get_url( '/mailform ) Can someone explain why?! From drsalists at gmail.com Fri Mar 6 10:00:50 2020 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 06 Mar 2020 10:00:50 -0500 Subject: iterate through an irregular nested list in Python Message-ID: On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinndhhu at gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in advance. > > > > Sample Ex > > > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > > > expected output: > > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > > > Use a recursive iterator/generator: > It becomes a bit peculiar because you want special treatment for empty > lists inside, > but otherwise it is quite standard Python: > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > def reclist(aList): > for item in aList: > if isinstance(item, list): > if item == []: > yield '' > else: > yield from reclist(item) > else: > yield item > > for i in reclist(aList): > print(i, end=',') > > This gives you an extra comma at the end, unfortunately. > But it is the pattern for other types of processing. > > Or use it like this: > > print (','.join(str(i) for i in reclist(aList))) > If your lists are nested to inconsistent depth, and you're on a modern version of Python (3.3 and up), recursion with yield from (as above) is the way to go. If your lists are nested to a consistent depth (as your example seems to suggest), you can just: for sublist in aList: for element in sublist: yield element If you need inconsistent depth and you're on an old version of python, yield from is unavailable. In that case, it's best to write it out recursively (even though that won't work really), and modify that to be nonrecursive using an explicit stack or stacks. There's an example of this at: http://stromberg.dnsalias.org/svn/treap/trunk/m4_treap.m4 See iterator_macro. Don't let the m4 throw you - it's just a way of deriving pure python and cython from the same file. You can generate the pure python form the .m4 file with simply: m4 -Dpy=1 < m4_treap.m4 > py_treap.py ...if you install an m4 binary. HTH. From grant.b.edwards at gmail.com Thu Mar 5 19:46:26 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 05 Mar 2020 19:46:26 -0500 Subject: Application setup like windows msi Message-ID: On 2020-03-05, Michael Torrie wrote: > On 3/4/20 4:51 PM, J A wrote: >> I was wondering g if there was a way to distribute an application that took >> advantage of user input like a windows .msi does. On linux of course. > > Several installer frameworks can make interactive installers for Linux. > There's the NullSoft installer and InstallerVICE. And quite a few > commercial packages have rolled their own installers. Although I find > installers of any kind of annoying on Linux and don't seem all that > necessary. I prefer a .tar file and a readme.txt file that says to run setup.py. But then again, I run Gentoo. ;) -- Grant Edwards grant.b.edwards Yow! I guess it was all a at DREAM ... or an episode of gmail.com HAWAII FIVE-O ... From souvik.viksou at gmail.com Fri Mar 6 21:54:58 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Fri, 06 Mar 2020 21:54:58 -0500 Subject: Python question Message-ID: This is not a place to quarrel our only task is to discuss and help other learn and learn ourselves. To Mr. Marco what Mr. Lee says is correct. Since he is working on a cryptocurrency project and he might use our original code in his final project I don't think offering money is bad. After all there have been times when a person demands his name to included in the credits page. Our sole task is to help. And you cannot form opinions for other people's by saying them not to support a person. That is injustice and rude. On Fri, 6 Mar, 2020, 9:14 pm Mr. Lee Chiffre, wrote: > Thank you Marco for at least taking the time to read my message even if > you do not agree with me on things. And no disrespect to you. But I came > here for python related questions and help. Not to be called suspicious > and untrustworthy only because I am concerned about security of users and > for being a advocate of privacy. Then to call for me to be censored is > just ludicrous. > > > > People of Python List, I strongly discourage you to support this user. > > He is quite suspicious for the following reasons: > > > > 1. he go so far as he offers money for, IMHO, a trivial task > > I said I am a python noob. This is why I asked for help. And I see no > issue in offering payment for a programming task. > > > 2. he does not trust binaries from pip. > > What is the point of open source if you cannot compile from source code? > > > code. A lack of trust in open source projects that is quite unusual > > 3. I don't trust any cryptocurrency. > > Not unusual. People use open source because they dont trust closed source. > Binaries that someone else compiled is not open source. > > > I believe in privacy, but not in financial privacy. Yes, > > cryptocurrencies can be useful for circumvent bans from tyrannic > > states. But they can, and _are_ used, primarily to: > > - wash dirty money, by criminals and mafias > > - evade taxes > > - buy highly unethical "products", like weapons... and who know what > > other > > - finance tyrannies. > > Roads and cars are used by drug dealers. Stop using roads and cars. Cash > is used by criminals. Stop using cash. Internet is used by child abusers. > Stop supporting the internet. I am offended that you group me with > criminals and baddies because I support technological privacy. > > > > > > I do _not_ think that all people that uses cryptocurrencies are > > criminals. I had, for example, some co-workers that invested in > > BitCoins, only for profit. > > > > But I do not trust this man, and I hope no one will offer support to > > him. By my side, I'll report this discussion to moderators. > > That is fine if you dont like something. You dont have to help me out if > you dont want to. But trying to censor me is unethical. Hopefully other > people will have the logic to make decisions for themselves and give me > help on python if they choose to do so. > > I hope my reply does not get censored. I am being reasonable here. And if > you are wondering why I am "paranoid", you would be too if you are dealing > with a server that might host a hot wallet. I dont want my server getting > hacked just because I was too lazy to compile my own code. And it is not > uncommon for binaries of open source projects to be injected with malware. > > > > -- > https://mail.python.org/mailman/listinfo/python-list > From ben.usenet at bsb.me.uk Fri Mar 6 10:28:32 2020 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Fri, 06 Mar 2020 10:28:32 -0500 Subject: =?utf-8?B?w78=?= in Unicode References: Message-ID: moi writes: > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ?Ccrit : >> moi writes: >> >> >>>> '??'.encode('utf-8') >> > b'\xc3\xbf' >> >>>> '??'.encode('utf-16-le') >> > b'\xff\x00' >> >>>> '??'.encode('utf-32-le') >> > b'\xff\x00\x00\x00' >> > >> That all looks as expected. > Yes > >>Is there something about the output that puzzles you? > No > >>Did you have a question? > No, only a comment > > This buggy language is very amusing. Whilst I am happy that you are entertained by Python, the ability to encode strings in various transfer formats does not strike me as being particularly amusing. But there's little enough happiness in the world, so take it where you can! -- Ben. From auriocus at gmx.de Thu Mar 5 20:50:40 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Thu, 05 Mar 2020 20:50:40 -0500 Subject: Application setup like windows msi Message-ID: Am 05.03.20 um 02:48 schrieb Michael Torrie: > On 3/4/20 4:51 PM, J A wrote: >> I was wondering g if there was a way to distribute an application that took >> advantage of user input like a windows .msi does. On linux of course. > > Several installer frameworks can make interactive installers for Linux. > There's the NullSoft installer and InstallerVICE. And quite a few > commercial packages have rolled their own installers. Although I find > installers of any kind of annoying on Linux and don't seem all that > necessary. > +1! On Linux, the most reasonable binary distribution is a .tar.bz2 package which extracts a folder with a startup script. This works on every Linux distribution and is one of the most common ways for Firefox etc. Of course, if you can afford to offer several packages, the other recommended way is packages for the system package manager - but this means it is system-dependent - or the newer things like flatpak and snap. However the tarball is the thing that always works, even for me as a user without root access. Christian From rosuav at gmail.com Fri Mar 6 22:25:58 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 06 Mar 2020 22:25:58 -0500 Subject: =?UTF-8?Q?Re=3A_=C3=BF_in_Unicode?= Message-ID: On Fri, Mar 6, 2020 at 9:31 PM Ben Bacarisse wrote: > > moi writes: > > > Le jeudi 5 mars 2020 13:20:38 UTC+1, Ben Bacarisse a ??Ccrit : > >> moi writes: > >> > >> >>>> '????'.encode('utf-8') > >> > b'\xc3\xbf' > >> >>>> '????'.encode('utf-16-le') > >> > b'\xff\x00' > >> >>>> '????'.encode('utf-32-le') > >> > b'\xff\x00\x00\x00' > >> > > > >> That all looks as expected. > > Yes > > > >>Is there something about the output that puzzles you? > > No > > > >>Did you have a question? > > No, only a comment > > > > This buggy language is very amusing. > > Whilst I am happy that you are entertained by Python, the ability to > encode strings in various transfer formats does not strike me as being > particularly amusing. But there's little enough happiness in the world, > so take it where you can! > FYI he's blocked from the mailing list and is in most people's killfiles. Ignore him - he never has anything useful to say, and his idea of "buggy" disagrees with, well, the whole rest of the world. ChrisA From sinndhhu at gmail.com Fri Mar 6 04:59:26 2020 From: sinndhhu at gmail.com (sinndhhu) Date: Fri, 06 Mar 2020 04:59:26 -0500 Subject: iterate through an irregular nested list in Python Message-ID: Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] expected output: 2,jkj,,,kite,88,ooo,pop,push,pull,hello From lee.chiffre at secmail.pro Thu Mar 5 20:49:14 2020 From: lee.chiffre at secmail.pro (Mr. Lee Chiffre) Date: Thu, 05 Mar 2020 20:49:14 -0500 Subject: Python question Message-ID: Thank you Marco for at least taking the time to read my message even if you do not agree with me on things. And no disrespect to you. But I came here for python related questions and help. Not to be called suspicious and untrustworthy only because I am concerned about security of users and for being a advocate of privacy. Then to call for me to be censored is just ludicrous. > People of Python List, I strongly discourage you to support this user. > He is quite suspicious for the following reasons: > > 1. he go so far as he offers money for, IMHO, a trivial task I said I am a python noob. This is why I asked for help. And I see no issue in offering payment for a programming task. > 2. he does not trust binaries from pip. What is the point of open source if you cannot compile from source code? > code. A lack of trust in open source projects that is quite unusual > 3. I don't trust any cryptocurrency. Not unusual. People use open source because they dont trust closed source. Binaries that someone else compiled is not open source. > I believe in privacy, but not in financial privacy. Yes, > cryptocurrencies can be useful for circumvent bans from tyrannic > states. But they can, and _are_ used, primarily to: > - wash dirty money, by criminals and mafias > - evade taxes > - buy highly unethical "products", like weapons... and who know what > other > - finance tyrannies. Roads and cars are used by drug dealers. Stop using roads and cars. Cash is used by criminals. Stop using cash. Internet is used by child abusers. Stop supporting the internet. I am offended that you group me with criminals and baddies because I support technological privacy. > > I do _not_ think that all people that uses cryptocurrencies are > criminals. I had, for example, some co-workers that invested in > BitCoins, only for profit. > > But I do not trust this man, and I hope no one will offer support to > him. By my side, I'll report this discussion to moderators. That is fine if you dont like something. You dont have to help me out if you dont want to. But trying to censor me is unethical. Hopefully other people will have the logic to make decisions for themselves and give me help on python if they choose to do so. I hope my reply does not get censored. I am being reasonable here. And if you are wondering why I am "paranoid", you would be too if you are dealing with a server that might host a hot wallet. I dont want my server getting hacked just because I was too lazy to compile my own code. And it is not uncommon for binaries of open source projects to be injected with malware. From PythonList at DancesWithMice.info Fri Mar 6 17:33:48 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Sat, 7 Mar 2020 11:33:48 +1300 Subject: How to POST html data to be handled by a route endpoint In-Reply-To: <1a4558c4-a05d-4e6b-9426-2ddc70398c26@googlegroups.com> References: <1a4558c4-a05d-4e6b-9426-2ddc70398c26@googlegroups.com> Message-ID: <0be67a73-00ea-f33b-b894-14e4411d720a@DancesWithMice.info> On 7/03/20 2:33 AM, ????? ?????? wrote: > First i must say i use Bottle, but the same may also be the case in Flask too. I ask here and not in sub Bottle because there are only a few people there and i receive no responses. > > Actualy since i started here let me say what i have found. > > Iam just trying to post html form data to the following endpoint. > > @app.route( '/mailform', method=['POST'] ) > IF i try to post the html form data using the the endpoint url way, i get "Method NOT Allowed" error: > >
> > > WHILE if i try the following way, i receive no error. > > ...html...
''' % app.get_url( '/mailform ) > > Can someone explain why?! Please post the full error message and traceback. To clarify: is the error coming from Python or from the web server? -- Regards =dn From bernard+work at ei8fdb.org Fri Mar 6 18:23:29 2020 From: bernard+work at ei8fdb.org (Bernard Tyers - Sane UX Design) Date: Fri, 6 Mar 2020 23:23:29 +0000 Subject: pip UX Studies - help improve the usability of pip Message-ID: Hi there, My name is Bernard Tyers. I'm a UX designer and have recently started working on the PSF project to improve the usability of pip, funded by MOSS/CZI. I want to let you know about the pip UX Studies we've started today, and encourage you to sign-up and take part. The pip Team is looking for Python users who use pip to take part in our UX Studies. Your input will have a direct impact on improving pip. We want to speak with as diverse a group as possible. We'd particularly like to speak with people with accessibility needs. You _don't_ have to be a Python expert to take part - I can't stress this enough! You can find out all the details you'll need and find the sign-up link on this blogpost: http://www.ei8fdb.org/thoughts/2020/03/pip-ux-study-recruitment/ If you do have questions I've not answered there, let me know. We'd also appreciate some signal boosting to reach as wide an audience as possible. Please share the blog post with people in different Python using communities. If you're a Twitter/Mastodon user we'd appreciate a signal boost of these also: https://twitter.com/bernardtyers/status/1236039617222230017 https://social.ei8fdb.org/@bernard/103778645553767728 Thank you for your attention! Best wishes, Bernard -- Bernard Tyers, User research & Interaction Design T: @bernardtyers M: @bernard at social.ei8fdb.org PGP Key: keybase.io/ei8fdb I work on User-Centred Design, Open Source Software and Privacy. From jon+usenet at unequivocal.eu Fri Mar 6 20:55:20 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Sat, 7 Mar 2020 01:55:20 -0000 (UTC) Subject: =?UTF-8?Q?=C3=BF?= in Unicode References: Message-ID: On 2020-03-06, Jon Ribbens wrote: > What's the bug, or source of amusement? Oh, that's fun. There's a Russian Fidonet gateway, that somehow still exists, that's re-injecting usenet posts back into the group. From torriem at gmail.com Fri Mar 6 22:06:40 2020 From: torriem at gmail.com (Michael Torrie) Date: Fri, 6 Mar 2020 20:06:40 -0700 Subject: Using zipfile to create a zip file with directories and files inside those directories Message-ID: <33e71132-b9e6-b480-eeb5-3ca9a82791d4@gmail.com> I am trying to do something very simple but having no success in finding out how to do it. I just want to use the Python zipfile module to create a zip file with a specific directory structure and create and write to files inside those subdirectories (not files already on disk). The documentation talks about writing files from disk, but I'm interested in creating these files from within Python directly in the zip archive. I've read over the docs several times but nothing speaks to this, and none of the examples I've searched for show this either. I thought that in zip files, directories are really just part of the name of the file, and if unless you tell unzip not to, it creates them as files are extracted. So I naively thought I could use the "open" method of zipfile, giving it a relative path describing the relative path and file name that I want to then write bytes to. But seems I am mistaken. Is this a limitation of the zip format that cannot allow that sort of thing? Must I resort to temporary files? Plenty of examples on how to create an archive from existing files and directories on disk of course, which isn't what I want to do. From souvik.viksou at gmail.com Fri Mar 6 22:11:25 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Sat, 7 Mar 2020 08:41:25 +0530 Subject: Is there something similar to guidechimp in python? Message-ID: This is guidechimp -https://github.com/Labs64/GuideChimp Is there anything similar to this in python? From musbur at posteo.org Sat Mar 7 03:08:58 2020 From: musbur at posteo.org (musbur at posteo.org) Date: Sat, 7 Mar 2020 09:08:58 +0100 Subject: Using zipfile to create a zip file with directories and files inside those directories In-Reply-To: <33e71132-b9e6-b480-eeb5-3ca9a82791d4@gmail.com> References: <33e71132-b9e6-b480-eeb5-3ca9a82791d4@gmail.com> Message-ID: <20200307090858.2ed2afd1@nxp10225> On Fri, 6 Mar 2020 20:06:40 -0700 Michael Torrie wrote: > The documentation talks about writing files from > disk, but I'm interested in creating these files from within Python > directly in the zip archive. But you have seen writestr(), haven't you? ZipFile.writestr(zinfo_or_arcname, data, compress_type=None, compresslevel=None) Write a file into the archive. The contents is data, which may be either a str or a bytes instance; > So I naively thought I could use the "open" > method of zipfile, giving it a relative path describing the relative > path and file name that I want to then write bytes to. But seems I am > mistaken. No your're not. writestr() and ZipInfo are your friends, unless I haven't understood what you're trying to do. From vergos.nikolas at gmail.com Sat Mar 7 05:15:36 2020 From: vergos.nikolas at gmail.com (=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?=) Date: Sat, 7 Mar 2020 02:15:36 -0800 (PST) Subject: How to POST html data to be handled by a route endpoint In-Reply-To: References: <1a4558c4-a05d-4e6b-9426-2ddc70398c26@googlegroups.com> <0be67a73-00ea-f33b-b894-14e4411d720a@DancesWithMice.info> Message-ID: ?? ???????, 7 ??????? 2020 - 12:34:21 ?.?. UTC+2, ? ??????? DL Neil ??????: > Please post the full error message and traceback. > > To clarify: is the error coming from Python or from the web server? I beleive it comes from the web server. Here it is: Error: 500 Internal Server Error Sorry, the requested URL 'http://superhost.gr/mailform' caused an error: Internal Server Error Exception: TypeError("argument of type 'NoneType' is not iterable",) Traceback: Traceback (most recent call last): File "/home/nikos/wsgi/bottle.py", line 996, in _handle out = route.call(**args) File "/home/nikos/wsgi/bottle.py", line 2007, in wrapper rv = callback(*a, **ka) File "/home/nikos/wsgi/www.py", line 189, in mailform if provider in FROM: TypeError: argument of type 'NoneType' is not iterable I somehow beleive that the following apache conf directives somehow create problem. When superhost.gr/test tries to post html form data to the route endpoint '/mailform' it sends it to superhost.gr/mailform and NOT at superhost.gr/test/mailform as it should have done. They somehow interfere. Here is the processes running in the webserver that somehow interfere. WSGIDaemonProcess test user=nikos group=nikos home=/home/nikos/wsgi WSGIScriptAlias /test /home/nikos/wsgi/test.py process-group=test application-group=%{GLOBAL} WSGIDaemonProcess www user=nikos group=nikos home=/home/nikos/wsgi WSGIScriptAliasMatch / /home/nikos/wsgi/www.py process-group=www application-group=%{GLOBAL} From address at not.available Sat Mar 7 05:32:59 2020 From: address at not.available (R.Wieser) Date: Sat, 7 Mar 2020 11:32:59 +0100 Subject: =?UTF-8?B?UmU6IMO/IGluIFVuaWNvZGU=?= References: <14c1ba2b-9131-451a-a239-721cdb64ca18@googlegroups.com> Message-ID: Moi, > - Today, there are still people who do not understand a > "?' can not be *safely* encoded with a single byte. It can (and has been done for ages), just not in the character encoding method you've choosen to use. > - Python == Latin-1 mess (as somebody wrote on a mailing list). Putting blanket, unsupported statements forward doesn't score you any points. Feel free to come up with examples* though, as well as (ofcourse) how you think it could have been done better *examples in regard how Python fails to use the character encoding according to its definition. Any complaint towards the encoding itself doesn't belong in this newsgroup. But, seeing that you started this thread with posting stuff that actually works**as advertised I won't hold my breath. **instead of supporting your 'Python makes a mess of it' stance. Which ofcourse suggests that that example is actually the worst thing you could come up with - but only shows both Python and the UTF-x encodings working as expected. > - This "Flexible string representation" succeded to reintroduced > the mess of the coding of characters. Nope. That /you/ don't understand how the UTF-x character encoding works doesn't mean others do not either. > Once you get this, it's a child play to produce failing Python code. > Python approach. Do you know how to take a car engine apart and rebuild it ? No ? Than you also suck at cooking food, am I right ? (You eat in the car, you transport food by it. The connection is /obviously/ there :-) ) > Other possibility, take a "utf-NNN tool" (lib), C# (Powershell), > golang and show these tools are correctly working where Python > fails for the same task. Kiddo, all I have seen you do is to suggest that UTF encoding is bad(1), and by association Python is bad(2), by making some reference to other programs that do it better(3) and where Python fails(4) (1),(2),(3),(4) - None of which are underbuild, let alone proven. In short, hollow and meaningless drivel. Acceptable for a politician, but not for a programmer/scripter. > A real funny mess. Very amusing. Oh well, you at least get /some/ enjoyment outof knowing* the Python language. * I'm just assuming you are not actually /using/ it, as its so bad and you got a range of better languages at your disposal. But that does make me wonder why you are posting here to start with. Although, I think I can guess ... Regards, Rudy Wieser From vergos.nikolas at gmail.com Sat Mar 7 08:10:37 2020 From: vergos.nikolas at gmail.com (=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?=) Date: Sat, 7 Mar 2020 05:10:37 -0800 (PST) Subject: How to POST html data to be handled by a route endpoint In-Reply-To: References: <1a4558c4-a05d-4e6b-9426-2ddc70398c26@googlegroups.com> <0be67a73-00ea-f33b-b894-14e4411d720a@DancesWithMice.info> Message-ID: You will see if you create a route endpoint called 'mailform' within '/' which is an alias of 'www.py' and you also have '/mailform' in 'superhost.gr/test' when the latter tries to post data to '/mailform' instead of sending them to 'superhost.gr/test/' it sends them to '/' which is 'superhost.gr' From torriem at gmail.com Sat Mar 7 09:48:49 2020 From: torriem at gmail.com (Michael Torrie) Date: Sat, 7 Mar 2020 07:48:49 -0700 Subject: Using zipfile to create a zip file with directories and files inside those directories In-Reply-To: <20200307090858.2ed2afd1@nxp10225> References: <33e71132-b9e6-b480-eeb5-3ca9a82791d4@gmail.com> <20200307090858.2ed2afd1@nxp10225> Message-ID: <7bc05fc7-b426-d16a-ef08-208ce0627269@gmail.com> On 3/7/20 1:08 AM, musbur at posteo.org wrote: > On Fri, 6 Mar 2020 20:06:40 -0700 > Michael Torrie wrote: > >> The documentation talks about writing files from >> disk, but I'm interested in creating these files from within Python >> directly in the zip archive. > > But you have seen writestr(), haven't you? Yes, that's what I was using. Turns out I didn't look closely enough at the exception I was getting. What i thought was zipfile complaining about a '/' character was really Python complaining about a bad string formatting string I was using! Thanks for confirming that zipfile indeed should work the way I hoped it wood. I'm in business now. thank you. From ethan at stoneleaf.us Sat Mar 7 10:13:44 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Sat, 7 Mar 2020 07:13:44 -0800 Subject: wxjmfauth posts Message-ID: All, wxjmfauth is a known troll who posts on the usenet comp.lang.python. Their posts are discarded from Python List. If you choose to interact with them anyway, please: - leave `wxjmfauth` in the attribution lines so those replies can be discarded - keep your discourse civil Thank you. -- ~Ethan~ Python List Moderator From address at not.available Sat Mar 7 10:40:41 2020 From: address at not.available (R.Wieser) Date: Sat, 7 Mar 2020 16:40:41 +0100 Subject: =?UTF-8?B?UmU6IMO/IGluIFVuaWNvZGU=?= References: <14c1ba2b-9131-451a-a239-721cdb64ca18@googlegroups.com> Message-ID: Moi, > Fortunately, UTF-8 has not been created the Python devs. And there we go again, making vague statements/accusations - without /anything/ to back it up ofcourse Kiddo, you have posted a couple of messages now, but have said exactly nothing. Are you sure you do not want to go into politics ? Regards, Rudy Wieser From ben.usenet at bsb.me.uk Sat Mar 7 12:52:47 2020 From: ben.usenet at bsb.me.uk (Ben Bacarisse) Date: Sat, 07 Mar 2020 17:52:47 +0000 Subject: =?iso-8859-1?Q?=FF?= in Unicode References: <14c1ba2b-9131-451a-a239-721cdb64ca18@googlegroups.com> <95670409-21da-4667-b6cb-9d38bb5c48cc@googlegroups.com> Message-ID: <875zfg128g.fsf@bsb.me.uk> moi writes: > Le samedi 7 mars 2020 16:41:10 UTC+1, R.Wieser a ?crit?: >> Moi, >> >> > Fortunately, UTF-8 has not been created the Python devs. >> >> And there we go again, making vague statements/accusations - without >> /anything/ to back it up ofcourse >> >> Kiddo, you have posted a couple of messages now, but have said exactly >> nothing. Are you sure you do not want to go into politics ? >> > The day, when this language will stop to interpret a byte > as being a Latin-1 (ISO-8859-1) character, this language will > start to work properly. >>> "?".encode('iso-8859-1') b'\xff' -- Ben. From Richard at Damon-Family.org Sat Mar 7 13:09:45 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Sat, 7 Mar 2020 13:09:45 -0500 Subject: =?UTF-8?Q?Re=3a_=c3=bf_in_Unicode?= In-Reply-To: <875zfg128g.fsf@bsb.me.uk> References: <14c1ba2b-9131-451a-a239-721cdb64ca18@googlegroups.com> <95670409-21da-4667-b6cb-9d38bb5c48cc@googlegroups.com> <875zfg128g.fsf@bsb.me.uk> Message-ID: On 3/7/20 12:52 PM, Ben Bacarisse wrote: > moi writes: > >> Le samedi 7 mars 2020 16:41:10 UTC+1, R.Wieser a ?crit?: >>> Moi, >>> >>>> Fortunately, UTF-8 has not been created the Python devs. >>> >>> And there we go again, making vague statements/accusations - without >>> /anything/ to back it up ofcourse >>> >>> Kiddo, you have posted a couple of messages now, but have said exactly >>> nothing. Are you sure you do not want to go into politics ? >>> >> The day, when this language will stop to interpret a byte >> as being a Latin-1 (ISO-8859-1) character, this language will >> start to work properly. > >>>> "?".encode('iso-8859-1') > b'\xff' > or the reverse. b'\xff'.decode('iso-8859-1') '?' iso-8859-1 just isn't the DEFAULT character encoding to use. From grant.b.edwards at gmail.com Sat Mar 7 10:35:56 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sat, 7 Mar 2020 15:35:56 -0000 (UTC) Subject: =?UTF-8?Q?=C3=BF?= in Unicode References: Message-ID: On 2020-03-07, Jon Ribbens via Python-list wrote: > On 2020-03-06, Jon Ribbens wrote: >> What's the bug, or source of amusement? > > Oh, that's fun. There's a Russian Fidonet gateway, that somehow > still exists, that's re-injecting usenet posts back into the group. Last time I think it was one in Australia. -- Grant From ethan at stoneleaf.us Fri Mar 6 07:59:58 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 06 Mar 2020 07:59:58 -0500 Subject: Help building python application from source Message-ID: On 03/03/2020 01:50 PM, Marco Sulla via Python-list wrote: > People of Python List, I strongly discourage you to support this user. > He is quite suspicious for the following reasons: Marco, this is not an appropriate response. If you have concerns about list behavior then email the list owners. If you have evidence of wrong-doing then email the list owners and do what you can to contact the appropriate authorities. Asking the list to not help someone because you disagree with their beliefs will not be tolerated. Consider this your warning. -- ~Ethan~ From souvik.viksou at gmail.com Fri Mar 6 21:48:12 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Fri, 06 Mar 2020 21:48:12 -0500 Subject: iterate through an irregular nested list in Python Message-ID: A better way would be to just do nestedl = [[2], [], [], [l, b, n]] #nested list for a in nestedl: #taking all the sublist for b in a: #iterating through the sub print(b) Though it is easy the only limitation is that it works only if the elements are lists. Which we can be easily overcome by using an if statement to check the elements type. On Fri, 6 Mar, 2020, 6:30 pm , wrote: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > -- > https://mail.python.org/mailman/listinfo/python-list > On Fri, 6 Mar, 2020, 6:30 pm , wrote: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > -- > https://mail.python.org/mailman/listinfo/python-list > From souvik.viksou at gmail.com Fri Mar 6 21:54:58 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Fri, 06 Mar 2020 21:54:58 -0500 Subject: Python question Message-ID: This is not a place to quarrel our only task is to discuss and help other learn and learn ourselves. To Mr. Marco what Mr. Lee says is correct. Since he is working on a cryptocurrency project and he might use our original code in his final project I don't think offering money is bad. After all there have been times when a person demands his name to included in the credits page. Our sole task is to help. And you cannot form opinions for other people's by saying them not to support a person. That is injustice and rude. On Fri, 6 Mar, 2020, 9:14 pm Mr. Lee Chiffre, wrote: > Thank you Marco for at least taking the time to read my message even if > you do not agree with me on things. And no disrespect to you. But I came > here for python related questions and help. Not to be called suspicious > and untrustworthy only because I am concerned about security of users and > for being a advocate of privacy. Then to call for me to be censored is > just ludicrous. > > > > People of Python List, I strongly discourage you to support this user. > > He is quite suspicious for the following reasons: > > > > 1. he go so far as he offers money for, IMHO, a trivial task > > I said I am a python noob. This is why I asked for help. And I see no > issue in offering payment for a programming task. > > > 2. he does not trust binaries from pip. > > What is the point of open source if you cannot compile from source code? > > > code. A lack of trust in open source projects that is quite unusual > > 3. I don't trust any cryptocurrency. > > Not unusual. People use open source because they dont trust closed source. > Binaries that someone else compiled is not open source. > > > I believe in privacy, but not in financial privacy. Yes, > > cryptocurrencies can be useful for circumvent bans from tyrannic > > states. But they can, and _are_ used, primarily to: > > - wash dirty money, by criminals and mafias > > - evade taxes > > - buy highly unethical "products", like weapons... and who know what > > other > > - finance tyrannies. > > Roads and cars are used by drug dealers. Stop using roads and cars. Cash > is used by criminals. Stop using cash. Internet is used by child abusers. > Stop supporting the internet. I am offended that you group me with > criminals and baddies because I support technological privacy. > > > > > > I do _not_ think that all people that uses cryptocurrencies are > > criminals. I had, for example, some co-workers that invested in > > BitCoins, only for profit. > > > > But I do not trust this man, and I hope no one will offer support to > > him. By my side, I'll report this discussion to moderators. > > That is fine if you dont like something. You dont have to help me out if > you dont want to. But trying to censor me is unethical. Hopefully other > people will have the logic to make decisions for themselves and give me > help on python if they choose to do so. > > I hope my reply does not get censored. I am being reasonable here. And if > you are wondering why I am "paranoid", you would be too if you are dealing > with a server that might host a hot wallet. I dont want my server getting > hacked just because I was too lazy to compile my own code. And it is not > uncommon for binaries of open source projects to be injected with malware. > > > > -- > https://mail.python.org/mailman/listinfo/python-list > From pieter-l at vanoostrum.org Fri Mar 6 15:54:40 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Fri, 06 Mar 2020 15:54:40 -0500 Subject: iterate through an irregular nested list in Python Message-ID: sinndhhu at gmail.com writes: > Hi All, > I am new to python. > I have a irregular nested lists in a list. > Please help me to iterate through each element. > > Thanks much in advance. > > Sample Ex > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > expected output: > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > Use a recursive iterator/generator: It becomes a bit peculiar because you want special treatment for empty lists inside, but otherwise it is quite standard Python: aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] def reclist(aList): for item in aList: if isinstance(item, list): if item == []: yield '' else: yield from reclist(item) else: yield item for i in reclist(aList): print(i, end=',') This gives you an extra comma at the end, unfortunately. But it is the pattern for other types of processing. Or use it like this: print (','.join(str(i) for i in reclist(aList))) -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From grant.b.edwards at gmail.com Thu Mar 5 19:46:26 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Thu, 05 Mar 2020 19:46:26 -0500 Subject: Application setup like windows msi Message-ID: On 2020-03-05, Michael Torrie wrote: > On 3/4/20 4:51 PM, J A wrote: >> I was wondering g if there was a way to distribute an application that took >> advantage of user input like a windows .msi does. On linux of course. > > Several installer frameworks can make interactive installers for Linux. > There's the NullSoft installer and InstallerVICE. And quite a few > commercial packages have rolled their own installers. Although I find > installers of any kind of annoying on Linux and don't seem all that > necessary. I prefer a .tar file and a readme.txt file that says to run setup.py. But then again, I run Gentoo. ;) -- Grant Edwards grant.b.edwards Yow! I guess it was all a at DREAM ... or an episode of gmail.com HAWAII FIVE-O ... From PythonList at DancesWithMice.info Sat Mar 7 11:33:48 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Sat, 07 Mar 2020 11:33:48 -0500 Subject: How to POST html data to be handled by a route endpoint Message-ID: On 7/03/20 2:33 AM, ???-?????? ??? ???????? wrote: > First i must say i use Bottle, but the same may also be the case in Flask too. I ask here and not in sub Bottle because there are only a few people there and i receive no responses. > > Actualy since i started here let me say what i have found. > > Iam just trying to post html form data to the following endpoint. > > @app.route( '/mailform', method=['POST'] ) > IF i try to post the html form data using the the endpoint url way, i get "Method NOT Allowed" error: > >
> > > WHILE if i try the following way, i receive no error. > > ...html...
''' % app.get_url( '/mailform ) > > Can someone explain why?! Please post the full error message and traceback. To clarify: is the error coming from Python or from the web server? -- Regards =dn From drsalists at gmail.com Fri Mar 6 10:00:50 2020 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 06 Mar 2020 10:00:50 -0500 Subject: iterate through an irregular nested list in Python Message-ID: On Fri, Mar 6, 2020 at 6:55 AM Pieter van Oostrum wrote: > sinndhhu at gmail.com writes: > > > Hi All, > > I am new to python. > > I have a irregular nested lists in a list. > > Please help me to iterate through each element. > > > > Thanks much in advance. > > > > Sample Ex > > > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > > > expected output: > > 2,jkj,,,kite,88,ooo,pop,push,pull,hello > > > > Use a recursive iterator/generator: > It becomes a bit peculiar because you want special treatment for empty > lists inside, > but otherwise it is quite standard Python: > > aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] > > def reclist(aList): > for item in aList: > if isinstance(item, list): > if item == []: > yield '' > else: > yield from reclist(item) > else: > yield item > > for i in reclist(aList): > print(i, end=',') > > This gives you an extra comma at the end, unfortunately. > But it is the pattern for other types of processing. > > Or use it like this: > > print (','.join(str(i) for i in reclist(aList))) > If your lists are nested to inconsistent depth, and you're on a modern version of Python (3.3 and up), recursion with yield from (as above) is the way to go. If your lists are nested to a consistent depth (as your example seems to suggest), you can just: for sublist in aList: for element in sublist: yield element If you need inconsistent depth and you're on an old version of python, yield from is unavailable. In that case, it's best to write it out recursively (even though that won't work really), and modify that to be nonrecursive using an explicit stack or stacks. There's an example of this at: http://stromberg.dnsalias.org/svn/treap/trunk/m4_treap.m4 See iterator_macro. Don't let the m4 throw you - it's just a way of deriving pure python and cython from the same file. You can generate the pure python form the .m4 file with simply: m4 -Dpy=1 < m4_treap.m4 > py_treap.py ...if you install an m4 binary. HTH. From =?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs Fri Mar 6 05:33:46 2020 From: =?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs (=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs) Date: Fri, 06 Mar 2020 05:33:46 -0500 Subject: How to POST html data to be handled by a route endpoint Message-ID: First i must say i use Bottle, but the same may also be the case in Flask too. I ask here and not in sub Bottle because there are only a few people there and i receive no responses. Actualy since i started here let me say what i have found. Iam just trying to post html form data to the following endpoint. @app.route( '/mailform', method=['POST'] ) IF i try to post the html form data using the the endpoint url way, i get "Method NOT Allowed" error:
WHILE if i try the following way, i receive no error. ...html...
''' % app.get_url( '/mailform ) Can someone explain why?! From auriocus at gmx.de Thu Mar 5 20:50:40 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Thu, 05 Mar 2020 20:50:40 -0500 Subject: Application setup like windows msi Message-ID: Am 05.03.20 um 02:48 schrieb Michael Torrie: > On 3/4/20 4:51 PM, J A wrote: >> I was wondering g if there was a way to distribute an application that took >> advantage of user input like a windows .msi does. On linux of course. > > Several installer frameworks can make interactive installers for Linux. > There's the NullSoft installer and InstallerVICE. And quite a few > commercial packages have rolled their own installers. Although I find > installers of any kind of annoying on Linux and don't seem all that > necessary. > +1! On Linux, the most reasonable binary distribution is a .tar.bz2 package which extracts a folder with a startup script. This works on every Linux distribution and is one of the most common ways for Firefox etc. Of course, if you can afford to offer several packages, the other recommended way is packages for the system package manager - but this means it is system-dependent - or the newer things like flatpak and snap. However the tarball is the thing that always works, even for me as a user without root access. Christian From sinndhhu at gmail.com Fri Mar 6 04:59:26 2020 From: sinndhhu at gmail.com (sinndhhu) Date: Fri, 06 Mar 2020 04:59:26 -0500 Subject: iterate through an irregular nested list in Python Message-ID: Hi All, I am new to python. I have a irregular nested lists in a list. Please help me to iterate through each element. Thanks much in advance. Sample Ex aList = [[2,'jkj'],[],[],['kite',88,'ooo','pop','push','pull'],['hello']] expected output: 2,jkj,,,kite,88,ooo,pop,push,pull,hello From lee.chiffre at secmail.pro Thu Mar 5 20:49:14 2020 From: lee.chiffre at secmail.pro (Mr. Lee Chiffre) Date: Thu, 05 Mar 2020 20:49:14 -0500 Subject: Python question Message-ID: Thank you Marco for at least taking the time to read my message even if you do not agree with me on things. And no disrespect to you. But I came here for python related questions and help. Not to be called suspicious and untrustworthy only because I am concerned about security of users and for being a advocate of privacy. Then to call for me to be censored is just ludicrous. > People of Python List, I strongly discourage you to support this user. > He is quite suspicious for the following reasons: > > 1. he go so far as he offers money for, IMHO, a trivial task I said I am a python noob. This is why I asked for help. And I see no issue in offering payment for a programming task. > 2. he does not trust binaries from pip. What is the point of open source if you cannot compile from source code? > code. A lack of trust in open source projects that is quite unusual > 3. I don't trust any cryptocurrency. Not unusual. People use open source because they dont trust closed source. Binaries that someone else compiled is not open source. > I believe in privacy, but not in financial privacy. Yes, > cryptocurrencies can be useful for circumvent bans from tyrannic > states. But they can, and _are_ used, primarily to: > - wash dirty money, by criminals and mafias > - evade taxes > - buy highly unethical "products", like weapons... and who know what > other > - finance tyrannies. Roads and cars are used by drug dealers. Stop using roads and cars. Cash is used by criminals. Stop using cash. Internet is used by child abusers. Stop supporting the internet. I am offended that you group me with criminals and baddies because I support technological privacy. > > I do _not_ think that all people that uses cryptocurrencies are > criminals. I had, for example, some co-workers that invested in > BitCoins, only for profit. > > But I do not trust this man, and I hope no one will offer support to > him. By my side, I'll report this discussion to moderators. That is fine if you dont like something. You dont have to help me out if you dont want to. But trying to censor me is unethical. Hopefully other people will have the logic to make decisions for themselves and give me help on python if they choose to do so. I hope my reply does not get censored. I am being reasonable here. And if you are wondering why I am "paranoid", you would be too if you are dealing with a server that might host a hot wallet. I dont want my server getting hacked just because I was too lazy to compile my own code. And it is not uncommon for binaries of open source projects to be injected with malware. From torriem at gmail.com Fri Mar 6 20:06:40 2020 From: torriem at gmail.com (Michael Torrie) Date: Fri, 06 Mar 2020 20:06:40 -0500 Subject: Using zipfile to create a zip file with directories and files inside Message-ID: I am trying to do something very simple but having no success in finding out how to do it. I just want to use the Python zipfile module to create a zip file with a specific directory structure and create and write to files inside those subdirectories (not files already on disk). The documentation talks about writing files from disk, but I'm interested in creating these files from within Python directly in the zip archive. I've read over the docs several times but nothing speaks to this, and none of the examples I've searched for show this either. I thought that in zip files, directories are really just part of the name of the file, and if unless you tell unzip not to, it creates them as files are extracted. So I naively thought I could use the "open" method of zipfile, giving it a relative path describing the relative path and file name that I want to then write bytes to. But seems I am mistaken. Is this a limitation of the zip format that cannot allow that sort of thing? Must I resort to temporary files? Plenty of examples on how to create an archive from existing files and directories on disk of course, which isn't what I want to do. From bernard+work at ei8fdb.org Fri Mar 6 23:23:28 2020 From: bernard+work at ei8fdb.org (Bernard Tyers - Sane UX Design) Date: Fri, 06 Mar 2020 23:23:28 -0500 Subject: pip UX Studies - help improve the usability of pip Message-ID: Hi there, My name is Bernard Tyers. I'm a UX designer and have recently started working on the PSF project to improve the usability of pip, funded by MOSS/CZI. I want to let you know about the pip UX Studies we've started today, and encourage you to sign-up and take part. The pip Team is looking for Python users who use pip to take part in our UX Studies. Your input will have a direct impact on improving pip. We want to speak with as diverse a group as possible. We'd particularly like to speak with people with accessibility needs. You _don't_ have to be a Python expert to take part - I can't stress this enough! You can find out all the details you'll need and find the sign-up link on this blogpost: http://www.ei8fdb.org/thoughts/2020/03/pip-ux-study-recruitment/ If you do have questions I've not answered there, let me know. We'd also appreciate some signal boosting to reach as wide an audience as possible. Please share the blog post with people in different Python using communities. If you're a Twitter/Mastodon user we'd appreciate a signal boost of these also: https://twitter.com/bernardtyers/status/1236039617222230017 https://social.ei8fdb.org/@bernard/103778645553767728 Thank you for your attention! Best wishes, Bernard -- Bernard Tyers, User research & Interaction Design T: @bernardtyers M: @bernard at social.ei8fdb.org PGP Key: keybase.io/ei8fdb I work on User-Centred Design, Open Source Software and Privacy. From souvik.viksou at gmail.com Sat Mar 7 08:41:24 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Sat, 07 Mar 2020 08:41:24 -0500 Subject: Is there something similar to guidechimp in python? Message-ID: This is guidechimp -https://github.com/Labs64/GuideChimp Is there anything similar to this in python? From musbur at posteo.org Sat Mar 7 09:08:58 2020 From: musbur at posteo.org (musbur) Date: Sat, 07 Mar 2020 09:08:58 -0500 Subject: Using zipfile to create a zip file with directories and files Message-ID: On Fri, 6 Mar 2020 20:06:40 -0700 Michael Torrie wrote: > The documentation talks about writing files from > disk, but I'm interested in creating these files from within Python > directly in the zip archive. But you have seen writestr(), haven't you? ZipFile.writestr(zinfo_or_arcname, data, compress_type=None, compresslevel=None) Write a file into the archive. The contents is data, which may be either a str or a bytes instance; > So I naively thought I could use the "open" > method of zipfile, giving it a relative path describing the relative > path and file name that I want to then write bytes to. But seems I am > mistaken. No your're not. writestr() and ZipInfo are your friends, unless I haven't understood what you're trying to do. From vergos.nikolas at gmail.com Sat Mar 7 02:15:36 2020 From: vergos.nikolas at gmail.com (=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?=) Date: Sat, 07 Mar 2020 02:15:36 -0500 Subject: How to POST html data to be handled by a route endpoint References: Message-ID: ???? ??????????????, 7 ?????????-???? 2020 - 12:34:21 ? .??. UTC+2, ?? ?????R???????? DL Neil ? ??????????: > Please post the full error message and traceback. > > To clarify: is the error coming from Python or from the web server? I beleive it comes from the web server. Here it is: Error: 500 Internal Server Error Sorry, the requested URL 'http://superhost.gr/mailform' caused an error: Internal Server Error Exception: TypeError("argument of type 'NoneType' is not iterable",) Traceback: Traceback (most recent call last): File "/home/nikos/wsgi/bottle.py", line 996, in _handle out = route.call(**args) File "/home/nikos/wsgi/bottle.py", line 2007, in wrapper rv = callback(*a, **ka) File "/home/nikos/wsgi/www.py", line 189, in mailform if provider in FROM: TypeError: argument of type 'NoneType' is not iterable I somehow beleive that the following apache conf directives somehow create problem. When superhost.gr/test tries to post html form data to the route endpoint '/mailform' it sends it to superhost.gr/mailform and NOT at superhost.gr/test/mailform as it should have done. They somehow interfere. Here is the processes running in the webserver that somehow interfere. WSGIDaemonProcess test user=nikos group=nikos home=/home/nikos/wsgi WSGIScriptAlias /test /home/nikos/wsgi/test.py process-group=test application-group=%{GLOBAL} WSGIDaemonProcess www user=nikos group=nikos home=/home/nikos/wsgi WSGIScriptAliasMatch / /home/nikos/wsgi/www.py process-group=www application-group=%{GLOBAL} From torriem at gmail.com Sat Mar 7 07:48:48 2020 From: torriem at gmail.com (Michael Torrie) Date: Sat, 07 Mar 2020 07:48:48 -0500 Subject: Using zipfile to create a zip file with directories and files Message-ID: On 3/7/20 1:08 AM, musbur at posteo.org wrote: > On Fri, 6 Mar 2020 20:06:40 -0700 > Michael Torrie wrote: > >> The documentation talks about writing files from >> disk, but I'm interested in creating these files from within Python >> directly in the zip archive. > > But you have seen writestr(), haven't you? Yes, that's what I was using. Turns out I didn't look closely enough at the exception I was getting. What i thought was zipfile complaining about a '/' character was really Python complaining about a bad string formatting string I was using! Thanks for confirming that zipfile indeed should work the way I hoped it wood. I'm in business now. thank you. From vergos.nikolas at gmail.com Sat Mar 7 05:10:36 2020 From: vergos.nikolas at gmail.com (=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?=) Date: Sat, 07 Mar 2020 05:10:36 -0500 Subject: How to POST html data to be handled by a route endpoint References: Message-ID: You will see if you create a route endpoint called 'mailform' within '/' which is an alias of 'www.py' and you also have '/mailform' in 'superhost.gr/test' when the latter tries to post data to '/mailform' instead of sending them to 'superhost.gr/test/' it sends them to '/' which is 'superhost.gr' From vergos.nikolas at gmail.com Sat Mar 7 14:34:21 2020 From: vergos.nikolas at gmail.com (=?UTF-8?B?zp3Or866zr/PgiDOks6tz4HOs86/z4I=?=) Date: Sat, 7 Mar 2020 11:34:21 -0800 (PST) Subject: How to POST html data to be handled by a route endpoint In-Reply-To: References: Message-ID: ?? ???????, 7 ??????? 2020 - 9:00:41 ?.?. UTC+2, ? ??????? DL Neil ??????: > On 7/03/20 2:33 AM, ???-?????? ??? ???????? wrote: > > First i must say i use Bottle, but the same may also be the case in Flask > too. I ask here and not in sub Bottle because there are only a few people there and i receive no responses. > > > > Actualy since i started here let me say what i have found. > > > > Iam just trying to post html form data to the following endpoint. > > > > @app.route( '/mailform', method=['POST'] ) > > IF i try to post the html form data using the the endpoint url way, i get > "Method NOT Allowed" error: > > > >
> > > > > > WHILE if i try the following way, i receive no error. > > > > ...html...
''' % app.get_url( > '/mailform ) > > > > Can someone explain why?! > > > Please post the full error message and traceback. > > To clarify: is the error coming from Python or from the web server? > > -- > Regards =dn Sorry, the requested URL 'http://superhost.gr/mailform' caused an error: Internal Server Error Exception: TypeError("argument of type 'NoneType' is not iterable",) Traceback: Traceback (most recent call last): File "/home/nikos/wsgi/bottle.py", line 996, in _handle out = route.call(**args) File "/home/nikos/wsgi/bottle.py", line 2007, in wrapper rv = callback(*a, **ka) File "/home/nikos/wsgi/www.py", line 189, in mailform if provider in FROM: TypeError: argument of type 'NoneType' is not iterable From Richard at Damon-Family.org Sat Mar 7 14:47:36 2020 From: Richard at Damon-Family.org (Richard Damon) Date: Sat, 7 Mar 2020 14:47:36 -0500 Subject: How to POST html data to be handled by a route endpoint In-Reply-To: References: <1a4558c4-a05d-4e6b-9426-2ddc70398c26@googlegroups.com> <0be67a73-00ea-f33b-b894-14e4411d720a@DancesWithMice.info> Message-ID: <5992a561-54df-2053-9f07-8242c67215a0@Damon-Family.org> On 3/7/20 5:15 AM, ????? ?????? wrote: > When superhost.gr/test tries to post html form data to the route endpoint '/mailform' it sends it to superhost.gr/mailform and NOT at superhost.gr/test/mailform as it should have done. > The HTML path /mailform means server relative path, so the path is relative to the SERVER, not the current page, so it would be superhost.gr/mailform The other format goes through a function which might re-interpret the path and either make it page relative or add in the path of the current page to get to /test/mailform -- Richard Damon From pjvirgo at outlook.com Sat Mar 7 16:23:58 2020 From: pjvirgo at outlook.com (Perri Jones) Date: Sat, 7 Mar 2020 21:23:58 +0000 Subject: The Real-Time Use of Python in Data Science World! In-Reply-To: <158355958156.9300.18008261846550968871@mail.python.org> References: <9f0fc4fa-1336-41c9-ae41-20bee930cb36@googlegroups.com>, <158355958156.9300.18008261846550968871@mail.python.org> Message-ID: Is this training that someone can sign up for, and if so, how do you sign up. ________________________________ From: priyasudha041298 at gmail.com Sent: Saturday, March 7, 2020 12:39 AM To: python-announce-list at python.org Subject: Re: The Real-Time Use of Python in Data Science World! Besant Technologies providing Python Training in Chennai with expert guidance and fully hands-on classes. Python is a high-level programming language sometimes it also denoted as the scripting language as it provides rapid & fast development and easy of use. Our Python Training in Chennai package also includes job placement assistance, which is really a bonus point for students. We also help students in getting a good job by conducting interviews of ours with good IT companies and MNCs too. https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.besanttechnologies.com%2Ftraining-courses%2Fpython-training-institute-in-chennai&data=02%7C01%7C%7Ca4d13696dfe649b76ba308d7c25dd7c2%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637191580609217361&sdata=lRZZiFR6AWxUBu7r90lXNZNlITNSji80S%2Bp%2FVWRWbi8%3D&reserved=0 -- Python-announce-list mailing list -- python-announce-list at python.org To unsubscribe send an email to python-announce-list-leave at python.org https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail.python.org%2Fmailman3%2Flists%2Fpython-announce-list.python.org%2F&data=02%7C01%7C%7Ca4d13696dfe649b76ba308d7c25dd7c2%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637191580609217361&sdata=%2FGx3A6KvX6%2FNRu2mkOwPty9n3Y8Z1tCX0Lmv1Ov1LcI%3D&reserved=0 Support the Python Software Foundation: https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.python.org%2Fpsf%2Fdonations%2F&data=02%7C01%7C%7Ca4d13696dfe649b76ba308d7c25dd7c2%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637191580609217361&sdata=iEYALDe6NXEt%2BzW9g%2BW4zqLQEJq9kxMPXTFl8nyeg3Q%3D&reserved=0 From gheskett at shentel.net Sat Mar 7 17:29:10 2020 From: gheskett at shentel.net (Gene Heskett) Date: Sat, 7 Mar 2020 17:29:10 -0500 Subject: The Real-Time Use of Python in Data Science World! In-Reply-To: References: <9f0fc4fa-1336-41c9-ae41-20bee930cb36@googlegroups.com> <158355958156.9300.18008261846550968871@mail.python.org> Message-ID: <202003071729.10320.gheskett@shentel.net> On Saturday 07 March 2020 16:23:58 Perri Jones wrote: > Is this training that someone can sign up for, and if so, how do you > sign up. This could be legit, but it sure smells like spam to me, so please meet sa-learn spam> > ________________________________ > From: priyasudha041298 at gmail.com > Sent: Saturday, March 7, 2020 12:39 AM > To: python-announce-list at python.org > Subject: Re: The Real-Time Use of Python in Data Science World! > > Besant Technologies providing Python Training in Chennai with expert > guidance and fully hands-on classes. Python is a high-level > programming language sometimes it also denoted as the scripting > language as it provides rapid & fast development and easy of use. Our > Python Training in Chennai package also includes job placement > assistance, which is really a bonus point for students. We also help > students in getting a good job by conducting interviews of ours with > good IT companies and MNCs too. > > https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww. >besanttechnologies.com%2Ftraining-courses%2Fpython-training-institute-i >n-chennai&data=02%7C01%7C%7Ca4d13696dfe649b76ba308d7c25dd7c2%7C84df >9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637191580609217361&sdata=lRZ >ZiFR6AWxUBu7r90lXNZNlITNSji80S%2Bp%2FVWRWbi8%3D&reserved=0 -- > Python-announce-list mailing list -- python-announce-list at python.org > To unsubscribe send an email to python-announce-list-leave at python.org > https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmail >.python.org%2Fmailman3%2Flists%2Fpython-announce-list.python.org%2F& >;data=02%7C01%7C%7Ca4d13696dfe649b76ba308d7c25dd7c2%7C84df9e7fe9f640afb >435aaaaaaaaaaaa%7C1%7C0%7C637191580609217361&sdata=%2FGx3A6KvX6%2FN >Ru2mkOwPty9n3Y8Z1tCX0Lmv1Ov1LcI%3D&reserved=0 > > Support the Python Software Foundation: > > https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.p >ython.org%2Fpsf%2Fdonations%2F&data=02%7C01%7C%7Ca4d13696dfe649b76b >a308d7c25dd7c2%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C63719158060 >9217361&sdata=iEYALDe6NXEt%2BzW9g%2BW4zqLQEJq9kxMPXTFl8nyeg3Q%3D&am >p;reserved=0 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) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From shrinivk at gmail.com Sun Mar 8 06:05:36 2020 From: shrinivk at gmail.com (Shrinivas Kulkarni) Date: Sun, 8 Mar 2020 15:35:36 +0530 Subject: Possible Addition to Python Language: Marked Sub-condition Message-ID: Hello Everyone While writing python code, I frequently come across the need to do certain tasks based on combined conditions. Much of the task for all the sub-conditions are common but some are specific to one or more of these sub-conditions. A simplified example: ########################## Code ########################## if (color == BLUE and count == 20) or (color == RED and count % 5 == 0): rotate_the_wheel() # Common to the two sub-conditions if(color == BLUE and count == 20): # First sub-condition set_signal() if(color == RED and count % 5 == 0): # Second sub-condition clear_signal() proc_post_rotate() # Common to the two sub-conditions I am not sure if there is a better way to do this. If not, maybe there can be an extension to the language, which would allow marking a sub-condition just like we mark a sub-expression in a regular expression. Tentative syntax for this could be ({} marks the sub-condition and \number refers back to it): ########################## Code ########################## if {(color == BLUE and count == 20)} or {(color == RED and count % 5 == 0)}: rotate_the_wheel() if(\1): # First marked condition set_signal() if(\2): # Second marked condition unset_signal() proc_post_rotate() And like sub-expressions, the nesting of marked sub-condions should also be possible: ########################## Code ########################## if {{(color == BLUE and count == 20)} and {value == 20}} or {(color == RED and count % 5 == 0)}: if(\1):# Refers to the entire subcondition {{(color == BLUE and count == 20)} and {value = 20}} proc1() if(\2):# Refers to sub-subcondition {value == 20} This will not only avoid the repetition of sub-conditions, but make code readable since something like \1 will give an immediate indication of a sub-condition that's defined earlier. Please let me know something similar is already implemented. Even otherwise, all your thoughts, inputs and criticism are welcome. Thanks and best regards Shrinivas Kulkarni From mal at europython.eu Sun Mar 8 07:55:19 2020 From: mal at europython.eu (M.-A. Lemburg) Date: Sun, 8 Mar 2020 12:55:19 +0100 Subject: EuroPython 2020: Launching the conference website Message-ID: We are very excited to announce the launch of our website for EuroPython 2020: * EuroPython 2020 Website * https://ep2020.europython.eu/ Our web WG worked hard on putting the finishing touches on the website and many other team members helped update the content. We have ported the accounts from last year to the new website, so you should be able to login with last year?s details. That said, we?d recommend changing your password as best practice. Please note that we have also updated the profile page, so after login you will be redirected to the profile page to make any necessary adjustments. More updates: ------------- - The CFP will launch as planned on Monday, March 9th. - We are also considering to open early bird sales on Wednesday, March 11 at 12:00 CET. However, since we?re still waiting for the VAT ID registration, we won?t be able to produce invoices yet. Those will get delivered later when we have the VAT ID - much like in Edinburgh, where we had similar delays. - Ticket prices are already available on the registration page. Unlike in previous years, we are publishing all prices at once, so that you can get a better overview. - As you probably know, the Corona virus has hit Europe and we are closely monitoring the situation. We will publish separate blog posts on this topic. So far, we are hopeful that the situation will have calmed down by July. - We have prepared the sponsorship packages and will announce these in separate blog post. Early bird sponsors will again receive a 10% discount on the package price. If you?re interested in becoming a sponsor, please contact our sponsor team at sponsoring at europython.eu. Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/post/611955238740557824/europython-2020-launching-the-conference-website Tweet: https://twitter.com/europython/status/1236620559443800066 Enjoy, -- EuroPython 2020 Team https://ep2020.europython.eu/ https://www.europython-society.org/ From p.f.moore at gmail.com Sun Mar 8 11:59:14 2020 From: p.f.moore at gmail.com (Paul Moore) Date: Sun, 8 Mar 2020 15:59:14 +0000 Subject: Possible Addition to Python Language: Marked Sub-condition In-Reply-To: References: Message-ID: On Sun, 8 Mar 2020 at 15:02, Shrinivas Kulkarni wrote: > > Hello Everyone > > While writing python code, I frequently come across the need to do > certain tasks based on combined conditions. > > Much of the task for all the sub-conditions are common but some are > specific to one or more of these sub-conditions. > > A simplified example: > > ########################## Code ########################## > if (color == BLUE and count == 20) or (color == RED and count % 5 == 0): > rotate_the_wheel() # Common to the two sub-conditions > if(color == BLUE and count == 20): # First sub-condition > set_signal() > if(color == RED and count % 5 == 0): # Second sub-condition > clear_signal() > proc_post_rotate() # Common to the two sub-conditions > > I am not sure if there is a better way to do this. If not, maybe there > can be an extension to the language, which would allow marking a > sub-condition just like we mark a sub-expression in a regular > expression. I would have thought that simply naming the sub-conditions would be sufficient. blue_20 = (color == BLUE and count == 20) red_5 = (color == RED and count % 5 == 0) if blue_20 or red_5: rotate_the_wheel() # Common to the two sub-conditions if blue_20: # First sub-condition set_signal() if red_5: # Second sub-condition clear_signal() proc_post_rotate() # Common to the two sub-conditions I don't know how experienced you are with Python programming, but if you had framed your question as "how do I modify this code to avoid repeating the conditions?" you would likely have been given this advice on the python-list mailinglist, or other similar Python programming help resources. Starting with a proposed language change before you've explored the existing options isn't likely to be the best approach (and would likely have meant you could resolve your issue without needing to bring it to python-ideas at all). Paul From python at mrabarnett.plus.com Sun Mar 8 12:07:51 2020 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 8 Mar 2020 16:07:51 +0000 Subject: Possible Addition to Python Language: Marked Sub-condition In-Reply-To: References: Message-ID: On 2020-03-08 10:05, Shrinivas Kulkarni wrote: > Hello Everyone > > While writing python code, I frequently come across the need to do > certain tasks based on combined conditions. > > Much of the task for all the sub-conditions are common but some are > specific to one or more of these sub-conditions. > > A simplified example: > > ########################## Code ########################## > if (color == BLUE and count == 20) or (color == RED and count % 5 == 0): > rotate_the_wheel() # Common to the two sub-conditions > if(color == BLUE and count == 20): # First sub-condition > set_signal() > if(color == RED and count % 5 == 0): # Second sub-condition > clear_signal() > proc_post_rotate() # Common to the two sub-conditions > > I am not sure if there is a better way to do this. If not, maybe there > can be an extension to the language, which would allow marking a > sub-condition just like we mark a sub-expression in a regular > expression. > > Tentative syntax for this could be ({} marks the sub-condition and > \number refers back to it): > > ########################## Code ########################## > if {(color == BLUE and count == 20)} or {(color == RED and count % 5 == 0)}: > rotate_the_wheel() > if(\1): # First marked condition > set_signal() > if(\2): # Second marked condition > unset_signal() > proc_post_rotate() > An expression { ... } is already defined as a set. > And like sub-expressions, the nesting of marked sub-condions should > also be possible: > > ########################## Code ########################## > if {{(color == BLUE and count == 20)} and {value == 20}} or {(color == > RED and count % 5 == 0)}: > if(\1):# Refers to the entire subcondition {{(color == BLUE and > count == 20)} and {value = 20}} > proc1() > if(\2):# Refers to sub-subcondition {value == 20} > > This will not only avoid the repetition of sub-conditions, but make > code readable since something like \1 will give an immediate > indication of a sub-condition that's defined earlier. > > Please let me know something similar is already implemented. > Even otherwise, all your thoughts, inputs and criticism are welcome. > In Python 3.8+ there's the "walrus operator" which lets you assign within an expression: if (first := (color == BLUE and count == 20)) or (second := (color == RED and count % 5 == 0)): rotate_the_wheel() if first: set_signal() if second: unset_signal() proc_post_rotate() However, this has the problem that if the first subexpression is true, the second will not be evaluated, so 'second' would not be set. The simplest and clearest solution is just to write: first = color == BLUE and count == 20 second = color == RED and count % 5 == 0 if first or second: rotate_the_wheel() if first: set_signal() if second: unset_signal() proc_post_rotate() From souvik.viksou at gmail.com Sun Mar 8 13:48:03 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Sun, 8 Mar 2020 23:18:03 +0530 Subject: EuroPython 2020: Launching the conference website In-Reply-To: References: Message-ID: I have a suggestion. It would be better if you could have made a packaging software that could package not only the dependencies but also the python interpreter so that we could just plug and play the application in a computer that does not has a python interpreter pre installed. The installer that would be the final product could also check if there is any pre installed python interpreter so we don't just end up having lots of python interpreters at the same time. Thank you On Sun, 8 Mar, 2020, 8:34 pm M.-A. Lemburg, wrote: > We are very excited to announce the launch of our website for > EuroPython 2020: > > * EuroPython 2020 Website * > > https://ep2020.europython.eu/ > > > Our web WG worked hard on putting the finishing touches on the website > and many other team members helped update the content. > > We have ported the accounts from last year to the new website, so you > should be able to login with last year?s details. That said, we?d > recommend changing your password as best practice. > > Please note that we have also updated the profile page, so after login > you will be redirected to the profile page to make any necessary > adjustments. > > > More updates: > ------------- > > - The CFP will launch as planned on Monday, March 9th. > > - We are also considering to open early bird sales on Wednesday, March > 11 at 12:00 CET. However, since we?re still waiting for the VAT ID > registration, we won?t be able to produce invoices yet. Those will > get delivered later when we have the VAT ID - much like in > Edinburgh, where we had similar delays. > > - Ticket prices are already available on the registration page. Unlike > in previous years, we are publishing all prices at once, so that you > can get a better overview. > > - As you probably know, the Corona virus has hit Europe and we are > closely monitoring the situation. We will publish separate blog > posts on this topic. So far, we are hopeful that the situation will > have calmed down by July. > > - We have prepared the sponsorship packages and will announce these in > separate blog post. Early bird sponsors will again receive a 10% > discount on the package price. If you?re interested in becoming a > sponsor, please contact our sponsor team at > sponsoring at europython.eu. > > > Help spread the word > -------------------- > > Please help us spread this message by sharing it on your social > networks as widely as possible. Thank you ! > > Link to the blog post: > > > https://blog.europython.eu/post/611955238740557824/europython-2020-launching-the-conference-website > > Tweet: > > https://twitter.com/europython/status/1236620559443800066 > > > Enjoy, > -- > EuroPython 2020 Team > https://ep2020.europython.eu/ > https://www.europython-society.org/ > > -- > https://mail.python.org/mailman/listinfo/python-list > From PythonList at DancesWithMice.info Sun Mar 8 15:26:04 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Mon, 9 Mar 2020 08:26:04 +1300 Subject: Possible Addition to Python Language: Marked Sub-condition In-Reply-To: References: Message-ID: <19a72a9a-8f95-bac3-321d-bba63ff7f708@DancesWithMice.info> On 8/03/20 11:05 PM, Shrinivas Kulkarni wrote: > Hello Everyone > > While writing python code, I frequently come across the need to do > certain tasks based on combined conditions. > > Much of the task for all the sub-conditions are common but some are > specific to one or more of these sub-conditions. The specification is incomplete. In a real-time system, one has to decide whether the cascade of decisions is to be taken with a single set of data taken at a single point-in-time (suggestions for which appear in earlier replies), *or* if the nature of the system requires that the values within the sub-conditions might change between the various stages of the program(me). In which case, there would be no alternative to taking multiple samples from the signal-sources, as-and-when required. Either way, Python is capable of handling the situation. -- Regards =dn From PythonList at DancesWithMice.info Sun Mar 8 15:37:26 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Mon, 9 Mar 2020 08:37:26 +1300 Subject: How to POST html data to be handled by a route endpoint In-Reply-To: <5992a561-54df-2053-9f07-8242c67215a0@Damon-Family.org> References: <1a4558c4-a05d-4e6b-9426-2ddc70398c26@googlegroups.com> <0be67a73-00ea-f33b-b894-14e4411d720a@DancesWithMice.info> <5992a561-54df-2053-9f07-8242c67215a0@Damon-Family.org> Message-ID: <25fa810b-b7f1-194a-1ad3-32f1b33e5138@DancesWithMice.info> On 8/03/20 8:47 AM, Richard Damon wrote: > On 3/7/20 5:15 AM, ????? ?????? wrote: >> When superhost.gr/test tries to post html form data to the route endpoint '/mailform' it sends it to superhost.gr/mailform and NOT at superhost.gr/test/mailform as it should have done. >> > The HTML path /mailform means server relative path, so the path is > relative to the SERVER, not the current page, so it would be > superhost.gr/mailform > > The other format goes through a function which might re-interpret the > path and either make it page relative or add in the path of the current > page to get to /test/mailform +1 May I recommend two techniques: 1 before using a URL from Python, check what happens in your favorite web browser (with exactly the same values - not what you might think/expect as an expansion). This helps narrow-down the problem between the two choices (in this case) - the language or the web-server. 2 use your logging system for testing/debugging, ie build-in logging 'early' rather than retro-fitting it to a newly-working system (as seems to be the habit amongst some of my colleagues). Thus, a glance at the log would tell you the *exact* URL that Python has attempted to use - and likely, much more besides... (remember that the logging library has 'levels' of logging, eg DEBUG, built-in and available to you 'for free'; so encoding it 'earlier' rather than 'later' also gives you debug-print-style intelligence for-free!) Remember also, to configure the web server to provide similarly... -- Regards =dn From tjreedy at udel.edu Sun Mar 8 13:03:09 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 8 Mar 2020 13:03:09 -0400 Subject: Possible Addition to Python Language: Marked Sub-condition In-Reply-To: References: Message-ID: On 3/8/2020 12:07 PM, MRAB wrote: > In Python 3.8+ there's the "walrus operator" which lets you assign > within an expression: > > if (first := (color == BLUE and count == 20)) or (second := (color == > RED and count % 5 == 0)): > ??? rotate_the_wheel() > ??? if first: > ??????? set_signal() > ??? if second: > ??????? unset_signal() > ???? proc_post_rotate() > > However, this has the problem that if the first subexpression is true, > the second will not be evaluated, so 'second' would not be set. One can use '|' instead of 'or' to force evaluation of the second. >>> if (first := True) | (second := False): second False -- Terry Jan Reedy From hjp-python at hjp.at Sun Mar 8 18:11:31 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 8 Mar 2020 23:11:31 +0100 Subject: Python question In-Reply-To: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> Message-ID: <20200308221131.GA24980@hjp.at> On 2020-03-05 20:49:14 -0800, Mr. Lee Chiffre wrote: > > 2. he does not trust binaries from pip. > > What is the point of open source if you cannot compile from source code? You can get the source code from pypi. I don't see any option for pip to do that, but you can easily do it manually. If you don't trust the binaries from pypi, don't trust the source code either! Malware has been found on npm, for example. So to be sure there are no backdoors you have to (carefully) read the source of each module you use (which makes the time for downloading them manually trivial). Oh, and you have read "Reflections on Trusting Trust", I presume? > Not unusual. People use open source because they dont trust closed source. > Binaries that someone else compiled is not open source. It's still open source if the source is available (under the usual conditions). Whether you trust somebody else to compile the software is a question of trust, not of openness. Do you trust the person who compiled your compiler? 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 shubhamsachinthakur at gmail.com Mon Mar 9 02:17:24 2020 From: shubhamsachinthakur at gmail.com (sachin thakur) Date: Mon, 9 Mar 2020 11:47:24 +0530 Subject: Please solve this problem Message-ID: From shubhamsachinthakur at gmail.com Mon Mar 9 03:20:23 2020 From: shubhamsachinthakur at gmail.com (sachin thakur) Date: Mon, 9 Mar 2020 12:50:23 +0530 Subject: Please solve this problem In-Reply-To: References: Message-ID: Rply if solved On Mon, 9 Mar, 2020, 11:47 AM sachin thakur, wrote: > From Hilary.Ilsley at jnpgroup.co.uk Mon Mar 9 05:08:24 2020 From: Hilary.Ilsley at jnpgroup.co.uk (Hilary Ilsley) Date: Mon, 9 Mar 2020 09:08:24 +0000 Subject: Python download for windows Message-ID: Hello We have been asked to download python so our daughter can complete her homework, only once we have down loaded it keeps going to "set up" and even after completing "modify" or "repair" it goes back to set up. https://www.python.org/downloads/release/python-382/ -this is what we have downloaded. Any advice? Hilary Ilsley BSc (Jnt Hons) MSc CBiol MSB SiLC Associate (Geo-environmental Scientist) [A close up of a sign Description automatically generated] Brighouse * Chesham * Glasgow * Hartlepool * Leamington Spa * Sheffield Marlborough House, 48 Holly Walk, Leamington Spa, CV32 4XP t: 01926 889955 w: jnpgroup.co.uk [cid:image002.jpg at 01D5F540.BF6B4CD0][cid:image003.png at 01D5F540.BF6B4CD0][cid:image004.png at 01D5F540.BF6B4CD0][twitter] [cid:image006.jpg at 01D5F540.BF6B4CD0] This message, including any attachments, is strictly confidential, protected by law, and is intended solely for the use of the individual or entity to whom it is addressed. If you are not the intended recipient, be advised that you have received this message in error, and that any use, dissemination, forwarding, printing, alteration or copying of this e-mail and any attachments is strictly prohibited and we will not be liable for any direct, special, indirect or consequential loss/damages arising from any action taken or omitted to be taken in reliance on it or any alteration of the contents of this message by you or any third party. If you have received this e-mail in error, please contact the sender immediately. The views expressed in this email are not necessarily the views of JNP Group, its owners or employees and makes no representation or accepts any liability for its accuracy or completeness unless expressly stated to the contrary. We have made every effort to ensure that emails and any attachments generated are free from viruses. However, we cannot accept any responsibility for any viruses which are transmitted. We recommend that you scan all attachments. Use of your personal information: JNP Group takes data protection very seriously and the privacy notice that will apply to our use of your personal information can be found at http://www.jnpgroup.co.uk/wp-content/uploads/2018/06/JNP-Group-Data-Privacy-Notice.pdf From omar.aboumrad at gmail.com Mon Mar 9 05:30:12 2020 From: omar.aboumrad at gmail.com (Omar Abou Mrad) Date: Mon, 9 Mar 2020 11:30:12 +0200 Subject: Please solve this problem In-Reply-To: References: Message-ID: On Mon, Mar 9, 2020 at 11:21 AM sachin thakur wrote: > Rply if solved > > <..snip..> Solved, answer is: From bgailer at gmail.com Mon Mar 9 07:42:53 2020 From: bgailer at gmail.com (Bob Gailer) Date: Mon, 9 Mar 2020 07:42:53 -0400 Subject: Python download for windows In-Reply-To: References: Message-ID: On Mar 9, 2020 5:22 AM, "Hilary Ilsley" wrote: > > Hello > > We have been asked to download python so our daughter can complete her homework, only once we have down loaded it keeps going to "set up" and even after completing "modify" or "repair" it goes back to set up. You're getting that response because you are re-running the installer rather than running python. Take a look at https://docs.python.org/3/tutorial/interpreter.html#invoking-the-interpreter There is a section explicitly for Windows. Whoever asked you to download python has made the incorrect assumption that you could figure out what to do. That's not your fault. You might want to tell them about your experience and ask them for guidance. regarding email list etiquette: note that I have trimmed all the excess from your post and have responded in line rather than what we call Top posting. Please feel free to post here telling us what you've done and what that's gotten you. We are here to help and we are also volunteers which means we help as we can. From nulla.epistola at web.de Mon Mar 9 08:10:25 2020 From: nulla.epistola at web.de (Sibylle Koczian) Date: Mon, 9 Mar 2020 13:10:25 +0100 Subject: Python download for windows In-Reply-To: References: Message-ID: Am 09.03.2020 um 10:08 schrieb Hilary Ilsley: > Hello > > We have been asked to download python so our daughter can complete her homework, only once we have down loaded it keeps going to "set up" and even after completing "modify" or "repair" it goes back to set up. > https://www.python.org/downloads/release/python-382/ -this is what we have downloaded. > > Any advice? > Sorry, no advice, we'd need more information. Main questions: You talk only about downloading - and the link you gave leads to the download page as a whole, so we can't guess the OS you - or your daughter - use. One guess, because that's quite a frequent problem, at least on Windows: did you perhaps try to start the installer a second time instead of Python itself? The symptoms you describe would fit this case. Some possibly helpful links: https://docs.python.org/3/faq/windows.html That's still supposing your daughter uses Windows. If yes, then the first entry might be enough to get her started. https://docs.python.org/3/using/index.html More about installing and using Python on Linux, Windows and Mac. If it's Windows then perhaps the Microsoft Store package might be easier to use? I don't know it myself, but the description looks promising. HTH Sibylle From nulla.epistola at web.de Mon Mar 9 08:10:25 2020 From: nulla.epistola at web.de (Sibylle Koczian) Date: Mon, 9 Mar 2020 13:10:25 +0100 Subject: Python download for windows In-Reply-To: References: Message-ID: Am 09.03.2020 um 10:08 schrieb Hilary Ilsley: > Hello > > We have been asked to download python so our daughter can complete her homework, only once we have down loaded it keeps going to "set up" and even after completing "modify" or "repair" it goes back to set up. > https://www.python.org/downloads/release/python-382/ -this is what we have downloaded. > > Any advice? > Sorry, no advice, we'd need more information. Main questions: You talk only about downloading - and the link you gave leads to the download page as a whole, so we can't guess the OS you - or your daughter - use. One guess, because that's quite a frequent problem, at least on Windows: did you perhaps try to start the installer a second time instead of Python itself? The symptoms you describe would fit this case. Some possibly helpful links: https://docs.python.org/3/faq/windows.html That's still supposing your daughter uses Windows. If yes, then the first entry might be enough to get her started. https://docs.python.org/3/using/index.html More about installing and using Python on Linux, Windows and Mac. If it's Windows then perhaps the Microsoft Store package might be easier to use? I don't know it myself, but the description looks promising. HTH Sibylle From mal at europython.eu Mon Mar 9 08:44:50 2020 From: mal at europython.eu (M.-A. Lemburg) Date: Mon, 9 Mar 2020 13:44:50 +0100 Subject: EuroPython 2020: Call for Proposals now open Message-ID: <0494a2e3-d084-c07d-83d8-b326997d04a3@europython.eu> We have opened the Call for Proposals today. It will be left open for three weeks and then close on: Sunday, March 29 23:59:59 CEST In order to submit a proposal, please log in to the site (or create an account first) and then proceed to the CFP page: * https://ep2020.europython.eu/call-for-proposals/ * We?re looking for proposals on every aspect of Python: all levels of programming from novice to advanced, applications, frameworks, data science, Python projects, internals or topics which you?re excited about, your experiences with Python and its ecosystem, creative or artistic things you?ve done with Python, to name a few. EuroPython is a community conference and we are eager to hear about your use of Python. Since feedback shows that our audience is very interested in advanced topics, we?d appreciate more entries in this category for EuroPython 2020. Please help spread word about Call for Proposals to anyone who might be interested. Thanks. Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/post/612113768932098048/europython-2020-call-for-proposals-now-open Tweet: https://twitter.com/europython/status/1236995749273092102 Enjoy, -- EuroPython 2020 Team https://ep2020.europython.eu/ https://www.europython-society.org/ From bgailer at gmail.com Mon Mar 9 09:21:52 2020 From: bgailer at gmail.com (Bob Gailer) Date: Mon, 9 Mar 2020 09:21:52 -0400 Subject: Python download for windows In-Reply-To: References: Message-ID: :> You talk only about downloading - and the link you gave leads to the download page as a whole, so we can't guess the OS you - or your daughter - use. the subject line explicitly states "download for Windows" Bob Gailer From best_lay at yahoo.com Mon Mar 9 10:16:13 2020 From: best_lay at yahoo.com (Wildman) Date: Mon, 09 Mar 2020 09:16:13 -0500 Subject: Please solve this problem References: Message-ID: On Mon, 09 Mar 2020 11:47:24 +0530, sachin thakur wrote: What is the problem? If you attached a screenshot to your post it was dropped. This is a text only group. Explain the problem or put the screenshot on a cloud site such as Dropbox and post the link. -- GNU/Linux user #557453 The cow died so I don't need your bull! From thardaway1 at gmail.com Mon Mar 9 10:16:55 2020 From: thardaway1 at gmail.com (Tim Ko) Date: Mon, 9 Mar 2020 07:16:55 -0700 (PDT) Subject: Installation of python Message-ID: <07af0aaf-b5d5-49f2-baf0-9ef8a49f4f1f@googlegroups.com> Hello, I am trying to install a custom Python package but ran into an error. The error presumably associated with cython. I tried a different compiler since Intel compiler often crashes when using cython, but couldn't get it working. Attached is the installation error log. I have installed and updated all essential packages such as numpy and scipy. Could someone please give me advice to resolve this issue? Many thanks in advance. Sincerely, TK =================== $ python setup.py build_ext -b PoissonSolver/ running build_ext skipping 'PoissonSolver/MV_2D_cy/matvec2D.c' Cython extension (up-to-date) skipping 'PoissonSolver/MV_1D_cy/matvec1D.c' Cython extension (up-to-date) skipping 'PoissonSolver/PS_3D_cy/ps3d.c' Cython extension (up-to-date) building 'matvec2D' extension icc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include -I/home01/r782a03/.conda/envs/hko_env/include/python3.7m -c PoissonSolver/MV_2D_cy/matvec2D.c -o build/temp.linux-x86_64-3.7/PoissonSolver/MV_2D_cy/matvec2D.o -ffast-math icc: command line warning #10006: ignoring unknown option '-ffast-math' In file included from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h(1830), from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h(12), from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h(4), from PoissonSolver/MV_2D_cy/matvec2D.c(232): /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h(17): warning #1224: #warning directive: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" #warning "Using deprecated NumPy API, disable it with " \ ^ PoissonSolver/MV_2D_cy/matvec2D.c(17500): error: struct "_ts" has no field "exc_type" *type = tstate->exc_type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17501): error: struct "_ts" has no field "exc_value" *value = tstate->exc_value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17502): error: struct "_ts" has no field "exc_traceback" *tb = tstate->exc_traceback; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17514): error: struct "_ts" has no field "exc_type" tmp_type = tstate->exc_type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17515): error: struct "_ts" has no field "exc_value" tmp_value = tstate->exc_value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17516): error: struct "_ts" has no field "exc_traceback" tmp_tb = tstate->exc_traceback; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17517): error: struct "_ts" has no field "exc_type" tstate->exc_type = type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17518): error: struct "_ts" has no field "exc_value" tstate->exc_value = value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17519): error: struct "_ts" has no field "exc_traceback" tstate->exc_traceback = tb; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17562): error: struct "_ts" has no field "exc_type" tmp_type = tstate->exc_type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17563): error: struct "_ts" has no field "exc_value" tmp_value = tstate->exc_value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17564): error: struct "_ts" has no field "exc_traceback" tmp_tb = tstate->exc_traceback; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17565): error: struct "_ts" has no field "exc_type" tstate->exc_type = local_type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17566): error: struct "_ts" has no field "exc_value" tstate->exc_value = local_value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17567): error: struct "_ts" has no field "exc_traceback" tstate->exc_traceback = local_tb; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17589): error: struct "_ts" has no field "exc_type" tmp_type = tstate->exc_type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17590): error: struct "_ts" has no field "exc_value" tmp_value = tstate->exc_value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17591): error: struct "_ts" has no field "exc_traceback" tmp_tb = tstate->exc_traceback; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17592): error: struct "_ts" has no field "exc_type" tstate->exc_type = *type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17593): error: struct "_ts" has no field "exc_value" tstate->exc_value = *value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17594): error: struct "_ts" has no field "exc_traceback" tstate->exc_traceback = *tb; ^ compilation aborted for PoissonSolver/MV_2D_cy/matvec2D.c (code 2) error: command 'icc' failed with exit status 2 =================== From thardaway1 at gmail.com Mon Mar 9 10:18:59 2020 From: thardaway1 at gmail.com (Tim Ko) Date: Mon, 9 Mar 2020 07:18:59 -0700 (PDT) Subject: Error while installing a python code Message-ID: Hello, I am trying to install a custom Python code but ran into an error. The error presumably associated with cython. I tried a different compiler since Intel compiler often crashes when using cython, but couldn't get it working. Attached is the installation error log. I have installed and updated all essential packages such as numpy and scipy. Could someone please give me advice to resolve this issue? Many thanks in advance. Sincerely, TK =================== $ python setup.py build_ext -b PoissonSolver/ running build_ext skipping 'PoissonSolver/MV_2D_cy/matvec2D.c' Cython extension (up-to-date) skipping 'PoissonSolver/MV_1D_cy/matvec1D.c' Cython extension (up-to-date) skipping 'PoissonSolver/PS_3D_cy/ps3d.c' Cython extension (up-to-date) building 'matvec2D' extension icc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include -I/home01/r782a03/.conda/envs/hko_env/include/python3.7m -c PoissonSolver/MV_2D_cy/matvec2D.c -o build/temp.linux-x86_64-3.7/PoissonSolver/MV_2D_cy/matvec2D.o -ffast-math icc: command line warning #10006: ignoring unknown option '-ffast-math' In file included from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h(1830), from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h(12), from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h(4), from PoissonSolver/MV_2D_cy/matvec2D.c(232): /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h(17): warning #1224: #warning directive: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" #warning "Using deprecated NumPy API, disable it with " \ ^ PoissonSolver/MV_2D_cy/matvec2D.c(17500): error: struct "_ts" has no field "exc_type" *type = tstate->exc_type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17501): error: struct "_ts" has no field "exc_value" *value = tstate->exc_value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17502): error: struct "_ts" has no field "exc_traceback" *tb = tstate->exc_traceback; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17514): error: struct "_ts" has no field "exc_type" tmp_type = tstate->exc_type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17515): error: struct "_ts" has no field "exc_value" tmp_value = tstate->exc_value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17516): error: struct "_ts" has no field "exc_traceback" tmp_tb = tstate->exc_traceback; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17517): error: struct "_ts" has no field "exc_type" tstate->exc_type = type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17518): error: struct "_ts" has no field "exc_value" tstate->exc_value = value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17519): error: struct "_ts" has no field "exc_traceback" tstate->exc_traceback = tb; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17562): error: struct "_ts" has no field "exc_type" tmp_type = tstate->exc_type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17563): error: struct "_ts" has no field "exc_value" tmp_value = tstate->exc_value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17564): error: struct "_ts" has no field "exc_traceback" tmp_tb = tstate->exc_traceback; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17565): error: struct "_ts" has no field "exc_type" tstate->exc_type = local_type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17566): error: struct "_ts" has no field "exc_value" tstate->exc_value = local_value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17567): error: struct "_ts" has no field "exc_traceback" tstate->exc_traceback = local_tb; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17589): error: struct "_ts" has no field "exc_type" tmp_type = tstate->exc_type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17590): error: struct "_ts" has no field "exc_value" tmp_value = tstate->exc_value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17591): error: struct "_ts" has no field "exc_traceback" tmp_tb = tstate->exc_traceback; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17592): error: struct "_ts" has no field "exc_type" tstate->exc_type = *type; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17593): error: struct "_ts" has no field "exc_value" tstate->exc_value = *value; ^ PoissonSolver/MV_2D_cy/matvec2D.c(17594): error: struct "_ts" has no field "exc_traceback" tstate->exc_traceback = *tb; ^ compilation aborted for PoissonSolver/MV_2D_cy/matvec2D.c (code 2) error: command 'icc' failed with exit status 2 =================== From ikorot01 at gmail.com Mon Mar 9 10:31:59 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Mon, 9 Mar 2020 09:31:59 -0500 Subject: Please solve this problem In-Reply-To: References: Message-ID: Hi, On Mon, Mar 9, 2020 at 9:22 AM Wildman via Python-list wrote: > > On Mon, 09 Mar 2020 11:47:24 +0530, sachin thakur wrote: > > What is the problem? If you attached a screenshot to your post > it was dropped. This is a text only group. Explain the problem > or put the screenshot on a cloud site such as Dropbox and post > the link. It was a problem and it was solved. Check the second or third e-mail in the thread. Thank you. > > -- > GNU/Linux user #557453 > The cow died so I don't need your bull! > -- > https://mail.python.org/mailman/listinfo/python-list From p.f.moore at gmail.com Mon Mar 9 11:06:10 2020 From: p.f.moore at gmail.com (Paul Moore) Date: Mon, 9 Mar 2020 15:06:10 +0000 Subject: pip UX Studies - help improve the usability of pip In-Reply-To: References: Message-ID: We've had some questions as to whether this survey is legitimate. I can confirm it is (speaking as a pip core developer). The link to a page describing this work is https://pyfound.blogspot.com/2019/12/moss-czi-support-pip.html, if anyone wants to find out more. Paul Moore On Sat, 7 Mar 2020 at 01:49, Bernard Tyers - Sane UX Design wrote: > > Hi there, > > My name is Bernard Tyers. I'm a UX designer and have recently started > working on the PSF project to improve the usability of pip, funded by > MOSS/CZI. > > I want to let you know about the pip UX Studies we've started today, and > encourage you to sign-up and take part. > > The pip Team is looking for Python users who use pip to take part in our > UX Studies. Your input will have a direct impact on improving pip. > > We want to speak with as diverse a group as possible. We'd particularly > like to speak with people with accessibility needs. > > You _don't_ have to be a Python expert to take part - I can't stress > this enough! > > You can find out all the details you'll need and find the sign-up link > on this blogpost: > > http://www.ei8fdb.org/thoughts/2020/03/pip-ux-study-recruitment/ > > If you do have questions I've not answered there, let me know. > > We'd also appreciate some signal boosting to reach as wide an audience > as possible. Please share the blog post with people in different Python > using communities. > > If you're a Twitter/Mastodon user we'd appreciate a signal boost of > these also: > > https://twitter.com/bernardtyers/status/1236039617222230017 > https://social.ei8fdb.org/@bernard/103778645553767728 > > > Thank you for your attention! > > Best wishes, > > Bernard > -- > > Bernard Tyers, User research & Interaction Design > > T: @bernardtyers > M: @bernard at social.ei8fdb.org > PGP Key: keybase.io/ei8fdb > > > I work on User-Centred Design, Open Source Software and Privacy. > -- > https://mail.python.org/mailman/listinfo/python-list From souvik.viksou at gmail.com Mon Mar 9 12:24:35 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Mon, 9 Mar 2020 21:54:35 +0530 Subject: Error while installing a python code In-Reply-To: References: Message-ID: I dont know if this will work. But still something is better than nothing. https://stackoverflow.com/questions/11094718/error-command-gcc-failed-with-exit-status-1-while-installing-eventlet I am not a "spoofer" in case you get any warning. On Mon, Mar 9, 2020, 7:54 PM Tim Ko wrote: > Hello, > > I am trying to install a custom Python code but ran into an error. The > error presumably associated with cython. I tried a different compiler since > Intel compiler often crashes when using cython, but couldn't get it working. > > Attached is the installation error log. I have installed and updated all > essential packages such as numpy and scipy. Could someone please give me > advice to resolve this issue? Many thanks in advance. > > Sincerely, > TK > > > =================== > $ python setup.py build_ext -b PoissonSolver/ > running build_ext > skipping 'PoissonSolver/MV_2D_cy/matvec2D.c' Cython extension (up-to-date) > skipping 'PoissonSolver/MV_1D_cy/matvec1D.c' Cython extension (up-to-date) > skipping 'PoissonSolver/PS_3D_cy/ps3d.c' Cython extension (up-to-date) > building 'matvec2D' extension > icc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC > -I/home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include > -I/home01/r782a03/.conda/envs/hko_env/include/python3.7m -c > PoissonSolver/MV_2D_cy/matvec2D.c -o > build/temp.linux-x86_64-3.7/PoissonSolver/MV_2D_cy/matvec2D.o -ffast-math > icc: command line warning #10006: ignoring unknown option '-ffast-math' > In file included from > /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h(1830), > from > /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h(12), > from > /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h(4), > from PoissonSolver/MV_2D_cy/matvec2D.c(232): > /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h(17): > warning #1224: #warning directive: "Using deprecated NumPy API, disable it > with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" > #warning "Using deprecated NumPy API, disable it with " \ > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17500): error: struct "_ts" has no field > "exc_type" > *type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17501): error: struct "_ts" has no field > "exc_value" > *value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17502): error: struct "_ts" has no field > "exc_traceback" > *tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17514): error: struct "_ts" has no field > "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17515): error: struct "_ts" has no field > "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17516): error: struct "_ts" has no field > "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17517): error: struct "_ts" has no field > "exc_type" > tstate->exc_type = type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17518): error: struct "_ts" has no field > "exc_value" > tstate->exc_value = value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17519): error: struct "_ts" has no field > "exc_traceback" > tstate->exc_traceback = tb; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17562): error: struct "_ts" has no field > "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17563): error: struct "_ts" has no field > "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17564): error: struct "_ts" has no field > "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17565): error: struct "_ts" has no field > "exc_type" > tstate->exc_type = local_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17566): error: struct "_ts" has no field > "exc_value" > tstate->exc_value = local_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17567): error: struct "_ts" has no field > "exc_traceback" > tstate->exc_traceback = local_tb; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17589): error: struct "_ts" has no field > "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17590): error: struct "_ts" has no field > "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17591): error: struct "_ts" has no field > "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17592): error: struct "_ts" has no field > "exc_type" > tstate->exc_type = *type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17593): error: struct "_ts" has no field > "exc_value" > tstate->exc_value = *value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17594): error: struct "_ts" has no field > "exc_traceback" > tstate->exc_traceback = *tb; > ^ > > compilation aborted for PoissonSolver/MV_2D_cy/matvec2D.c (code 2) > error: command 'icc' failed with exit status 2 > =================== > -- > https://mail.python.org/mailman/listinfo/python-list > From miked at dewhirst.com.au Mon Mar 9 06:16:33 2020 From: miked at dewhirst.com.au (Mike Dewhirst) Date: Mon, 09 Mar 2020 21:16:33 +1100 Subject: Python download for windows In-Reply-To: Message-ID: <48bYzh4wW6zpFVS@mail.python.org> HilaryPython isn't an ordinary program as understood by (most) Windows users.It needs a command-prompt in which to run interactively. In other words, after successful installation, open a command prompt (aka DOS prompt) and type "python". It should open, announce itself and display its characteristic prompt >>>Your daughter will write programs in files with names. If a file has an extension .py and it is double-clicked (when seen in its directory/folder in Windows explorer) it will be executed by Windows using the installed Python. You don't have to worry. That is your daughter's problem.You really should adjust Windows explorer so it doesn't hide file extensions.?Hope this helpsCheersMike -------- Original message --------From: Hilary Ilsley Date: 9/3/20 20:08 (GMT+10:00) To: python-list at python.org Subject: Python download for windows HelloWe have been asked to download python so our daughter can complete her homework, only once we have down loaded it keeps going to "set up" and even after completing "modify" or "repair" it goes back to set up.https://www.python.org/downloads/release/python-382/ -this is what we have downloaded.Any advice?Hilary IlsleyBSc (Jnt Hons) MSc CBiol MSB SiLCAssociate (Geo-environmental Scientist)[A close up of a sign? Description automatically generated]Brighouse * Chesham * Glasgow * Hartlepool * Leamington Spa * SheffieldMarlborough House, 48 Holly Walk, Leamington Spa, CV32 4XPt: 01926 889955? w: jnpgroup.co.uk[cid:image002.jpg at 01D5F540.BF6B4CD0][cid:image003.png at 01D5F540.BF6B4CD0][cid:image004.png at 01D5F540.BF6B4CD0][twitter]?? [cid:image006.jpg at 01D5F540.BF6B4CD0] This message, including any attachments, is strictly confidential, protected by law, and is intended solely for the use of the individual or entity to whom it is addressed. If you are not the intended recipient, be advised that you have received this message in error, and that any use, dissemination, forwarding, printing, alteration or copying of this e-mail and any attachments is strictly prohibited and we will not be liable for any direct, special, indirect or consequential loss/damages arising from any action taken or omitted to be taken in reliance on it or any alteration of the contents of this message by you or any third party. If you have received this e-mail in error, please contact the sender immediately. The views expressed in this email are not necessarily the views of JNP Group, its owners or employees and makes no representation or accepts any liability for its accuracy or completeness unless expressly stated to the contrary.We have made every effort to ensure that emails and any attachments generated are free from viruses. However, we cannot accept any responsibility for any viruses which are transmitted. We recommend that you scan all attachments.Use of your personal information: JNP Group takes data protection very seriously and the privacy notice that will apply to our use of your personal information can be found at http://www.jnpgroup.co.uk/wp-content/uploads/2018/06/JNP-Group-Data-Privacy-Notice.pdf-- https://mail.python.org/mailman/listinfo/python-list From David.Raymond at tomtom.com Mon Mar 9 12:50:00 2020 From: David.Raymond at tomtom.com (David Raymond) Date: Mon, 9 Mar 2020 16:50:00 +0000 Subject: Please solve this problem In-Reply-To: References: Message-ID: > It was a problem and it was solved. > Check the second or third e-mail in the thread. > > Thank you. The first email was blank, The second email was from the same person and just said "Rply if solved" The third was a sarcastic reply to the blank emails with just: "Solved, answer is:" The fourth was Wildman trying to helpfully let them know nothing came through. And the fifth was you saying there was both a problem and a solution. So where is either the problem or solution you speak of? From mertz at gnosis.cx Mon Mar 9 10:16:12 2020 From: mertz at gnosis.cx (David Mertz) Date: Mon, 9 Mar 2020 10:16:12 -0400 Subject: [Python-ideas] Re: Possible Addition to Python Language: Marked Sub-condition In-Reply-To: References: Message-ID: This isn't a terrible use of the walrus operator either. if blue_20 := (color==BLUE and count==20) or red_5 := (color==RED and count%5==0) rotate_the_wheel() # Common to the two sub-conditions if blue_20: # First sub-condition set_signal() if red_5: # Second sub-condition clear_signal() proc_post_rotate() # Common to the two sub-conditions On Sun, Mar 8, 2020 at 12:02 PM Paul Moore wrote: > On Sun, 8 Mar 2020 at 15:02, Shrinivas Kulkarni > wrote: > > > > Hello Everyone > > > > While writing python code, I frequently come across the need to do > > certain tasks based on combined conditions. > > > > Much of the task for all the sub-conditions are common but some are > > specific to one or more of these sub-conditions. > > > > A simplified example: > > > > ########################## Code ########################## > > if (color == BLUE and count == 20) or (color == RED and count % 5 == 0): > > rotate_the_wheel() # Common to the two sub-conditions > > if(color == BLUE and count == 20): # First sub-condition > > set_signal() > > if(color == RED and count % 5 == 0): # Second sub-condition > > clear_signal() > > proc_post_rotate() # Common to the two sub-conditions > > > > I am not sure if there is a better way to do this. If not, maybe there > > can be an extension to the language, which would allow marking a > > sub-condition just like we mark a sub-expression in a regular > > expression. > > I would have thought that simply naming the sub-conditions would be > sufficient. > > blue_20 = (color == BLUE and count == 20) > red_5 = (color == RED and count % 5 == 0) > if blue_20 or red_5: > rotate_the_wheel() # Common to the two sub-conditions > if blue_20: # First sub-condition > set_signal() > if red_5: # Second sub-condition > clear_signal() > proc_post_rotate() # Common to the two sub-conditions > > I don't know how experienced you are with Python programming, but if > you had framed your question as "how do I modify this code to avoid > repeating the conditions?" you would likely have been given this > advice on the python-list mailinglist, or other similar Python > programming help resources. > > Starting with a proposed language change before you've explored the > existing options isn't likely to be the best approach (and would > likely have meant you could resolve your issue without needing to > bring it to python-ideas at all). > > Paul > _______________________________________________ > Python-ideas mailing list -- python-ideas at python.org > To unsubscribe send an email to python-ideas-leave at python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas at python.org/message/3M2BOILT7FBGGJBFECZZKDSTHRKDANCA/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th. From dieter at handshake.de Mon Mar 9 13:22:50 2020 From: dieter at handshake.de (Dieter Maurer) Date: Mon, 9 Mar 2020 18:22:50 +0100 Subject: Error while installing a python code In-Reply-To: References: Message-ID: <24166.31594.621959.195544@ixdm.fritz.box> Tim Ko wrote at 2020-3-9 07:18 -0700: >I am trying to install a custom Python code but ran into an error. The error presumably associated with cython. I tried a different compiler since Intel compiler often crashes when using cython, but couldn't get it working. Almost surely, the compiler is not to blame. >Attached is the installation error log. I have installed and updated all essential packages such as numpy and scipy. Could someone please give me advice to resolve this issue? Many thanks in advance. > >Sincerely, >TK > > >=================== >$ python setup.py build_ext -b PoissonSolver/ > ... >skipping 'PoissonSolver/PS_3D_cy/ps3d.c' Cython extension (up-to-date) >building 'matvec2D' extension >icc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include -I/home01/r782a03/.conda/envs/hko_env/include/python3.7m -c PoissonSolver/MV_2D_cy/matvec2D.c -o build/temp.linux-x86_64-3.7/PoissonSolver/MV_2D_cy/matvec2D.o -ffast-math > ... >PoissonSolver/MV_2D_cy/matvec2D.c(17500): error: struct "_ts" has no field "exc_type" > *type = tstate->exc_type; Errors like this often indicate some version conflict. The "matvec2D" source obviously expects "_ts" to have a field "exc_type" but the compiler knows nothing about it. I know at least 2 reasons for such a situation: * the source expects a different (newer or older) version of a dependency * the available headers (for a dependency) are out of date. I have also seen similar errors in a case, when "cython" was not installed. In this case, the distribution came with pre-"cythonized" C sources, inadequate for my system. Installing "cython" solved this problem. You might face a similar situation: while "cython" is (likely) installed, the C source might wrongly seem up-to-date. You could try to delete it and retry. From ikorot01 at gmail.com Mon Mar 9 13:59:59 2020 From: ikorot01 at gmail.com (Igor Korot) Date: Mon, 9 Mar 2020 12:59:59 -0500 Subject: Please solve this problem In-Reply-To: References: Message-ID: Hi, On Mon, Mar 9, 2020 at 11:56 AM David Raymond wrote: > > > It was a problem and it was solved. > > Check the second or third e-mail in the thread. > > > > Thank you. > > The first email was blank, > > The second email was from the same person and just said "Rply if solved" > > The third was a sarcastic reply to the blank emails with just: "Solved, answer is:" I was talking about this one. And just bcause I didn't put a smiley, doesn't mean it is not sarcastic either. ;-) Thank you. > > The fourth was Wildman trying to helpfully let them know nothing came through. > > And the fifth was you saying there was both a problem and a solution. > > So where is either the problem or solution you speak of? > -- > https://mail.python.org/mailman/listinfo/python-list From grant.b.edwards at gmail.com Mon Mar 9 14:09:37 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Mon, 9 Mar 2020 18:09:37 -0000 (UTC) Subject: Please solve this problem References: Message-ID: On 2020-03-09, David Raymond wrote: >> It was a problem and it was solved. >> Check the second or third e-mail in the thread. >> >> Thank you. > > The first email was blank, > > The second email was from the same person and just said "Rply if solved" > > The third was a sarcastic reply to the blank emails with just: "Solved, answer is:" > > The fourth was Wildman trying to helpfully let them know nothing came through. > > And the fifth was you saying there was both a problem and a solution. It's always September _somewhere_. -- Grant Edwards grant.b.edwards Yow! I'm GLAD I at remembered to XEROX all gmail.com my UNDERSHIRTS!! From dieter at handshake.de Mon Mar 9 14:47:46 2020 From: dieter at handshake.de (Dieter Maurer) Date: Mon, 9 Mar 2020 19:47:46 +0100 Subject: Error while installing a python code In-Reply-To: References: Message-ID: <24166.36690.272996.504440@ixdm.fritz.box> Tim Ko wrote at 2020-3-9 07:18 -0700: >I am trying to install a custom Python code but ran into an error. The error presumably associated with cython. I tried a different compiler since Intel compiler often crashes when using cython, but couldn't get it working. Almost surely, the compiler is not to blame. >Attached is the installation error log. I have installed and updated all essential packages such as numpy and scipy. Could someone please give me advice to resolve this issue? Many thanks in advance. > >Sincerely, >TK > > >=================== >$ python setup.py build_ext -b PoissonSolver/ > ... >skipping 'PoissonSolver/PS_3D_cy/ps3d.c' Cython extension (up-to-date) >building 'matvec2D' extension >icc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include -I/home01/r782a03/.conda/envs/hko_env/include/python3.7m -c PoissonSolver/MV_2D_cy/matvec2D.c -o build/temp.linux-x86_64-3.7/PoissonSolver/MV_2D_cy/matvec2D.o -ffast-math > ... >PoissonSolver/MV_2D_cy/matvec2D.c(17500): error: struct "_ts" has no field "exc_type" > *type = tstate->exc_type; Errors like this often indicate some version conflict. The "matvec2D" source obviously expects "_ts" to have a field "exc_type" but the compiler knows nothing about it. I know at least 2 reasons for such a situation: * the source expects a different (newer or older) version of a dependency * the available headers (for a dependency) are out of date. I have also seen similar errors in a case, when "cython" was not installed. In this case, the distribution came with pre-"cythonized" C sources, inadequate for my system. Installing "cython" solved this problem. You might face a similar situation: while "cython" is (likely) installed, the C source might wrongly seem up-to-date. You could try to delete it and retry. From tjreedy at udel.edu Mon Mar 9 15:06:01 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 9 Mar 2020 15:06:01 -0400 Subject: Python download for windows In-Reply-To: <48bYzh4wW6zpFVS@mail.python.org> References: <48bYzh4wW6zpFVS@mail.python.org> Message-ID: On 3/9/2020 6:16 AM, Mike Dewhirst wrote: > Python isn't an ordinary program as understood by (most) Windows users. > It needs a command-prompt in which to run interactively. Or, one can click the lower left Windows Start icon, find and click 'Python 3.8' (for instance) under 'P', and select either 'IDLE (Python 3.8)', which I recommend for beginners*, or 'Python 3.8'. Still, one should eventually learn to use Command-Prompt, but some schools do not teach it and one can work for years without it. * On the IDLE menu, select Help and IDLE Help for the doc. -- Terry Jan Reedy From barry at barrys-emacs.org Mon Mar 9 15:10:40 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Mon, 9 Mar 2020 19:10:40 +0000 Subject: Error while installing a python code In-Reply-To: References: Message-ID: > On 9 Mar 2020, at 14:18, Tim Ko wrote: > > Hello, > > I am trying to install a custom Python code but ran into an error. The error presumably associated with cython. I tried a different compiler since Intel compiler often crashes when using cython, but couldn't get it working. > > Attached is the installation error log. I have installed and updated all essential packages such as numpy and scipy. Could someone please give me advice to resolve this issue? Many thanks in advance. > > Sincerely, > TK My guess is that this is code that only supports python 2. Check with the author that python 3 is supported. Barry > > > =================== > $ python setup.py build_ext -b PoissonSolver/ > running build_ext > skipping 'PoissonSolver/MV_2D_cy/matvec2D.c' Cython extension (up-to-date) > skipping 'PoissonSolver/MV_1D_cy/matvec1D.c' Cython extension (up-to-date) > skipping 'PoissonSolver/PS_3D_cy/ps3d.c' Cython extension (up-to-date) > building 'matvec2D' extension > icc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include -I/home01/r782a03/.conda/envs/hko_env/include/python3.7m -c PoissonSolver/MV_2D_cy/matvec2D.c -o build/temp.linux-x86_64-3.7/PoissonSolver/MV_2D_cy/matvec2D.o -ffast-math > icc: command line warning #10006: ignoring unknown option '-ffast-math' > In file included from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h(1830), > from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h(12), > from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h(4), > from PoissonSolver/MV_2D_cy/matvec2D.c(232): > /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h(17): warning #1224: #warning directive: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" > #warning "Using deprecated NumPy API, disable it with " \ > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17500): error: struct "_ts" has no field "exc_type" > *type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17501): error: struct "_ts" has no field "exc_value" > *value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17502): error: struct "_ts" has no field "exc_traceback" > *tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17514): error: struct "_ts" has no field "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17515): error: struct "_ts" has no field "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17516): error: struct "_ts" has no field "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17517): error: struct "_ts" has no field "exc_type" > tstate->exc_type = type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17518): error: struct "_ts" has no field "exc_value" > tstate->exc_value = value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17519): error: struct "_ts" has no field "exc_traceback" > tstate->exc_traceback = tb; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17562): error: struct "_ts" has no field "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17563): error: struct "_ts" has no field "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17564): error: struct "_ts" has no field "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17565): error: struct "_ts" has no field "exc_type" > tstate->exc_type = local_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17566): error: struct "_ts" has no field "exc_value" > tstate->exc_value = local_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17567): error: struct "_ts" has no field "exc_traceback" > tstate->exc_traceback = local_tb; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17589): error: struct "_ts" has no field "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17590): error: struct "_ts" has no field "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17591): error: struct "_ts" has no field "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17592): error: struct "_ts" has no field "exc_type" > tstate->exc_type = *type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17593): error: struct "_ts" has no field "exc_value" > tstate->exc_value = *value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17594): error: struct "_ts" has no field "exc_traceback" > tstate->exc_traceback = *tb; > ^ > > compilation aborted for PoissonSolver/MV_2D_cy/matvec2D.c (code 2) > error: command 'icc' failed with exit status 2 > =================== > -- > https://mail.python.org/mailman/listinfo/python-list > From adam.preble at gmail.com Mon Mar 9 20:19:20 2020 From: adam.preble at gmail.com (Adam Preble) Date: Mon, 9 Mar 2020 17:19:20 -0700 (PDT) Subject: How does the super type present itself and do lookups? In-Reply-To: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com> References: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com> Message-ID: <094a7298-a4d3-4ead-8ce6-bc209da8603e@googlegroups.com> On Wednesday, March 4, 2020 at 11:13:20 AM UTC-6, Adam Preble wrote: > Stuff I'm speculating that the stuff I don't see when poking are reserved slots. I figured out how much of a thing that is when I was digging around for how classes know how to construct themselves. I managed to figure out __call__ is like that too. So I guess it's something that doesn't readily reveal itself when asked but is there if you try to use it. (or something) From yon.goldschmidt at gmail.com Mon Mar 9 18:53:02 2020 From: yon.goldschmidt at gmail.com (Yonatan Goldschmidt) Date: Tue, 10 Mar 2020 00:53:02 +0200 Subject: Lock acquisition by the same thread - deadlock protection Message-ID: <20200309225302.GA22040@jong.localdomain> I recently debugged a program hang, eventually finding out it's a deadlock of a single thread, resulting from my usage of 2 libraries. One of them - call it library A - is reentrant & runs code in GC finalizers, while the other - library B - is not reentrant at all. Library B held one of its `threading.Lock` locks, and during this period, GC was invoked, running finalizers of library A which call back into library B, now attempting to take the lock again, locking the thread forever. Considering how relatively common this scenario might be (Python, by design, can preempt any user code to run some other user code, due to GC finalizers), I was surprised Python code is not protected from this simple type of deadlock. It makes sense that while `threading.RLock` allows for recursive locking, `threading.Lock` will prevent it - raising an exception if you attempt it. I might be missing something, but why isn't it the status? Why taking a `threading.Lock` twice from the same thread just hangs, instead of raising a friendly exception? I ran a quick search in bpo but found nothing about this topic. I also tried to search this mailing list but couldn't find how to, so I grepped a few random archives but found nothing about it. Would be happy if anyone could shed some light on it... Thanks, Yonatan From souvik.viksou at gmail.com Mon Mar 9 22:30:07 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Tue, 10 Mar 2020 08:00:07 +0530 Subject: Lock acquisition by the same thread - deadlock protection In-Reply-To: <20200309225302.GA22040@jong.localdomain> References: <20200309225302.GA22040@jong.localdomain> Message-ID: This should be what you need. https://python-reference.readthedocs.io/en/latest/docs/functions/super.html On Tue, 10 Mar, 2020, 7:02 am Yonatan Goldschmidt, < yon.goldschmidt at gmail.com> wrote: > I recently debugged a program hang, eventually finding out it's a deadlock > of a single thread, > resulting from my usage of 2 libraries. One of them - call it library A - > is reentrant & runs code in > GC finalizers, while the other - library B - is not reentrant at all. > Library B held one of its `threading.Lock` locks, and during this period, > GC was invoked, running > finalizers of library A which call back into library B, now attempting to > take the lock again, > locking the thread forever. > > Considering how relatively common this scenario might be (Python, by > design, can preempt any user code > to run some other user code, due to GC finalizers), I was surprised Python > code is not protected > from this simple type of deadlock. It makes sense that while > `threading.RLock` allows for recursive > locking, `threading.Lock` will prevent it - raising an exception if you > attempt it. > > I might be missing something, but why isn't it the status? Why taking a > `threading.Lock` twice from > the same thread just hangs, instead of raising a friendly exception? > I ran a quick search in bpo but found nothing about this topic. I also > tried to > search this mailing list but couldn't find how to, so I grepped a few > random archives > but found nothing about it. > > Would be happy if anyone could shed some light on it... > > Thanks, > Yonatan > -- > https://mail.python.org/mailman/listinfo/python-list > From souvik.viksou at gmail.com Mon Mar 9 22:30:33 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Tue, 10 Mar 2020 08:00:33 +0530 Subject: Lock acquisition by the same thread - deadlock protection In-Reply-To: References: <20200309225302.GA22040@jong.localdomain> Message-ID: Soorrrryyy it was not meant to you On Tue, 10 Mar, 2020, 8:00 am Souvik Dutta, wrote: > This should be what you need. > https://python-reference.readthedocs.io/en/latest/docs/functions/super.html > > On Tue, 10 Mar, 2020, 7:02 am Yonatan Goldschmidt, < > yon.goldschmidt at gmail.com> wrote: > >> I recently debugged a program hang, eventually finding out it's a >> deadlock of a single thread, >> resulting from my usage of 2 libraries. One of them - call it library A - >> is reentrant & runs code in >> GC finalizers, while the other - library B - is not reentrant at all. >> Library B held one of its `threading.Lock` locks, and during this period, >> GC was invoked, running >> finalizers of library A which call back into library B, now attempting to >> take the lock again, >> locking the thread forever. >> >> Considering how relatively common this scenario might be (Python, by >> design, can preempt any user code >> to run some other user code, due to GC finalizers), I was surprised >> Python code is not protected >> from this simple type of deadlock. It makes sense that while >> `threading.RLock` allows for recursive >> locking, `threading.Lock` will prevent it - raising an exception if you >> attempt it. >> >> I might be missing something, but why isn't it the status? Why taking a >> `threading.Lock` twice from >> the same thread just hangs, instead of raising a friendly exception? >> I ran a quick search in bpo but found nothing about this topic. I also >> tried to >> search this mailing list but couldn't find how to, so I grepped a few >> random archives >> but found nothing about it. >> >> Would be happy if anyone could shed some light on it... >> >> Thanks, >> Yonatan >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From souvik.viksou at gmail.com Mon Mar 9 22:31:20 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Tue, 10 Mar 2020 08:01:20 +0530 Subject: How does the super type present itself and do lookups? In-Reply-To: <094a7298-a4d3-4ead-8ce6-bc209da8603e@googlegroups.com> References: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com> <094a7298-a4d3-4ead-8ce6-bc209da8603e@googlegroups.com> Message-ID: This should be what you are looking for. https://python-reference.readthedocs.io/en/latest/docs/functions/super.html On Tue, 10 Mar, 2020, 5:50 am Adam Preble, wrote: > On Wednesday, March 4, 2020 at 11:13:20 AM UTC-6, Adam Preble wrote: > > Stuff > > I'm speculating that the stuff I don't see when poking are reserved slots. > I figured out how much of a thing that is when I was digging around for how > classes know how to construct themselves. I managed to figure out __call__ > is like that too. So I guess it's something that doesn't readily reveal > itself when asked but is there if you try to use it. > > (or something) > -- > https://mail.python.org/mailman/listinfo/python-list > From adam.preble at gmail.com Tue Mar 10 01:12:17 2020 From: adam.preble at gmail.com (Adam Preble) Date: Mon, 9 Mar 2020 22:12:17 -0700 (PDT) Subject: How does the super type present itself and do lookups? In-Reply-To: References: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com> <094a7298-a4d3-4ead-8ce6-bc209da8603e@googlegroups.com> Message-ID: <8aba33c4-c242-4bc2-be46-36bdd3ca6c7a@googlegroups.com> On Monday, March 9, 2020 at 9:31:45 PM UTC-5, Souvik Dutta wrote: > This should be what you are looking for. > https://python-reference.readthedocs.io/en/latest/docs/functions/super.html I'm not trying to figure out how the super() function works, but rather the anatomy of the object is returns. What I think is happening in my investigation is that some of the missing attributes in __dict__ are getting filled in from reserved slots, but it's just a theory. I'm trying to mimic the object in my own interpreter project. From darcosion at protonmail.com Tue Mar 10 05:30:20 2020 From: darcosion at protonmail.com (darcosion at protonmail.com) Date: Tue, 10 Mar 2020 09:30:20 +0000 Subject: The Real-Time Use of Python in Data Science World! In-Reply-To: <158355958156.9300.18008261846550968871@mail.python.org> References: <9f0fc4fa-1336-41c9-ae41-20bee930cb36@googlegroups.com> <158355958156.9300.18008261846550968871@mail.python.org> Message-ID: <7D0-KrMNECv7eoMwZP4ywb3wvAt9w-bCSVTUOf3b93mEs1dWB_ZKuKzaJbamjkX8BC5aHqjMQ34d_sRlu2sbkZk_gKAzMCp3nWVFHBKfACQ=@protonmail.com> Why they are ads on this mailing list ? ??????? Original Message ??????? Le samedi 7 mars 2020 06:39, a ?crit?: > Besant Technologies providing Python Training in Chennai with expert guidance and fully hands-on classes. Python is a high-level programming language sometimes it also denoted as the scripting language as it provides rapid & fast development and easy of use. Our Python Training in Chennai package also includes job placement assistance, which is really a bonus point for students. We also help students in getting a good job by conducting interviews of ours with good IT companies and MNCs too. > > https://www.besanttechnologies.com/training-courses/python-training-institute-in-chennai > > -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > Python-announce-list mailing list -- python-announce-list at python.org > To unsubscribe send an email to python-announce-list-leave at python.org > https://mail.python.org/mailman3/lists/python-announce-list.python.org/ > > Support the Python Software Foundation: > http://www.python.org/psf/donations/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 477 bytes Desc: OpenPGP digital signature URL: From mail.python.org at marco.sulla.e4ward.com Mon Mar 9 16:46:18 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 9 Mar 2020 21:46:18 +0100 Subject: pip UX Studies - help improve the usability of pip In-Reply-To: References: Message-ID: Subscribed. I have a little suggestion.... IMHO "What is you favourite pip command or functionality?" is not very useful... of course the most useful command is "install" :-) From mail.python.org at marco.sulla.e4ward.com Mon Mar 9 17:36:40 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 9 Mar 2020 22:36:40 +0100 Subject: Error while installing a python code In-Reply-To: References: Message-ID: I suppose you tried to use this setup.py: https://github.com/breathe/coffee_conda_package/blob/master/0001-Add-alternative-setup.py-script.patch It's not well written IMHO... anyway this is not the problem. I suppose you also downloaded the required sources from here: https://data.mendeley.com/datasets/s2x4d542dc/1 It seems the problem is that the above sources are generated by an old version of Cython: https://github.com/mcfletch/pyopengl/issues/11 You have "simply" to enter any subdir of PoissonSolver that ends with "_cy", remove the .c file inside and do: python setup.py build_ext --inplace After that, you'll be able to compile. The result is an ELF file. On my PC, the generated file is PoissonSolver/PoissonSolver/ps3d.cpython-38-x86_64-linux-gnu.so On Mon, 9 Mar 2020 at 15:27, Tim Ko wrote: > > Hello, > > I am trying to install a custom Python code but ran into an error. The error presumably associated with cython. I tried a different compiler since Intel compiler often crashes when using cython, but couldn't get it working. > > Attached is the installation error log. I have installed and updated all essential packages such as numpy and scipy. Could someone please give me advice to resolve this issue? Many thanks in advance. > > Sincerely, > TK > > > =================== > $ python setup.py build_ext -b PoissonSolver/ > running build_ext > skipping 'PoissonSolver/MV_2D_cy/matvec2D.c' Cython extension (up-to-date) > skipping 'PoissonSolver/MV_1D_cy/matvec1D.c' Cython extension (up-to-date) > skipping 'PoissonSolver/PS_3D_cy/ps3d.c' Cython extension (up-to-date) > building 'matvec2D' extension > icc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include -I/home01/r782a03/.conda/envs/hko_env/include/python3.7m -c PoissonSolver/MV_2D_cy/matvec2D.c -o build/temp.linux-x86_64-3.7/PoissonSolver/MV_2D_cy/matvec2D.o -ffast-math > icc: command line warning #10006: ignoring unknown option '-ffast-math' > In file included from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h(1830), > from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h(12), > from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h(4), > from PoissonSolver/MV_2D_cy/matvec2D.c(232): > /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h(17): warning #1224: #warning directive: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" > #warning "Using deprecated NumPy API, disable it with " \ > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17500): error: struct "_ts" has no field "exc_type" > *type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17501): error: struct "_ts" has no field "exc_value" > *value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17502): error: struct "_ts" has no field "exc_traceback" > *tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17514): error: struct "_ts" has no field "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17515): error: struct "_ts" has no field "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17516): error: struct "_ts" has no field "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17517): error: struct "_ts" has no field "exc_type" > tstate->exc_type = type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17518): error: struct "_ts" has no field "exc_value" > tstate->exc_value = value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17519): error: struct "_ts" has no field "exc_traceback" > tstate->exc_traceback = tb; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17562): error: struct "_ts" has no field "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17563): error: struct "_ts" has no field "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17564): error: struct "_ts" has no field "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17565): error: struct "_ts" has no field "exc_type" > tstate->exc_type = local_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17566): error: struct "_ts" has no field "exc_value" > tstate->exc_value = local_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17567): error: struct "_ts" has no field "exc_traceback" > tstate->exc_traceback = local_tb; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17589): error: struct "_ts" has no field "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17590): error: struct "_ts" has no field "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17591): error: struct "_ts" has no field "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17592): error: struct "_ts" has no field "exc_type" > tstate->exc_type = *type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17593): error: struct "_ts" has no field "exc_value" > tstate->exc_value = *value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17594): error: struct "_ts" has no field "exc_traceback" > tstate->exc_traceback = *tb; > ^ > > compilation aborted for PoissonSolver/MV_2D_cy/matvec2D.c (code 2) > error: command 'icc' failed with exit status 2 > =================== > -- > https://mail.python.org/mailman/listinfo/python-list From mail.python.org at marco.sulla.e4ward.com Sat Mar 7 06:21:32 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Sat, 7 Mar 2020 12:21:32 +0100 Subject: pip UX Studies - help improve the usability of pip In-Reply-To: References: Message-ID: There's someone of the pip team that can confirm this? On Sat, 7 Mar 2020 at 02:49, Bernard Tyers - Sane UX Design wrote: > > Hi there, > > My name is Bernard Tyers. I'm a UX designer and have recently started > working on the PSF project to improve the usability of pip, funded by > MOSS/CZI. > > I want to let you know about the pip UX Studies we've started today, and > encourage you to sign-up and take part. > > The pip Team is looking for Python users who use pip to take part in our > UX Studies. Your input will have a direct impact on improving pip. > > We want to speak with as diverse a group as possible. We'd particularly > like to speak with people with accessibility needs. > > You _don't_ have to be a Python expert to take part - I can't stress > this enough! > > You can find out all the details you'll need and find the sign-up link > on this blogpost: > > http://www.ei8fdb.org/thoughts/2020/03/pip-ux-study-recruitment/ > > If you do have questions I've not answered there, let me know. > > We'd also appreciate some signal boosting to reach as wide an audience > as possible. Please share the blog post with people in different Python > using communities. > > If you're a Twitter/Mastodon user we'd appreciate a signal boost of > these also: > > https://twitter.com/bernardtyers/status/1236039617222230017 > https://social.ei8fdb.org/@bernard/103778645553767728 > > > Thank you for your attention! > > Best wishes, > > Bernard > -- > > Bernard Tyers, User research & Interaction Design > > T: @bernardtyers > M: @bernard at social.ei8fdb.org > PGP Key: keybase.io/ei8fdb > > > I work on User-Centred Design, Open Source Software and Privacy. > -- > https://mail.python.org/mailman/listinfo/python-list From mail.python.org at marco.sulla.e4ward.com Mon Mar 9 10:42:22 2020 From: mail.python.org at marco.sulla.e4ward.com (Bernard Tyers - Sane UX Design) Date: Mon, 9 Mar 2020 14:42:22 +0000 Subject: pip UX Studies - help improve the usability of pip In-Reply-To: References: Message-ID: <071c648f-1e7e-02f5-079a-5fba4a18bb7e@ei8fdb.org> Hi Marco, Certainly. If you trust the validity of the Python Software Foundation's twitter feed, you can see they retweeted my call: https://twitter.com/ThePSF Alternatively if you reply to the list and ask Paul, Pradyun, Tzu-Ping or contact Sumana, the PM they'll be able to confirm it. Have I answered your question sufficiently? Regards, Bernard On 07/03/2020 11:21, Marco Sulla wrote: > There's someone of the pip team that can confirm this? > > On Sat, 7 Mar 2020 at 02:49, Bernard Tyers - Sane UX Design > wrote: >> >> Hi there, >> >> My name is Bernard Tyers. I'm a UX designer and have recently started >> working on the PSF project to improve the usability of pip, funded by >> MOSS/CZI. >> >> I want to let you know about the pip UX Studies we've started today, and >> encourage you to sign-up and take part. >> >> The pip Team is looking for Python users who use pip to take part in our >> UX Studies. Your input will have a direct impact on improving pip. >> >> We want to speak with as diverse a group as possible. We'd particularly >> like to speak with people with accessibility needs. >> >> You _don't_ have to be a Python expert to take part - I can't stress >> this enough! >> >> You can find out all the details you'll need and find the sign-up link >> on this blogpost: >> >> http://www.ei8fdb.org/thoughts/2020/03/pip-ux-study-recruitment/ >> >> If you do have questions I've not answered there, let me know. >> >> We'd also appreciate some signal boosting to reach as wide an audience >> as possible. Please share the blog post with people in different Python >> using communities. >> >> If you're a Twitter/Mastodon user we'd appreciate a signal boost of >> these also: >> >> https://twitter.com/bernardtyers/status/1236039617222230017 >> https://social.ei8fdb.org/@bernard/103778645553767728 >> >> >> Thank you for your attention! >> >> Best wishes, >> >> Bernard >> -- >> >> Bernard Tyers, User research & Interaction Design >> >> T: @bernardtyers >> M: @bernard at social.ei8fdb.org >> PGP Key: keybase.io/ei8fdb >> >> >> I work on User-Centred Design, Open Source Software and Privacy. >> -- >> https://mail.python.org/mailman/listinfo/python-list -- Bernard Tyers, User research & Interaction Design Sane UX Design Twitter: @bernardtyers PGP Key: keybase.io/ei8fdb I am currently working with the Python Foundation, and Open Technology Fund From mail.python.org at marco.sulla.e4ward.com Mon Mar 9 18:10:12 2020 From: mail.python.org at marco.sulla.e4ward.com (Tim Peters) Date: Mon, 9 Mar 2020 17:10:12 -0500 Subject: =?UTF-8?Q?Re=3A_=5BPython=2Dideas=5D_Re=3A_Magnitude_and_ProtoMagnitude_?= =?UTF-8?Q?ABCs_=E2=80=94_primarily_for_argument_validation?= In-Reply-To: References: <5c3b90b6-c5f5-31e5-7d1c-2d31685322ea@Damon-Family.org> <0c6ecd57-515c-ce2c-7f6e-bcee19625c30@Damon-Family.org> <20200305141047.GB4624@ando.pearwood.info> <20200309044129.GH4624@ando.pearwood.info> Message-ID: [Marco Sulla ] > Excuse me, Tim Peters, what do you think about my (probably heretical) > proposal of simply raising an exception instead of return a NaN, like > Python already do for division by zero? Sorry, I'm missing context. I don't see any other message(s) from you in this thread, so don't know what you mean. The message of mine you're replying to here said nothing about exceptions or NaNs. From mail.python.org at marco.sulla.e4ward.com Thu Mar 5 17:30:31 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Thu, 5 Mar 2020 23:30:31 +0100 Subject: =?UTF-8?Q?Re=3A_=5BPython=2Dideas=5D_Re=3A_Magnitude_and_ProtoMagnitude_?= =?UTF-8?Q?ABCs_=E2=80=94_primarily_for_argument_validation?= In-Reply-To: <158343493505.9300.18221727069008626252@mail.python.org> References: <158340457080.25211.11070091168084850872@mail.python.org> <158343493505.9300.18221727069008626252@mail.python.org> Message-ID: I think that implementing TotallyOrderable and PartiallyOrderable is a good idea. But is it useful? I mean, I don't know how much people needs really to order sets. Maybe some mathematician. But they can simply use Sage: http://doc.sagemath.org/html/en/reference/categories/sage/categories/posets.html The real problem is NaN. If NaN would not exists, floats will be perfectly total orderable. Yes, IEEE 754-2019 defines a total order: -NaN is a number minor that -Infinity, and +NaN is a number greater than +Infinity. And a NaN is greater than another NaN if its payload is greater. But IEEE 754 says also that the division by +0 should return +Infinity, and by -0 -Infinity. On the contrary, Python decided to not adhere to IEEE 754 in this case and do a very wise choice: raise an exception. The question is: why Python does not do the same for operations that now return NaN? Raising a NanError seems to me the only way to eliminate the NaN problem. Indeed NaN was created for languages like C, that does not support exceptions. From mail.python.org at marco.sulla.e4ward.com Mon Mar 9 16:20:21 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 9 Mar 2020 21:20:21 +0100 Subject: pip UX Studies - help improve the usability of pip In-Reply-To: References: Message-ID: On Mon, 9 Mar 2020 at 16:09, Paul Moore wrote: > We've had some questions as to whether this survey is legitimate. I > can confirm it is (speaking as a pip core developer). Thank you a lot! From mail.python.org at marco.sulla.e4ward.com Fri Mar 6 15:19:05 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Fri, 6 Mar 2020 21:19:05 +0100 Subject: Python question In-Reply-To: References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> Message-ID: On Fri, 6 Mar 2020 at 17:30, Souvik Dutta wrote: > And you cannot form opinions for > other people's by saying them not to support a person. That is injustice > and rude. I would reply, but I was already too much off topic. I want only to write what Gmail reports to me about the last message of the person that started this discussion: > This message seems dangerous > Many people marked similar messages as phishing scams, so this might contain unsafe content. Avoid clicking links, downloading attachments or replying with personal information. I never saw this message before in Gmail. Didn't your Gmail warned about this, Souvik Dutta? From mail.python.org at marco.sulla.e4ward.com Mon Mar 9 17:55:35 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Mon, 9 Mar 2020 22:55:35 +0100 Subject: Error while installing a python code In-Reply-To: References: Message-ID: Little errata: you have only to install or update Cython, remove the .c files as I wrote before and run again python setup.py build_ext -b PoissonSolver/ No intermediate steps are required. The generated ELF files are three. You have also to rename them with the names in the README file. On Mon, 9 Mar 2020 at 22:36, Marco Sulla wrote: > > I suppose you tried to use this setup.py: > https://github.com/breathe/coffee_conda_package/blob/master/0001-Add-alternative-setup.py-script.patch > > It's not well written IMHO... anyway this is not the problem. > > I suppose you also downloaded the required sources from here: > https://data.mendeley.com/datasets/s2x4d542dc/1 > > It seems the problem is that the above sources are generated by an old > version of Cython: > > https://github.com/mcfletch/pyopengl/issues/11 > > You have "simply" to enter any subdir of PoissonSolver that ends with > "_cy", remove the .c file inside and do: > python setup.py build_ext --inplace > > After that, you'll be able to compile. The result is an ELF file. On > my PC, the generated file is > PoissonSolver/PoissonSolver/ps3d.cpython-38-x86_64-linux-gnu.so > > On Mon, 9 Mar 2020 at 15:27, Tim Ko wrote: > > > > Hello, > > > > I am trying to install a custom Python code but ran into an error. The error presumably associated with cython. I tried a different compiler since Intel compiler often crashes when using cython, but couldn't get it working. > > > > Attached is the installation error log. I have installed and updated all essential packages such as numpy and scipy. Could someone please give me advice to resolve this issue? Many thanks in advance. > > > > Sincerely, > > TK > > > > > > =================== > > $ python setup.py build_ext -b PoissonSolver/ > > running build_ext > > skipping 'PoissonSolver/MV_2D_cy/matvec2D.c' Cython extension (up-to-date) > > skipping 'PoissonSolver/MV_1D_cy/matvec1D.c' Cython extension (up-to-date) > > skipping 'PoissonSolver/PS_3D_cy/ps3d.c' Cython extension (up-to-date) > > building 'matvec2D' extension > > icc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include -I/home01/r782a03/.conda/envs/hko_env/include/python3.7m -c PoissonSolver/MV_2D_cy/matvec2D.c -o build/temp.linux-x86_64-3.7/PoissonSolver/MV_2D_cy/matvec2D.o -ffast-math > > icc: command line warning #10006: ignoring unknown option '-ffast-math' > > In file included from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h(1830), > > from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h(12), > > from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h(4), > > from PoissonSolver/MV_2D_cy/matvec2D.c(232): > > /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h(17): warning #1224: #warning directive: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" > > #warning "Using deprecated NumPy API, disable it with " \ > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17500): error: struct "_ts" has no field "exc_type" > > *type = tstate->exc_type; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17501): error: struct "_ts" has no field "exc_value" > > *value = tstate->exc_value; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17502): error: struct "_ts" has no field "exc_traceback" > > *tb = tstate->exc_traceback; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17514): error: struct "_ts" has no field "exc_type" > > tmp_type = tstate->exc_type; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17515): error: struct "_ts" has no field "exc_value" > > tmp_value = tstate->exc_value; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17516): error: struct "_ts" has no field "exc_traceback" > > tmp_tb = tstate->exc_traceback; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17517): error: struct "_ts" has no field "exc_type" > > tstate->exc_type = type; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17518): error: struct "_ts" has no field "exc_value" > > tstate->exc_value = value; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17519): error: struct "_ts" has no field "exc_traceback" > > tstate->exc_traceback = tb; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17562): error: struct "_ts" has no field "exc_type" > > tmp_type = tstate->exc_type; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17563): error: struct "_ts" has no field "exc_value" > > tmp_value = tstate->exc_value; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17564): error: struct "_ts" has no field "exc_traceback" > > tmp_tb = tstate->exc_traceback; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17565): error: struct "_ts" has no field "exc_type" > > tstate->exc_type = local_type; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17566): error: struct "_ts" has no field "exc_value" > > tstate->exc_value = local_value; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17567): error: struct "_ts" has no field "exc_traceback" > > tstate->exc_traceback = local_tb; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17589): error: struct "_ts" has no field "exc_type" > > tmp_type = tstate->exc_type; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17590): error: struct "_ts" has no field "exc_value" > > tmp_value = tstate->exc_value; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17591): error: struct "_ts" has no field "exc_traceback" > > tmp_tb = tstate->exc_traceback; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17592): error: struct "_ts" has no field "exc_type" > > tstate->exc_type = *type; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17593): error: struct "_ts" has no field "exc_value" > > tstate->exc_value = *value; > > ^ > > > > PoissonSolver/MV_2D_cy/matvec2D.c(17594): error: struct "_ts" has no field "exc_traceback" > > tstate->exc_traceback = *tb; > > ^ > > > > compilation aborted for PoissonSolver/MV_2D_cy/matvec2D.c (code 2) > > error: command 'icc' failed with exit status 2 > > =================== > > -- > > https://mail.python.org/mailman/listinfo/python-list From mail.python.org at marco.sulla.e4ward.com Sat Mar 7 06:43:02 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Sat, 7 Mar 2020 12:43:02 +0100 Subject: [Python-ideas] Re: New explicit methods to trim strings In-Reply-To: References: <18006FFC-427D-4B9D-A7F3-3A850E667ACC@yahoo.com> <20200307000309.GE4624@ando.pearwood.info> Message-ID: I agree with Steven D'Aprano. I never had problems with strip(), but if people find it confusing, Python can simply leave strip() and all the other function as they are and add another functions, like crop() or snip() or shear() prune() or mow(). Personally I prefer crop() or prune(). This way there will be no breaking changes. On Sat, 7 Mar 2020 at 02:58, Ethan Furman wrote: > > On 03/06/2020 04:03 PM, Steven D'Aprano wrote: > > On Thu, Mar 05, 2020 at 12:45:28PM -0800, Andrew Barnert via Python-ideas wrote: > > >> Well, I like the idea if someone can come up with a good naming > >> scheme?something that at least reminds me which function is the ?set > >> of chars? stripper and which the ?substring? stripper, > > > > You've been a Python programmer for how many years now? Do you currently > > have trouble remembering what lstrip and rstrip do? > > Speaking for myself, about 13 years. And, yes, I do occasionally forget that the strips are character based. I can easily imagine it's worse for polyglot programmers. > > > > We already have `[l|r]strip` methods. If we want to associate the new > > methods with those, I suggest > > > > strip_prefix > > strip_suffix > > Works for me. Easy to add to bytes, too, if somebody is so inclined. > > -- > ~Ethan~ > _______________________________________________ > Python-ideas mailing list -- python-ideas at python.org > To unsubscribe send an email to python-ideas-leave at python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at https://mail.python.org/archives/list/python-ideas at python.org/message/JKBILM3G2C4TQ7XEVIH3V7M7CKCJ4R6Y/ > Code of Conduct: http://python.org/psf/codeofconduct/ From rosuav at gmail.com Tue Mar 10 08:38:41 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 10 Mar 2020 23:38:41 +1100 Subject: =?UTF-8?Q?Re=3A_=5BPython=2Dideas=5D_Re=3A_Magnitude_and_ProtoMagnitude_?= =?UTF-8?Q?ABCs_=E2=80=94_primarily_for_argument_validation?= In-Reply-To: References: <158340457080.25211.11070091168084850872@mail.python.org> <158343493505.9300.18221727069008626252@mail.python.org> Message-ID: On Tue, Mar 10, 2020 at 11:16 PM Marco Sulla via Python-list wrote: > Raising a NanError seems to me the only way to eliminate the NaN > problem. Indeed NaN was created for languages like C, that does not > support exceptions. People keep saying this - that nan exists to avoid exceptions - but that doesn't take signalling nans into account. Even in C, they are expected to raise an exception or equivalent. Python raises an exception for float division by zero because Python does its best to treat smallish integers and integral floats as equivalent. (Yes, I'm using "smallish" to mean "less than nine quadrillion"... programmers have weird ideas about magnitude sometimes.) Apart from indexing, the values 3 and 3.0 should be able to be used pretty much interchangeably. They compare equal (which, in turn, implies that they have the same hash), they behave very similarly in arithmetic, etc, etc, etc. It makes good sense for division by 0 and division by 0.0 to both result in the same exception. It also makes sense for integer division to raise rather than return a float (since "x // y" between two ints will never otherwise be a float). So it'd be nastily inconsistent to return a NaN for float division by zero. ChrisA From labs64dummystudent at gmail.com Tue Mar 10 10:14:41 2020 From: labs64dummystudent at gmail.com (labs64dummystudent at gmail.com) Date: Tue, 10 Mar 2020 07:14:41 -0700 (PDT) Subject: Is there something similar to guidechimp in python? In-Reply-To: References: Message-ID: <1d894b6f-5f55-4690-a5cd-233645297782@googlegroups.com> ???????, 7 ????? 2020 ?., 4:11:53 UTC+1 ???????????? Souvik Dutta ???????: > This is guidechimp -https://github.com/Labs64/GuideChimp > Is there anything similar to this in python? GuideChimp is a JavaScript library which can be integrated by adding js/css ressources to any web application. Please refer to https://github.com/Labs64/GuideChimp/wiki/Install#1-using-from-a-cdn to get the CDN ressources. Having that, you can actually use GuideChimp not only with Python application, but also with React, Vue.js, Angulat, PHP (Laravel) and many others. Hope that helps From __peter__ at web.de Tue Mar 10 10:27:42 2020 From: __peter__ at web.de (Peter Otten) Date: Tue, 10 Mar 2020 15:27:42 +0100 Subject: How does the super type present itself and do lookups? References: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com> Message-ID: Adam Preble wrote: > If you don't know, you can trap what super() returns some time and poke it > with a stick. If you print it you'll be able to tell it's definitely > unique: , > > > If you try to invoke methods on it, it'll invoke the superclass' methods. > That's what is supposed to happen and basically what already happens when > you do super().invoke_this_thing() anyways. > > Okay, so how is it doing the lookup for that? The child instance and the > super types' __dict__ are the same. The contents pass an equality > comparison and are the same if you print them. I think the fundamental insight is that given class A: foo = "A" class B(A): foo = "B" def super_foo(self): return super().foo def my_foo(self): return self.foo b = B() b.foo = "inst" print(b.super_foo()) # A print(b.my_foo()) # inst del b.foo print(b.my_foo()) # B del B.foo print(b.my_foo()) # A self.foo looks up the attribute in the instance, falls back to the class and then works its way up to the parent class, whereas super().foo bypasses both instance and class, and starts its lookup in the parent class. From nad at python.org Tue Mar 10 10:58:09 2020 From: nad at python.org (Ned Deily) Date: Tue, 10 Mar 2020 10:58:09 -0400 Subject: [RELEASE] Python 3.7.7 is now available Message-ID: https://discuss.python.org/t/python-3-7-7-is-now-available/3682 https://www.python.org/downloads/release/python-377/ -- Ned Deily nad at python.org -- [] From alan at csail.mit.edu Tue Mar 10 11:09:46 2020 From: alan at csail.mit.edu (Alan Bawden) Date: 10 Mar 2020 11:09:46 -0400 Subject: =?utf-8?b?UmU6IFtQeXRob24taWRl?= =?utf-8?b?YXNdIFJlOiBNYWduaXR1?= =?utf-8?b?ZGUgYW5kIFByb3RvTWFn?= =?utf-8?b?bml0dWRlIEFCQ3Mg4oCUIHA=?= =?utf-8?b?cmltYXJpbHkgZm9yIGFy?= =?utf-8?b?Z3VtZW50IHZhbGlkYXRp?= =?utf-8?b?b24=?= References: <158340457080.25211.11070091168084850872@mail.python.org> <158343493505.9300.18221727069008626252@mail.python.org> Message-ID: <864kuwnt51.fsf@richard.bawden.org> Chris Angelico writes: > People keep saying this - that nan exists to avoid exceptions - but > that doesn't take signalling nans into account. Even in C, they are > expected to raise an exception or equivalent. Actually, its not that far from the truth to say that NaNs "exist to avoid exceptions". According to Kahan, NaNs were an improvement over previous NaN-like mechanisms that existed in older computer hardware precisely because they avoid exceptions. Kahan says of those older mechanisms: "But nobody used them because they trap when touched." I believe that signalling NaNs were added to the IEEE standard late in the process because people still wanted something you could store in a uninitialized variable that would trap if you accidentally used it. Unlike all the IEEE operations that result in a NaN, using an uninitialized variable is clearly an error. Kahan doesn't think much of signalling NaNs, writing that they "exist mainly for political reasons and are rarely used". -- Alan Bawden From drsalists at gmail.com Tue Mar 10 11:39:22 2020 From: drsalists at gmail.com (Dan Stromberg) Date: Tue, 10 Mar 2020 08:39:22 -0700 Subject: Installation of python In-Reply-To: <07af0aaf-b5d5-49f2-baf0-9ef8a49f4f1f@googlegroups.com> References: <07af0aaf-b5d5-49f2-baf0-9ef8a49f4f1f@googlegroups.com> Message-ID: On Mon, Mar 9, 2020 at 7:20 AM Tim Ko wrote: > Hello, > > I am trying to install a custom Python package but ran into an error. The > error presumably associated with cython. I tried a different compiler since > Intel compiler often crashes when using cython, but couldn't get it > working. > Does this help? https://github.com/cython/cython/wiki/CythonExtensionsOnWindows I'm just guessing. I very infrequently use Windows. From barry at barrys-emacs.org Tue Mar 10 11:07:28 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Tue, 10 Mar 2020 15:07:28 +0000 Subject: Lock acquisition by the same thread - deadlock protection In-Reply-To: <20200309225302.GA22040@jong.localdomain> References: <20200309225302.GA22040@jong.localdomain> Message-ID: <400BDCEC-04F7-482A-9165-2E342B0230AE@barrys-emacs.org> > On 9 Mar 2020, at 22:53, Yonatan Goldschmidt wrote: > > I recently debugged a program hang, eventually finding out it's a deadlock of a single thread, > resulting from my usage of 2 libraries. One of them - call it library A - is reentrant & runs code in > GC finalizers, while the other - library B - is not reentrant at all. > Library B held one of its `threading.Lock` locks, and during this period, GC was invoked, running > finalizers of library A which call back into library B, now attempting to take the lock again, > locking the thread forever. > > Considering how relatively common this scenario might be (Python, by design, can preempt any user code > to run some other user code, due to GC finalizers), I was surprised Python code is not protected > from this simple type of deadlock. It makes sense that while `threading.RLock` allows for recursive > locking, `threading.Lock` will prevent it - raising an exception if you attempt it. > > I might be missing something, but why isn't it the status? Why taking a `threading.Lock` twice from > the same thread just hangs, instead of raising a friendly exception? > I ran a quick search in bpo but found nothing about this topic. I also tried to > search this mailing list but couldn't find how to, so I grepped a few random archives > but found nothing about it. > > Would be happy if anyone could shed some light on it... threading.Lock is not reentrant and its implementation does not allow detection of the problem from what I recall. In this case the code might want to use the threading.RLock that is reentrant. Of course there may be other issues in the code that prevent the finalizers working if it holds the lock. Barry From barry at barrys-emacs.org Tue Mar 10 11:28:40 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Tue, 10 Mar 2020 15:28:40 +0000 Subject: How does the super type present itself and do lookups? In-Reply-To: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com> References: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com> Message-ID: <7C615602-44BD-42BC-B3A2-E9B8B3923CAB@barrys-emacs.org> > On 4 Mar 2020, at 17:12, Adam Preble wrote: > > Months ago, I asked a bunch of stuff about super() and managed to fake it well enough to move on to other things for awhile. The day of reckoning came this week and I was forced to implement it better for my personal Python project. I have a hack in place that makes it work well-enough but I found myself frustrated with how shift the super type is. It's both the self and the parent class, but not. > > If you don't know, you can trap what super() returns some time and poke it with a stick. If you print it you'll be able to tell it's definitely unique: > , > > > If you try to invoke methods on it, it'll invoke the superclass' methods. That's what is supposed to happen and basically what already happens when you do super().invoke_this_thing() anyways. > > Okay, so how is it doing the lookup for that? The child instance and the super types' __dict__ are the same. The contents pass an equality comparison and are the same if you print them. Do you know about the Method Resolution Order (MRO) that is in __class__.__mro__)? I was very confused by super() until I found out about the MRO. When you call super() it finds where the code is in the MRO and then starts looking for a method in classes before the calling class. The following code shows this: class A: def __init__(self): super().__init__() def fn(self): return 'A.fn' class B(A): def __init__(self): super().__init__() class C(B): def __init__(self): super().__init__() def fn(self): return 'C.fn and super().fn is %r with value %r' % (super().fn, super().fn()) class D(C): def __init__(self): super().__init__() print(D.__mro__) obj = D() print( obj.fn() ) When it is run it prints: (, , , , ) C.fn and super().fn is > with value 'A.fn' When fn() is called on obj the version of fn() in class C is called. That fn() calls the super().fn and the second print shows that its the class A fn that is found called. super starts with the next class after the one it is called in. It is in C so find C in the MRO and starts with B. B does not have an fn(). Then it looks in A and finds fn(). Is this what you are looking for? Barry > > They have the same __getattribute__ method wrapper. However, if you dir() them you definitely get different stuff. For one, the super type has its special variables __self__, __self_class__, and __thisclass__. It's missing __dict__ from the dir output. But wait, I just looked at that! > > So I'm thinking that __getattr__ is involved, but it's not listed in anything. If I use getattr on the super, I'll get the parent methods. If I use __getattribute__, I get the child's methods. I get errors every way I've conceived of trying to pull out a __getattr__ dunder. No love. > > I guess the fundamental question is: what different stuff happens when LOAD_ATTR is performed on a super object versus a regular object? > > If you are curious about what I'm doing right now, I overrode __getattribute__ since that's primarily what I use for attribute lookups right now. It defer to the superclass' __getattribute__. If a method pops out, it replaces the self with the super's __self__ before kicking it out. I feel kind of dirty doing it: > > https://github.com/rockobonaparte/cloaca/blob/312758b2abb80320fb3bf344ba540a034875bc4b/LanguageImplementation/DataTypes/PySuperType.cs#L36 > > If you want to see how I was experimenting with super, here's the code and output: > > class Parent: > def __init__(self): > self.a = 1 > > def stuff(self): > print("Parent stuff!") > > > class Child(Parent): > def __init__(self): > super().__init__() > self.b = 2 > self.super_instance = super() > > def stuff(self): > print("Child stuff!") > > def only_in_child(self): > print("Only in child!") > > > c = Child() > c.super_instance.__init__() > c.stuff() > c.super_instance.stuff() > print(c) > print(c.super_instance) > print(c.__init__) > print(c.super_instance.__init__) > print(c.stuff) > print(c.super_instance.stuff) > print(c.__getattribute__) > print(c.super_instance.__getattribute__) > print(dir(c)) > print(dir(c.super_instance)) > print(c.__dict__ == c.super_instance.__dict__) > print(getattr(c, "__init__")) > print(getattr(c.super_instance, "__init__")) > print(c.__getattribute__("__init__")) > print(c.super_instance.__getattribute__("__init__")) > > > > Child stuff! > Parent stuff! > <__main__.Child object at 0x0000026854D99828> > , > > > > > > > > > > > > ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'a', 'b', 'only_in_child', 'stuff', 'super_instance'] > ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', '__self_class__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__thisclass__', 'a', 'b', 'super_instance'] > True > > > > > > > > > -- > https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Tue Mar 10 08:40:56 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 10 Mar 2020 23:40:56 +1100 Subject: Python question In-Reply-To: References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> Message-ID: On Tue, Mar 10, 2020 at 11:22 PM Marco Sulla via Python-list wrote: > > On Fri, 6 Mar 2020 at 17:30, Souvik Dutta wrote: > > And you cannot form opinions for > > other people's by saying them not to support a person. That is injustice > > and rude. > > I would reply, but I was already too much off topic. I want only to > write what Gmail reports to me about the last message of the person > that started this discussion: > > > This message seems dangerous > > Many people marked similar messages as phishing scams, so this might contain unsafe content. Avoid clicking links, downloading attachments or replying with personal information. > > I never saw this message before in Gmail. Didn't your Gmail warned > about this, Souvik Dutta? > I'm also reading this in Gmail, and I didn't get any such warning. I'm going to call that a spurious warning, a false positive. ChrisA From adam.preble at gmail.com Tue Mar 10 14:02:43 2020 From: adam.preble at gmail.com (Adam Preble) Date: Tue, 10 Mar 2020 11:02:43 -0700 (PDT) Subject: How does the super type present itself and do lookups? In-Reply-To: References: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com> Message-ID: On Tuesday, March 10, 2020 at 9:28:11 AM UTC-5, Peter Otten wrote: > self.foo looks up the attribute in the instance, falls back to the class and > then works its way up to the parent class, whereas > > super().foo bypasses both instance and class, and starts its lookup in the > parent class. Is this foo attribute being looked up in an override of __getattr__, __getattribute__, or is it a reserved slot that's internally doing this? That's what I'm trying to figure out. From torriem at gmail.com Tue Mar 10 14:34:50 2020 From: torriem at gmail.com (Michael Torrie) Date: Tue, 10 Mar 2020 12:34:50 -0600 Subject: Python question In-Reply-To: References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> Message-ID: <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> On 3/10/20 6:40 AM, Chris Angelico wrote: > On Tue, Mar 10, 2020 at 11:22 PM Marco Sulla via Python-list >> I would reply, but I was already too much off topic. I want only to >> write what Gmail reports to me about the last message of the person >> that started this discussion: >> >>> This message seems dangerous >>> Many people marked similar messages as phishing scams, so this might contain unsafe content. Avoid clicking links, downloading attachments or replying with personal information. >> >> I never saw this message before in Gmail. Didn't your Gmail warned >> about this, Souvik Dutta? >> > > I'm also reading this in Gmail, and I didn't get any such warning. I'm > going to call that a spurious warning, a false positive. Gmail often reports this about Python list messages because they are being sent through Python's mailing list servers but have the From address showing up as the poster's email address. Shows that Google's "my way or the highway" approach to security is problematic when it comes to traditional internet services like listservs. To say nothing of how they break mailing lists by throwing out your own messages to the list. Google products are definitely getting more and more frustrating for us traditional users. From PythonList at DancesWithMice.info Tue Mar 10 15:06:21 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Wed, 11 Mar 2020 08:06:21 +1300 Subject: Python question In-Reply-To: <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> Message-ID: <5d551551-b7e2-d3c5-e624-5d27751705b8@DancesWithMice.info> On 11/03/20 7:34 AM, Michael Torrie wrote: > On 3/10/20 6:40 AM, Chris Angelico wrote: >> On Tue, Mar 10, 2020 at 11:22 PM Marco Sulla via Python-list ... >> I'm also reading this in Gmail, and I didn't get any such warning. I'm >> going to call that a spurious warning, a false positive. > > Gmail often reports this about Python list messages because they are > being sent through Python's mailing list servers but have the From > address showing up as the poster's email address. > > Shows that Google's "my way or the highway" approach to security is > problematic when it comes to traditional internet services like > listservs. To say nothing of how they break mailing lists by throwing > out your own messages to the list. Google products are definitely > getting more and more frustrating for us traditional users. +1 ...and any right-of-reply is basically-hidden and then swathed in all manner of bureaucracy - which is why it not worth our long-suffering ListAdmins' (thanks guys!) time to attempt a fix! OT: Google is not the only over-large and over-bearing outfit... -- Regards =dn From souvik.viksou at gmail.com Tue Mar 10 20:49:44 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Wed, 11 Mar 2020 06:19:44 +0530 Subject: Python question In-Reply-To: <5d551551-b7e2-d3c5-e624-5d27751705b8@DancesWithMice.info> References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> <5d551551-b7e2-d3c5-e624-5d27751705b8@DancesWithMice.info> Message-ID: What about moving on to a social media app completely made in pythoj for python? On Wed, 11 Mar, 2020, 12:36 am DL Neil via Python-list, < python-list at python.org> wrote: > On 11/03/20 7:34 AM, Michael Torrie wrote: > > On 3/10/20 6:40 AM, Chris Angelico wrote: > >> On Tue, Mar 10, 2020 at 11:22 PM Marco Sulla via Python-list > ... > > >> I'm also reading this in Gmail, and I didn't get any such warning. I'm > >> going to call that a spurious warning, a false positive. > > > > Gmail often reports this about Python list messages because they are > > being sent through Python's mailing list servers but have the From > > address showing up as the poster's email address. > > > > Shows that Google's "my way or the highway" approach to security is > > problematic when it comes to traditional internet services like > > listservs. To say nothing of how they break mailing lists by throwing > > out your own messages to the list. Google products are definitely > > getting more and more frustrating for us traditional users. > > +1 > > ...and any right-of-reply is basically-hidden and then swathed in all > manner of bureaucracy - which is why it not worth our long-suffering > ListAdmins' (thanks guys!) time to attempt a fix! > > OT: Google is not the only over-large and over-bearing outfit... > > -- > Regards =dn > -- > https://mail.python.org/mailman/listinfo/python-list > From mail.python.org at marco.sulla.e4ward.com Tue Mar 10 18:49:51 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Tue, 10 Mar 2020 23:49:51 +0100 Subject: =?UTF-8?Q?Re=3A_=5BPython=2Dideas=5D_Re=3A_Magnitude_and_ProtoMagnitude_?= =?UTF-8?Q?ABCs_=E2=80=94_primarily_for_argument_validation?= In-Reply-To: References: <158340457080.25211.11070091168084850872@mail.python.org> <158343493505.9300.18221727069008626252@mail.python.org> Message-ID: On Tue, 10 Mar 2020 at 13:41, Chris Angelico wrote: > It makes good sense for > division by 0 and division by 0.0 to both result in the same > exception. But Python 3 returns a float, for example, in division between integers. 4 / 2 == 2.0. So some_integer / +0 should return +Infinity. This is what IEEE 754 says. Luckily Python does not adhere completely to IEEE 754. Furthermore, there's a precedence in Python: decimal. decimal.Decimal does not returns NaN in any of the operations that should return it: https://en.wikipedia.org/wiki/NaN#Operations_generating_NaN On the contrary, it returns decimal.InvalidOperation. @Alan Bawden: thank you for letting me know about William Kahan. I think it's analysis of IEEE 754 is very detailed, and I didn't know that traps exist. And yes, I agree that traps and exceptions slows down the computation. But in a language like Python, when simplicity and usability is a priority, and when "no exception should pass silently", IMHO operations that returns NaN are only an heritage from C, since Python is written in C. PS: I'm quoting import this with Tim Peters in the discussion, to Alan Bawden... It's like teaching physics to Fermi. From mail.python.org at marco.sulla.e4ward.com Tue Mar 10 19:01:51 2020 From: mail.python.org at marco.sulla.e4ward.com (Marco Sulla) Date: Wed, 11 Mar 2020 00:01:51 +0100 Subject: Installation of python In-Reply-To: <07af0aaf-b5d5-49f2-baf0-9ef8a49f4f1f@googlegroups.com> References: <07af0aaf-b5d5-49f2-baf0-9ef8a49f4f1f@googlegroups.com> Message-ID: *Ahem* I already posted the solution to your problem. I quote myself: I suppose you also downloaded the required sources from here: https://data.mendeley.com/datasets/s2x4d542dc/1 It seems the problem is that the above sources are generated by an old version of Cython: https://github.com/mcfletch/pyopengl/issues/11 You have "simply" to enter any subdir of PoissonSolver that ends with "_cy" and remove the .c file inside them. After that, you'll be able to compile. The result is three ELF files. On my PC, for example, one of the the generated shared libraries is PoissonSolver/PoissonSolver/ps3d.cpython-38-x86_64-linux-gnu.so You have also to rename them. Follow the README. On Mon, 9 Mar 2020 at 15:23, Tim Ko wrote: > > Hello, > > I am trying to install a custom Python package but ran into an error. The error presumably associated with cython. I tried a different compiler since Intel compiler often crashes when using cython, but couldn't get it working. > > Attached is the installation error log. I have installed and updated all essential packages such as numpy and scipy. Could someone please give me advice to resolve this issue? Many thanks in advance. > > Sincerely, > TK > > > =================== > $ python setup.py build_ext -b PoissonSolver/ > running build_ext > skipping 'PoissonSolver/MV_2D_cy/matvec2D.c' Cython extension (up-to-date) > skipping 'PoissonSolver/MV_1D_cy/matvec1D.c' Cython extension (up-to-date) > skipping 'PoissonSolver/PS_3D_cy/ps3d.c' Cython extension (up-to-date) > building 'matvec2D' extension > icc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include -I/home01/r782a03/.conda/envs/hko_env/include/python3.7m -c PoissonSolver/MV_2D_cy/matvec2D.c -o build/temp.linux-x86_64-3.7/PoissonSolver/MV_2D_cy/matvec2D.o -ffast-math > icc: command line warning #10006: ignoring unknown option '-ffast-math' > In file included from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h(1830), > from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h(12), > from /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h(4), > from PoissonSolver/MV_2D_cy/matvec2D.c(232): > /home01/r782a03/.conda/envs/hko_env/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h(17): warning #1224: #warning directive: "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" > #warning "Using deprecated NumPy API, disable it with " \ > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17500): error: struct "_ts" has no field "exc_type" > *type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17501): error: struct "_ts" has no field "exc_value" > *value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17502): error: struct "_ts" has no field "exc_traceback" > *tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17514): error: struct "_ts" has no field "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17515): error: struct "_ts" has no field "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17516): error: struct "_ts" has no field "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17517): error: struct "_ts" has no field "exc_type" > tstate->exc_type = type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17518): error: struct "_ts" has no field "exc_value" > tstate->exc_value = value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17519): error: struct "_ts" has no field "exc_traceback" > tstate->exc_traceback = tb; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17562): error: struct "_ts" has no field "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17563): error: struct "_ts" has no field "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17564): error: struct "_ts" has no field "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17565): error: struct "_ts" has no field "exc_type" > tstate->exc_type = local_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17566): error: struct "_ts" has no field "exc_value" > tstate->exc_value = local_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17567): error: struct "_ts" has no field "exc_traceback" > tstate->exc_traceback = local_tb; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17589): error: struct "_ts" has no field "exc_type" > tmp_type = tstate->exc_type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17590): error: struct "_ts" has no field "exc_value" > tmp_value = tstate->exc_value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17591): error: struct "_ts" has no field "exc_traceback" > tmp_tb = tstate->exc_traceback; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17592): error: struct "_ts" has no field "exc_type" > tstate->exc_type = *type; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17593): error: struct "_ts" has no field "exc_value" > tstate->exc_value = *value; > ^ > > PoissonSolver/MV_2D_cy/matvec2D.c(17594): error: struct "_ts" has no field "exc_traceback" > tstate->exc_traceback = *tb; > ^ > > compilation aborted for PoissonSolver/MV_2D_cy/matvec2D.c (code 2) > error: command 'icc' failed with exit status 2 > =================== > -- > https://mail.python.org/mailman/listinfo/python-list From kthakur.nand at gmail.com Tue Mar 10 21:20:38 2020 From: kthakur.nand at gmail.com (NAND KISHORE) Date: Tue, 10 Mar 2020 20:20:38 -0500 Subject: Issue with PYSFTP - Working in WINSCP Message-ID: Hi We have requirement where we need to get file from client path and then upload the same to vendor directory path. I am not able to upload the file to vendor directory path , however when I tried to use the WINSCP it worked fine. So I thought of checking with Gurus what is wrong I am doing in my script. Appreciate your input. I will attach my script. Here is what I am doing. Step1. Clear the client directory path Step2. Make a call to HVAC Vault to get the username and password for client and vendor server Step3. Use the username and password to establish connection using pysftp for client. Step4. Store the file in local path. Step5. Segregate the file into different path based on file type Step6 Establish a connection to vendor and copy the file to vendor. Step7 Close the client and Vendor connection Please see the file attached. Also below is the error which I am getting --------------------------------------------------------- ERROR:root:Error in getting the file from EBS Outbound Server Traceback (most recent call last): File "FILE_TRANSFER_PROCESS.py", line 191, in file_transfer vendor.put(src_file, dst_file) File "/d01/python3/lib64/python3.6/site-packages/pysftp/__init__.py", line 364, in put confirm=confirm) File "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line 759, in put return self.putfo(fl, remotepath, file_size, callback, confirm) File "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line 720, in putfo s = self.stat(remotepath) File "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line 493, in stat t, msg = self._request(CMD_STAT, path) File "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line 813, in _request return self._read_response(num) File "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line 865, in _read_response self._convert_status(msg) File "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line 894, in _convert_status raise IOError(errno.ENOENT, text) FileNotFoundError: [Errno 2] /custom/OWO/ECE_OWO_20200303_143895.dat -------------- next part -------------- #!/usr/bin/python # -*- coding: utf-8 -*- import csv # from pysftp import Connection, CnOpts import os import sys import pysftp import logging import hvac import datetime from datetime import datetime import ssl import smtplib import shutil from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email import encoders def file_delete (dirs): write_to_file('F', 'The directory is '+dirs) for files in os.listdir(dirs): filed = dirs + "/" +files write_to_file('F','File is to be deleted '+filed) os.remove(filed) def write_to_file(mode,filetext): log_path = "/home/kishnx/scripts/log/sftp.log" if mode == 'I': f = open(log_path,"w") else: f = open(log_path,"a") f.write(filetext) f.write("\n") f.close() def sendEmail(v_status): port = 587 # For starttls smtp_server = "smtp.gmail.com" receiver_email = "test_receiver at gmail.com" sender_email = "test_sender at gmail.com" password = "Test1234" if v_status == 'S': message = """\ GXS_OUTBOUND Ran the Python SFTP program.""" elif v_status == 'E': message = """\ GXS_OUTBOUND Issue with the Python SFTP program.Check Log Files.""" context = ssl.create_default_context() with smtplib.SMTP(smtp_server, port) as server: server.ehlo() # Can be omitted server.starttls(context=context) server.ehlo() # Can be omitted server.login(sender_email, password) server.sendmail(sender_email, receiver_email, message) timing=datetime.now() fcontent1 = 'Logging for today has started' write_to_file('I',"-------------------------------------------------------------------------------------------------------------") write_to_file('F',fcontent1) write_to_file('F',str(timing)) sl_cinfo = None ot_cinfo = None otsource = 'VENDOR' ebspath1 = 'UNKNOWN' otpath1 = 'UNKNOWN' ebssource = 'CLIENT' localfuspath = '/home/test/scripts/outbound/scm' localfuspath3 = '/home/test/scripts/outbound/outbound' shutil.rmtree(localfuspath) os.makedirs(localfuspath) vaultfile = open('/home/test/.vaulttoken', 'r') vault_token = vaultfile.read().strip() client = hvac.Client() client = hvac.Client(url='https://vault.comfort.com:8200', token=vault_token, verify='/home/test/vault-cert.crt') if client.is_authenticated(): print ('vault is authenticated') write_to_file('F','vault is authenticated') def file_transfer(sleep, vendor, paths): global localfusaropath1 global localfusowopath1 global localfusitempath1 global localfuspath1 # print("paths are ",paths[0],paths[1]) ebsBasePath = paths[0] localBasePath = paths[1] localfuspath1 = paths[2] localpath3 = paths[3] ebsArchivePath = os.path.join(ebsBasePath, 'archive') localfusaropath1 = os.path.join(localpath3, 'aro') localfusowopath1 = os.path.join(localpath3, 'owo') localfusitempath1 = os.path.join(localpath3, 'item') localfuspath2 = os.path.join(localfuspath1, '/') otaropath1 = paths[5] otowopath1 = paths[4] otitempath1 = paths[6] print ('client connection') print (sleep) print ('vendor connection ') print (vendor) print (localfuspath1, ' for SFTP ebs base path', ebsBasePath,' Sleep Connection ',sleep,' Vendor Connection ', vendor ) write_to_file('F', '*****************************************************************************') write_to_file('F','Start of File Transfer Program') write_to_file('F', '*****************************************************************************') write_to_file('F', ' Directory Path Reference') write_to_file('F','EBS Path for Outbound ' + ebsBasePath) write_to_file('F','EBS Archive Path for Outbound ' + ebsArchivePath) write_to_file('F', 'Server Path where file will be written from EBS ' + localfuspath1) write_to_file('F','Server Path where file ARO OWO QGO File will be copied ' + localpath3) write_to_file('F', 'Server Path for ARO ' + localfusaropath1) write_to_file('F', 'Server Path for QGO ' + localfusitempath1) write_to_file('F', 'Server Path for OWO ' + localfusowopath1) write_to_file('F', 'Client Path for ARO ' + otaropath1) write_to_file('F', 'Client Path for QGO ' + otitempath1) write_to_file('F', 'Client Path for OWO ' + otowopath1) write_to_file('F', '*****************************************************************************') source_dir = localfuspath1 + "/" print("source dir " + source_dir) if ebsBasePath != 'UNKNOWN': try: #Initialize the directory by deleting the content write_to_file('F','Initialize the directory by deleting the content') print(' Content of directory ') print(os.listdir(localfuspath1)) file_delete(localfuspath1) file_delete(localfusaropath1) file_delete(localfusowopath1) file_delete(localfusitempath1) write_to_file('F','End of Intialization Process ') write_to_file('F', '*****************************************************************************') write_to_file('F', 'Start of SFTP Process ') sleep.get_d(ebsBasePath, localfuspath1, preserve_mtime=True) # depending on file type move to various location for file in os.listdir(localfuspath1): src = os.path.join(source_dir, file) if file.startswith("ECE_ARO"): dst_dir=localfusaropath1 + "/" dst=os.path.join(dst_dir,file) print("ECE_ARO File--> "+file) shutil.copyfile(src,dst) if file.startswith("ECE_OWO"): dst_dir = localfusowopath1 + "/" dst = os.path.join(dst_dir, file) print("ECE_OWO File--> "+file) shutil.copyfile(src, dst) if file.startswith("ECE_QGO"): dst_dir = localfusitempath1 + "/" dst = os.path.join(dst_dir, file) print("ECE_QGO File--> "+file) shutil.copyfile(src, dst) sleep.put_d(localfuspath1, ebsArchivePath, preserve_mtime=True) write_to_file('F','File is successfully Copied To Client Local Folder and Archive Location') #print('File is successfully copied to Client') except Exception: # remote Archive sendEmail('E') logging.exception('Exception in sending files to eBS') write_to_file('F','Exception in sending files to eBS') try: write_to_file('F'," File Contents for ARO "+localfusaropath1) # Switch to a remote directory vendor.cwd(otowopath1) # Obtain structure of the remote directory '/var/www/vhosts' directory_structure = vendor.listdir_attr() # Print data print("attributes") for attr in directory_structure: print ( attr.filename, attr ) for file in os.listdir(localfusaropath1): write_to_file('F',file) src_dir = localfusaropath1 + "/" src_file = os.path.join(src_dir, file) dst_dir = otaropath1 + "/" dst_file = os.path.join(dst_dir, file) print( " src and dst file ") print(src_file) print(dst_dir ) #vendor.cd(dst_dir) #vendor.put(src_file) #vendor.put(src_file,dst_file) write_to_file('F'," ******************************* ") write_to_file('F'," File Contents for OWO "+localfusowopath1) for file in os.listdir(localfusowopath1): write_to_file('F',file) src_dir = localfusowopath1 + "/" src_file = os.path.join(src_dir, file) dst_dir = otowopath1 + "/" dst_file = os.path.join(dst_dir, file) vendor.put(src_file, dst_file) write_to_file('F'," ******************************* ") write_to_file('F'," File Contents for QGO "+localfusitempath1) for file in os.listdir(localfusitempath1): write_to_file('F',file) src_dir = localfusitempath1 + "/" src_file = os.path.join(src_dir, file) dst_dir = otitempath1 + "/" dst_file = os.path.join(dst_dir, file) vendor.put(src_file, dst_file) write_to_file('F'," ******************************* ") print('Server Path for ARO ' + localfusaropath1) print('Server Path for QGO ' + localfusitempath1) print('Server Path for OWO ' + localfusowopath1) print('Client Path for ARO ' + otaropath1) print('Client Path for QGO ' + otitempath1) print('Client Path for OWO ' + otowopath1) #vendor.put_d(localfusaropath1, otaropath1, preserve_mtime=True) #vendor.put_d(localfusaropath1,otaropath1, preserve_mtime=True) #vendor.put_d(localfusowopath1, otowopath1, preserve_mtime=True) print ('File is successfully Transferred to open Text') write_to_file('F','File is successfully Transferred to open Text') vendor.close() sleep.close() except Exception: logging.exception('Error in getting the file from EBS Outbound Server') sendEmail('E') write_to_file('F','Error in getting the file from EBS Outbound Server') def create_connection( osource, oshost, vusername, vpassword): global sl_cinfo global ot_cinfo cnopts = pysftp.CnOpts() cnopts.hostkeys = None # oshost='10.7.51.60' write_to_file('F','Start of create_connection Program') write_to_file('F','Source ' + osource) print("source " +osource) ebs_cinfo = pysftp.Connection(host=oshost, username=vusername, password=vpassword, cnopts=cnopts) print("Able to establish the connection") write_to_file('F','Able to establish the connection') if osource == 'CLIENT': sl_cinfo = ebs_cinfo if osource == 'VENDOR': ot_cinfo = ebs_cinfo if ebssource == 'CLIENT': try: vault = '/kv/opentext/tst2' ebs_username = client.read(vault)['data']['ebs_username'].strip() ebs_password = client.read(vault)['data']['ebs_password'].strip() ebshost = client.read(vault)['data']['ebs_host'].strip() ebshost = 'ebststapp11' ebspath1 = client.read(vault)['data']['ebs_path'].strip() create_connection(ebssource, ebshost, ebs_username, ebs_password) print ('Worked Fine ', ebssource) write_to_file('F',ebssource) write_to_file('F','Connection Established') except: print ('Error in establishing the connection ', ebssource) write_to_file('F',ebssource) write_to_file('F','Connection Failed') sendEmail('E') if otsource == 'VENDOR': try: vault = '/kv/opentext/tst2' ot_username = client.read(vault)['data']['ot_username'].strip() ot_password = client.read(vault)['data']['ot_password'].strip() othost = client.read(vault)['data']['ot_host'].strip() ot_owo_path = client.read(vault)['data']['ot_owo_path'].strip() ot_aro_path = client.read(vault)['data']['ot_aro_path'].strip() ot_qgo_path = client.read(vault)['data']['ot_qgo_path'].strip() otpath1 = client.read(vault)['data']['ot_owo_path'].strip() create_connection(otsource, othost, ot_username,ot_password) print('Connection Established ',otsource) write_to_file('F',otsource) write_to_file('F','Connection Established') except: print ('Error in establishing the connection ', otsource) write_to_file('F',otsource) write_to_file('F','Error in Connection Established') sendEmail('E') paths = [ebspath1, otpath1,localfuspath,localfuspath3,ot_owo_path,ot_aro_path,ot_qgo_path] file_transfer(sl_cinfo, ot_cinfo, paths) sendEmail('S') write_to_file('F',"Email has been sent ") print ("Email has been sent ") timing=datetime.now() write_to_file('F',str(timing)) write_to_file('F','the logging has ended') write_to_file('F',"-------------------------------------------------------------------------------------------------------------") From kthakur.nand at gmail.com Tue Mar 10 21:48:34 2020 From: kthakur.nand at gmail.com (NAND KISHORE) Date: Tue, 10 Mar 2020 20:48:34 -0500 Subject: Pysftp Issue File Upload is not working - put command In-Reply-To: <1583885255.31.0.428229167076.issue39928@roundup.psfhosted.org> References: <1583885255.31.0.428229167076.issue39928@roundup.psfhosted.org> Message-ID: > > > Hi > We have requirement where we need to get file from client path and then > upload the same to vendor directory path. I am not able to upload the file > to vendor directory path , however when I tried to use the WINSCP it worked > fine. So I thought of checking with Gurus what is wrong I am doing in my > script. Appreciate your input. > I will attach my script. Here is what I am doing. > > Step1. Clear the client directory path > Step2. Make a call to HVAC Vault to get the username and password for > client and vendor server > Step3. Use the username and password to establish connection using pysftp > for client. > Step4. Store the file in local path. > Step5. Segregate the file into different path based on file type > Step6 Establish a connection to vendor and upload the file to vendor > directory path. > Step7 Close the client and Vendor connection > > Note : In step 6 I am getting an error and I am getting below error > Please see the file attached for code. > > Also below is the error which I am getting > > --------------------------------------------------------- > > > > > > > > > > > > > > > > > > > > * ERROR:root:Error in getting the file from EBS Outbound Server Traceback > (most recent call last): File "FILE_TRANSFER_PROCESS.py", line 191, in > file_transfer vendor.put(src_file, dst_file) File > "/d01/python3/lib64/python3.6/site-packages/pysftp/__init__.py", line 364, > in put confirm=confirm) File > "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line > 759, in put return self.putfo(fl, remotepath, file_size, callback, > confirm) File > "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line > 720, in putfo s = self.stat(remotepath) File > "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line > 493, in stat t, msg = self._request(CMD_STAT, path) File > "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line > 813, in _request return self._read_response(num) File > "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line > 865, in _read_response self._convert_status(msg) File > "/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line > 894, in _convert_status raise IOError(errno.ENOENT, text) > FileNotFoundError: [Errno 2] /custom/OWO/ECE_OWO_20200303_143895.dat* > ______ > -------------- next part -------------- #!/usr/bin/python # -*- coding: utf-8 -*- import csv # from pysftp import Connection, CnOpts import os import sys import pysftp import logging import hvac import datetime from datetime import datetime import ssl import smtplib import shutil from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email import encoders def file_delete (dirs): write_to_file('F', 'The directory is '+dirs) for files in os.listdir(dirs): filed = dirs + "/" +files write_to_file('F','File is to be deleted '+filed) os.remove(filed) def write_to_file(mode,filetext): log_path = "/home/kishnx/scripts/log/sftp.log" if mode == 'I': f = open(log_path,"w") else: f = open(log_path,"a") f.write(filetext) f.write("\n") f.close() def sendEmail(v_status): port = 587 # For starttls smtp_server = "smtp.gmail.com" receiver_email = "test_receiver at gmail.com" sender_email = "test_sender at gmail.com" password = "Test1234" if v_status == 'S': message = """\ GXS_OUTBOUND Ran the Python SFTP program.""" elif v_status == 'E': message = """\ GXS_OUTBOUND Issue with the Python SFTP program.Check Log Files.""" context = ssl.create_default_context() with smtplib.SMTP(smtp_server, port) as server: server.ehlo() # Can be omitted server.starttls(context=context) server.ehlo() # Can be omitted server.login(sender_email, password) server.sendmail(sender_email, receiver_email, message) timing=datetime.now() fcontent1 = 'Logging for today has started' write_to_file('I',"-------------------------------------------------------------------------------------------------------------") write_to_file('F',fcontent1) write_to_file('F',str(timing)) sl_cinfo = None ot_cinfo = None otsource = 'VENDOR' ebspath1 = 'UNKNOWN' otpath1 = 'UNKNOWN' ebssource = 'CLIENT' localfuspath = '/home/test/scripts/outbound/scm' localfuspath3 = '/home/test/scripts/outbound/outbound' shutil.rmtree(localfuspath) os.makedirs(localfuspath) vaultfile = open('/home/test/.vaulttoken', 'r') vault_token = vaultfile.read().strip() client = hvac.Client() client = hvac.Client(url='https://vault.comfort.com:8200', token=vault_token, verify='/home/test/vault-cert.crt') if client.is_authenticated(): print ('vault is authenticated') write_to_file('F','vault is authenticated') def file_transfer(sleep, vendor, paths): global localfusaropath1 global localfusowopath1 global localfusitempath1 global localfuspath1 # print("paths are ",paths[0],paths[1]) ebsBasePath = paths[0] localBasePath = paths[1] localfuspath1 = paths[2] localpath3 = paths[3] ebsArchivePath = os.path.join(ebsBasePath, 'archive') localfusaropath1 = os.path.join(localpath3, 'aro') localfusowopath1 = os.path.join(localpath3, 'owo') localfusitempath1 = os.path.join(localpath3, 'item') localfuspath2 = os.path.join(localfuspath1, '/') otaropath1 = paths[5] otowopath1 = paths[4] otitempath1 = paths[6] print ('client connection') print (sleep) print ('vendor connection ') print (vendor) print (localfuspath1, ' for SFTP ebs base path', ebsBasePath,' Sleep Connection ',sleep,' Vendor Connection ', vendor ) write_to_file('F', '*****************************************************************************') write_to_file('F','Start of File Transfer Program') write_to_file('F', '*****************************************************************************') write_to_file('F', ' Directory Path Reference') write_to_file('F','EBS Path for Outbound ' + ebsBasePath) write_to_file('F','EBS Archive Path for Outbound ' + ebsArchivePath) write_to_file('F', 'Server Path where file will be written from EBS ' + localfuspath1) write_to_file('F','Server Path where file ARO OWO QGO File will be copied ' + localpath3) write_to_file('F', 'Server Path for ARO ' + localfusaropath1) write_to_file('F', 'Server Path for QGO ' + localfusitempath1) write_to_file('F', 'Server Path for OWO ' + localfusowopath1) write_to_file('F', 'Client Path for ARO ' + otaropath1) write_to_file('F', 'Client Path for QGO ' + otitempath1) write_to_file('F', 'Client Path for OWO ' + otowopath1) write_to_file('F', '*****************************************************************************') source_dir = localfuspath1 + "/" print("source dir " + source_dir) if ebsBasePath != 'UNKNOWN': try: #Initialize the directory by deleting the content write_to_file('F','Initialize the directory by deleting the content') print(' Content of directory ') print(os.listdir(localfuspath1)) file_delete(localfuspath1) file_delete(localfusaropath1) file_delete(localfusowopath1) file_delete(localfusitempath1) write_to_file('F','End of Intialization Process ') write_to_file('F', '*****************************************************************************') write_to_file('F', 'Start of SFTP Process ') sleep.get_d(ebsBasePath, localfuspath1, preserve_mtime=True) # depending on file type move to various location for file in os.listdir(localfuspath1): src = os.path.join(source_dir, file) if file.startswith("ECE_ARO"): dst_dir=localfusaropath1 + "/" dst=os.path.join(dst_dir,file) print("ECE_ARO File--> "+file) shutil.copyfile(src,dst) if file.startswith("ECE_OWO"): dst_dir = localfusowopath1 + "/" dst = os.path.join(dst_dir, file) print("ECE_OWO File--> "+file) shutil.copyfile(src, dst) if file.startswith("ECE_QGO"): dst_dir = localfusitempath1 + "/" dst = os.path.join(dst_dir, file) print("ECE_QGO File--> "+file) shutil.copyfile(src, dst) sleep.put_d(localfuspath1, ebsArchivePath, preserve_mtime=True) write_to_file('F','File is successfully Copied To Client Local Folder and Archive Location') #print('File is successfully copied to Client') except Exception: # remote Archive sendEmail('E') logging.exception('Exception in sending files to eBS') write_to_file('F','Exception in sending files to eBS') try: write_to_file('F'," File Contents for ARO "+localfusaropath1) # Switch to a remote directory vendor.cwd(otowopath1) # Obtain structure of the remote directory '/var/www/vhosts' directory_structure = vendor.listdir_attr() # Print data print("attributes") for attr in directory_structure: print ( attr.filename, attr ) for file in os.listdir(localfusaropath1): write_to_file('F',file) src_dir = localfusaropath1 + "/" src_file = os.path.join(src_dir, file) dst_dir = otaropath1 + "/" dst_file = os.path.join(dst_dir, file) print( " src and dst file ") print(src_file) print(dst_dir ) #vendor.cd(dst_dir) #vendor.put(src_file) #vendor.put(src_file,dst_file) write_to_file('F'," ******************************* ") write_to_file('F'," File Contents for OWO "+localfusowopath1) for file in os.listdir(localfusowopath1): write_to_file('F',file) src_dir = localfusowopath1 + "/" src_file = os.path.join(src_dir, file) dst_dir = otowopath1 + "/" dst_file = os.path.join(dst_dir, file) vendor.put(src_file, dst_file) write_to_file('F'," ******************************* ") write_to_file('F'," File Contents for QGO "+localfusitempath1) for file in os.listdir(localfusitempath1): write_to_file('F',file) src_dir = localfusitempath1 + "/" src_file = os.path.join(src_dir, file) dst_dir = otitempath1 + "/" dst_file = os.path.join(dst_dir, file) vendor.put(src_file, dst_file) write_to_file('F'," ******************************* ") print('Server Path for ARO ' + localfusaropath1) print('Server Path for QGO ' + localfusitempath1) print('Server Path for OWO ' + localfusowopath1) print('Client Path for ARO ' + otaropath1) print('Client Path for QGO ' + otitempath1) print('Client Path for OWO ' + otowopath1) #vendor.put_d(localfusaropath1, otaropath1, preserve_mtime=True) #vendor.put_d(localfusaropath1,otaropath1, preserve_mtime=True) #vendor.put_d(localfusowopath1, otowopath1, preserve_mtime=True) print ('File is successfully Transferred to open Text') write_to_file('F','File is successfully Transferred to open Text') vendor.close() sleep.close() except Exception: logging.exception('Error in getting the file from EBS Outbound Server') sendEmail('E') write_to_file('F','Error in getting the file from EBS Outbound Server') def create_connection( osource, oshost, vusername, vpassword): global sl_cinfo global ot_cinfo cnopts = pysftp.CnOpts() cnopts.hostkeys = None # oshost='10.7.51.60' write_to_file('F','Start of create_connection Program') write_to_file('F','Source ' + osource) print("source " +osource) ebs_cinfo = pysftp.Connection(host=oshost, username=vusername, password=vpassword, cnopts=cnopts) print("Able to establish the connection") write_to_file('F','Able to establish the connection') if osource == 'CLIENT': sl_cinfo = ebs_cinfo if osource == 'VENDOR': ot_cinfo = ebs_cinfo if ebssource == 'CLIENT': try: vault = '/kv/opentext/tst2' ebs_username = client.read(vault)['data']['ebs_username'].strip() ebs_password = client.read(vault)['data']['ebs_password'].strip() ebshost = client.read(vault)['data']['ebs_host'].strip() ebshost = 'ebststapp11' ebspath1 = client.read(vault)['data']['ebs_path'].strip() create_connection(ebssource, ebshost, ebs_username, ebs_password) print ('Worked Fine ', ebssource) write_to_file('F',ebssource) write_to_file('F','Connection Established') except: print ('Error in establishing the connection ', ebssource) write_to_file('F',ebssource) write_to_file('F','Connection Failed') sendEmail('E') if otsource == 'VENDOR': try: vault = '/kv/opentext/tst2' ot_username = client.read(vault)['data']['ot_username'].strip() ot_password = client.read(vault)['data']['ot_password'].strip() othost = client.read(vault)['data']['ot_host'].strip() ot_owo_path = client.read(vault)['data']['ot_owo_path'].strip() ot_aro_path = client.read(vault)['data']['ot_aro_path'].strip() ot_qgo_path = client.read(vault)['data']['ot_qgo_path'].strip() otpath1 = client.read(vault)['data']['ot_owo_path'].strip() create_connection(otsource, othost, ot_username,ot_password) print('Connection Established ',otsource) write_to_file('F',otsource) write_to_file('F','Connection Established') except: print ('Error in establishing the connection ', otsource) write_to_file('F',otsource) write_to_file('F','Error in Connection Established') sendEmail('E') paths = [ebspath1, otpath1,localfuspath,localfuspath3,ot_owo_path,ot_aro_path,ot_qgo_path] file_transfer(sl_cinfo, ot_cinfo, paths) sendEmail('S') write_to_file('F',"Email has been sent ") print ("Email has been sent ") timing=datetime.now() write_to_file('F',str(timing)) write_to_file('F','the logging has ended') write_to_file('F',"-------------------------------------------------------------------------------------------------------------") From torriem at gmail.com Wed Mar 11 00:06:30 2020 From: torriem at gmail.com (Michael Torrie) Date: Tue, 10 Mar 2020 22:06:30 -0600 Subject: Python question In-Reply-To: References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> <5d551551-b7e2-d3c5-e624-5d27751705b8@DancesWithMice.info> Message-ID: <387e5713-fcdb-6611-4a1c-fa9a7f8990c7@gmail.com> On 3/10/20 6:49 PM, Souvik Dutta wrote: > What about moving on to a social media app completely made in pythoj for > python? No thanks. I don't want to be on yet another web forum. I don't need "social media" or a "social media app." Email works exceedingly well for this sort of thing, despite Google's antics. Sadly a lot of open source projects are abandoning the good old list and moving to awkward web forums like Discourse. With e-mail lists, everything is right here in my email client (Thunderbird), separated out into folders with procmail (or whatever filtering system you want), and with proper nesting of messages. No web forum I've seen offers this convenience or proper nesting. Electronic communication is fraught enough. "Social media" (whatever that means) seems to just make it harder. From rhodri at kynesim.co.uk Wed Mar 11 10:03:47 2020 From: rhodri at kynesim.co.uk (Rhodri James) Date: Wed, 11 Mar 2020 14:03:47 +0000 Subject: Python question In-Reply-To: <387e5713-fcdb-6611-4a1c-fa9a7f8990c7@gmail.com> References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> <5d551551-b7e2-d3c5-e624-5d27751705b8@DancesWithMice.info> <387e5713-fcdb-6611-4a1c-fa9a7f8990c7@gmail.com> Message-ID: <0d44f894-dd2e-4bd2-8383-11aa69d93c6f@kynesim.co.uk> On 11/03/2020 04:06, Michael Torrie wrote: > On 3/10/20 6:49 PM, Souvik Dutta wrote: >> What about moving on to a social media app completely made in pythoj for >> python? > No thanks. I don't want to be on yet another web forum. I don't need > "social media" or a "social media app." Email works exceedingly well > for this sort of thing, despite Google's antics. +100000 The best response to "This system breaks when I abuse it" is almost always "Well stop abusing it then." -- Rhodri James *-* Kynesim Ltd From sonicsoul at gmail.com Wed Mar 11 10:30:35 2020 From: sonicsoul at gmail.com (Raf B) Date: Wed, 11 Mar 2020 07:30:35 -0700 (PDT) Subject: reactive programming use case Message-ID: <7ae01023-3129-45df-89aa-96f050204394@googlegroups.com> hi, i am thinking about using RxPy to solve the following problem, and not yet sure if its the right tool for the job. I am working on a calculation engine, that takes a dataset (or multiple sets) and calculates new columns. so in pandas terms, it starts as DataFrame, and then i run it through a set of calcs. which all add new columns to the frame, and in the end i use those columns to check my dataset for things such as minimum % of colA / ColX etc.. i was thinking about using reactive programming to: * decouple the dataset from running all the calculations * maybe help in making it more of a observable graph * combine datasets but maybe there is a better pattern? From robin at reportlab.com Wed Mar 11 11:26:44 2020 From: robin at reportlab.com (Robin Becker) Date: Wed, 11 Mar 2020 15:26:44 +0000 Subject: link to venv python sees a different sys.path Message-ID: <90991f4c-976f-37a3-7ecc-b7f8bbf414d4@everest.reportlab.co.uk> I'm trying to understand why python 3.8.2 venv behaves differently when it is executed va a link Make the env > rptlab at everest:~/code/hg-repos > $ python38 -mvenv __py__/382v > rptlab at everest:~/code/hg-repos make a link > $ ln -s ../__py__/382v/bin/python bin/python382v the venv sys.path > rptlab at everest:~/code/hg-repos > $ __py__/382v/bin/python -c"import sys;print('\n'.join(sys.path))" > > /home/rptlab/LOCAL/382/lib/python38.zip > /home/rptlab/LOCAL/382/lib/python3.8 > /home/rptlab/LOCAL/382/lib/python3.8/lib-dynload > /home/rptlab/code/hg-repos/__py__/382v/lib/python3.8/site-packages > rptlab at everest:~/code/hg-repos the linked python sys.path > $ bin/python382v -c"import sys;print('\n'.join(sys.path))" > > /home/rptlab/LOCAL/382/lib/python38.zip > /home/rptlab/LOCAL/382/lib/python3.8 > /home/rptlab/LOCAL/382/lib/python3.8/lib-dynload > /home/rptlab/LOCAL/382/lib/python3.8/site-packages > rptlab at everest:~/code/hg-repos > $ so the linked version of the venv python sees the base python site packages and not the expected venv site-packages. Is there a way to make the link work properly. This problem doesn't seem to occur with older virtualenv made environments. -- Robin Becker From jon+usenet at unequivocal.eu Wed Mar 11 12:23:46 2020 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Wed, 11 Mar 2020 16:23:46 -0000 (UTC) Subject: link to venv python sees a different sys.path References: <90991f4c-976f-37a3-7ecc-b7f8bbf414d4@everest.reportlab.co.uk> Message-ID: On 2020-03-11, Robin Becker wrote: > I'm trying to understand why python 3.8.2 venv behaves differently > when it is executed va a link Because site.py contains a function called venv() which looks up the path of the executed python binary, and searches for the virtual environment relative to that path. If you're executing the python binary via a link, it will look relative to the link, not the target of the link. > so the linked version of the venv python sees the base python site > packages and not the expected venv site-packages. > > Is there a way to make the link work properly. No. Unless you count making a shell script in the place you want which does nothing except exec the python binary inside the venv, i.e.: cat >pythonish #!/bin/sh exec some/other/python "$@" ^D From info at egenix.com Wed Mar 11 06:43:51 2020 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Wed, 11 Mar 2020 11:43:51 +0100 Subject: ANN: PyDDF Python Spring Sprint 2020 Message-ID: <6053ac5d-3539-fc07-007c-0162f246c16e@egenix.com> [This announcement is in German since it targets a local user group meeting in D?sseldorf, Germany] ________________________________________________________________________ ANK?NDIGUNG PyDDF Python Spring Sprint 2020 in D?sseldorf Samstag, 28.03.2020, 10:00-18:00 Uhr Sonntag, 29.03.2020, 10:00-18:00 Uhr trivago N.V., Kesselstrasse 5-7, 40221 D?sseldorf Python Meeting D?sseldorf https://www.pyddf.de/sprint2020/ ________________________________________________________________________ INFORMATION Das Python Meeting D?sseldorf (PyDDF) veranstaltet mit freundlicher Unterst?tzung der *trivago N.V.* ein Python Sprint Wochenende. Der Sprint findet am Wochenende 28./29.3.2020 in der trivago Niederlassung im Medienhafen D?sseldorf statt (Achtung: Nicht mehr am Karl-Arnold-Platz). * Google Maps: https://goo.gl/maps/dGM6ThfkLiJ2 Folgende Themengebiete haben wir als Anregung angedacht: * Matrix Protokoll - https://matrix.org * Aufzugssimulator * Wegeheld Nat?rlich kann jeder Teilnehmer weitere Themen vorschlagen. Alles weitere und die Anmeldung findet Ihr auf der Sprint Seite: https://www.pyddf.de/sprint2020/ WICHTIG: Ohne Anmeldung k?nnen wir kein Badge f?r den Geb?udezugang bereitstellen lassen. Eine spontane Anmeldung am Sprint Tag wird daher vermutlich nicht funktionieren. Also bitte unbedingt mit vollen Namen bis sp?testens Mittwoch, 25.03., anmelden. Teilnehmer sollten sich zudem auf der PyDDF Liste anmelden, da wir uns dort koordinieren: https://www.egenix.com/mailman/listinfo/pyddf ________________________________________________________________________ ?BER UNS Das Python Meeting D?sseldorf (PyDDF) ist eine regelm??ige Veranstaltung in D?sseldorf, die sich an Python Begeisterte aus der Region wendet: * https://pyddf.de/ Einen guten ?berblick ?ber die Vortr?ge bietet unser YouTube-Kanal, auf dem wir die Vortr?ge nach den Meetings ver?ffentlichen: * http://www.youtube.com/pyddf/ Veranstaltet wird das Meeting von der eGenix.com GmbH, Langenfeld,- in Zusammenarbeit mit Clark Consulting & Research, D?sseldorf: * http://www.egenix.com/ * http://www.clark-consulting.eu/ Mit freundlichen Gr??en, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Experts (#1, Mar 11 2020) >>> Python Projects, Coaching and Support ... https://www.egenix.com/ >>> Python Product Development ... https://consulting.egenix.com/ ________________________________________________________________________ ::: We implement business ideas - efficiently in both time and costs ::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 https://www.egenix.com/company/contact/ https://www.malemburg.com/ From grant.b.edwards at gmail.com Wed Mar 11 10:32:44 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Wed, 11 Mar 2020 14:32:44 -0000 (UTC) Subject: Python question References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> <5d551551-b7e2-d3c5-e624-5d27751705b8@DancesWithMice.info> <387e5713-fcdb-6611-4a1c-fa9a7f8990c7@gmail.com> Message-ID: On 2020-03-11, Michael Torrie wrote: > On 3/10/20 6:49 PM, Souvik Dutta wrote: >> What about moving on to a social media app completely made in pythoj for >> python? > > No thanks. I don't want to be on yet another web forum. I don't need > "social media" or a "social media app." Email works exceedingly well > for this sort of thing, despite Google's antics. For me, "news" works even better than email, which is why I read all my email lists via the gmane NNTP server using a news client (slrn). :) -- Grant Edwards grant.b.edwards Yow! Now I'm concentrating at on a specific tank battle gmail.com toward the end of World War II! From yon.goldschmidt at gmail.com Wed Mar 11 10:24:22 2020 From: yon.goldschmidt at gmail.com (Yonatan) Date: Wed, 11 Mar 2020 16:24:22 +0200 Subject: Lock acquisition by the same thread - deadlock protection In-Reply-To: <400BDCEC-04F7-482A-9165-2E342B0230AE@barrys-emacs.org> References: <20200309225302.GA22040@jong.localdomain> <400BDCEC-04F7-482A-9165-2E342B0230AE@barrys-emacs.org> Message-ID: That code I'm talking about didn't require a reentrant lock - the algorithm really wasn't reentrant. Let me clarify my point: I'm wondering why the non-reentrant lock doesn't raise an exception immediately on this erroneous situation. I thought it could be altered, or at least we could add an option to let a `threading.Lock` behave like a pthread mutex in mode `PTHREAD_MUTEX_ERRORCHECK`: Disallow double locking by same thread, disallow unlocking by another thread. However, after searching a bit more, I found a reference mentioning current behavior in a docstring defined in `_threadmodule.c`: "A lock is not owned by the thread that locked it; another thread may unlock it.". It was added in 75e9fc31d3a18068, a commit from 1998... Since it's a well-documented behavior I guess it's here to stay. At least the "unlock by another thread" part. But I question the double locking. On Tue, Mar 10, 2020 at 5:07 PM Barry Scott wrote: > > > > > On 9 Mar 2020, at 22:53, Yonatan Goldschmidt wrote: > > > > I recently debugged a program hang, eventually finding out it's a deadlock of a single thread, > > resulting from my usage of 2 libraries. One of them - call it library A - is reentrant & runs code in > > GC finalizers, while the other - library B - is not reentrant at all. > > Library B held one of its `threading.Lock` locks, and during this period, GC was invoked, running > > finalizers of library A which call back into library B, now attempting to take the lock again, > > locking the thread forever. > > > > Considering how relatively common this scenario might be (Python, by design, can preempt any user code > > to run some other user code, due to GC finalizers), I was surprised Python code is not protected > > from this simple type of deadlock. It makes sense that while `threading.RLock` allows for recursive > > locking, `threading.Lock` will prevent it - raising an exception if you attempt it. > > > > I might be missing something, but why isn't it the status? Why taking a `threading.Lock` twice from > > the same thread just hangs, instead of raising a friendly exception? > > I ran a quick search in bpo but found nothing about this topic. I also tried to > > search this mailing list but couldn't find how to, so I grepped a few random archives > > but found nothing about it. > > > > Would be happy if anyone could shed some light on it... > > threading.Lock is not reentrant and its implementation does not allow detection of the problem > from what I recall. > > In this case the code might want to use the threading.RLock that is reentrant. > Of course there may be other issues in the code that prevent the finalizers working if it holds the lock. > > Barry > > > From dieter at handshake.de Wed Mar 11 13:24:31 2020 From: dieter at handshake.de (Dieter Maurer) Date: Wed, 11 Mar 2020 18:24:31 +0100 Subject: link to venv python sees a different sys.path In-Reply-To: <90991f4c-976f-37a3-7ecc-b7f8bbf414d4@everest.reportlab.co.uk> References: <90991f4c-976f-37a3-7ecc-b7f8bbf414d4@everest.reportlab.co.uk> Message-ID: <24169.7887.598821.319553@ixdm.fritz.box> Robin Becker wrote at 2020-3-11 15:26 +0000: >I'm trying to understand why python 3.8.2 venv behaves differently when it is executed va a link > >Make the env >> rptlab at everest:~/code/hg-repos >> $ python38 -mvenv __py__/382v >> rptlab at everest:~/code/hg-repos > >make a link >> $ ln -s ../__py__/382v/bin/python bin/python382v > >the venv sys.path >> rptlab at everest:~/code/hg-repos > $ __py__/382v/bin/python -c"import sys;print('\n'.join(sys.path))" >> >> /home/rptlab/LOCAL/382/lib/python38.zip >> /home/rptlab/LOCAL/382/lib/python3.8 >> /home/rptlab/LOCAL/382/lib/python3.8/lib-dynload >> /home/rptlab/code/hg-repos/__py__/382v/lib/python3.8/site-packages >> rptlab at everest:~/code/hg-repos > >the linked python sys.path >> $ bin/python382v -c"import sys;print('\n'.join(sys.path))" >> >> /home/rptlab/LOCAL/382/lib/python38.zip >> /home/rptlab/LOCAL/382/lib/python3.8 >> /home/rptlab/LOCAL/382/lib/python3.8/lib-dynload >> /home/rptlab/LOCAL/382/lib/python3.8/site-packages >> rptlab at everest:~/code/hg-repos >> $ > >so the linked version of the venv python sees the base python site packages and not the expected venv site-packages. I guess (!) that it is using the path to the interpreter program in order to locate the venv's "site-packages" and falls back to the system's when this is not possible. If my guess is correct, then some links will not work. But, you should be able to use links which find "site-packages" via "/../lib/python/site-packages". From dieter at handshake.de Wed Mar 11 13:26:24 2020 From: dieter at handshake.de (Dieter Maurer) Date: Wed, 11 Mar 2020 18:26:24 +0100 Subject: Issue with PYSFTP - Working in WINSCP In-Reply-To: References: Message-ID: <24169.8000.440109.342789@ixdm.fritz.box> NAND KISHORE wrote at 2020-3-10 20:20 -0500: > We have requirement where we need to get file from client path and then >upload the same to vendor directory path. I am not able to upload the file >to vendor directory path , however when I tried to use the WINSCP it worked >fine. So I thought of checking with Gurus what is wrong I am doing in my >script. Appreciate your input. >I will attach my script. Here is what I am doing. > ... >Also below is the error which I am getting > >--------------------------------------------------------- >ERROR:root:Error in getting the file from EBS Outbound Server >Traceback (most recent call last): > ... > File >"/d01/python3/lib64/python3.6/site-packages/paramiko/sftp_client.py", line >894, in _convert_status > raise IOError(errno.ENOENT, text) >FileNotFoundError: [Errno 2] /custom/OWO/ECE_OWO_20200303_143895.dat This error message tells you that "/customOWO/ECE_OWO_20200303_143895.dat" does not exist. Are you sure that this is the correct filename? Especially, the leading "/" looks wrong. From barry at barrys-emacs.org Wed Mar 11 17:37:36 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Wed, 11 Mar 2020 21:37:36 +0000 Subject: Lock acquisition by the same thread - deadlock protection In-Reply-To: References: <20200309225302.GA22040@jong.localdomain> <400BDCEC-04F7-482A-9165-2E342B0230AE@barrys-emacs.org> Message-ID: <861D82C2-1736-4F05-9DF2-A4BFD2DE2C99@barrys-emacs.org> > On 11 Mar 2020, at 14:24, Yonatan wrote: > > That code I'm talking about didn't require a reentrant lock - the > algorithm really wasn't reentrant. > > Let me clarify my point: I'm wondering why the non-reentrant lock > doesn't raise an exception immediately on this > erroneous situation. > I thought it could be altered, or at least we could add an option to > let a `threading.Lock` behave like a pthread > mutex in mode `PTHREAD_MUTEX_ERRORCHECK`: Disallow double locking by > same thread, disallow unlocking > by another thread. > However, after searching a bit more, I found a reference mentioning > current behavior in a docstring defined > in `_threadmodule.c`: "A lock is not owned by the thread that locked > it; another thread may unlock it.". > It was added in 75e9fc31d3a18068, a commit from 1998... > > Since it's a well-documented behavior I guess it's here to stay. At > least the "unlock by another thread" part. > But I question the double locking. Reading the CPYTHON code I find that the type of mutex is NORMAL and man pthread_mutex_lock documents that it will deadlock if the same thread calls lock a second time. This is what you are seeing it seems. The code I found was in ./Python/thread_pthread.h Sounds to me like the library has a bug in its locking. Getting a exception would help track down the bug faster. But still sounds like a bug. It used to be the case that using the NORMAL locks was higher performance then the ERRORCHECK or RECURSIVE locks. No idea if this is still true of that it matters for cpython. Maybe changing from NORMAL to ERRORCHECK would be a benefit. Barry > > > On Tue, Mar 10, 2020 at 5:07 PM Barry Scott wrote: >> >> >> >>> On 9 Mar 2020, at 22:53, Yonatan Goldschmidt wrote: >>> >>> I recently debugged a program hang, eventually finding out it's a deadlock of a single thread, >>> resulting from my usage of 2 libraries. One of them - call it library A - is reentrant & runs code in >>> GC finalizers, while the other - library B - is not reentrant at all. >>> Library B held one of its `threading.Lock` locks, and during this period, GC was invoked, running >>> finalizers of library A which call back into library B, now attempting to take the lock again, >>> locking the thread forever. >>> >>> Considering how relatively common this scenario might be (Python, by design, can preempt any user code >>> to run some other user code, due to GC finalizers), I was surprised Python code is not protected >>> from this simple type of deadlock. It makes sense that while `threading.RLock` allows for recursive >>> locking, `threading.Lock` will prevent it - raising an exception if you attempt it. >>> >>> I might be missing something, but why isn't it the status? Why taking a `threading.Lock` twice from >>> the same thread just hangs, instead of raising a friendly exception? >>> I ran a quick search in bpo but found nothing about this topic. I also tried to >>> search this mailing list but couldn't find how to, so I grepped a few random archives >>> but found nothing about it. >>> >>> Would be happy if anyone could shed some light on it... >> >> threading.Lock is not reentrant and its implementation does not allow detection of the problem >> from what I recall. >> >> In this case the code might want to use the threading.RLock that is reentrant. >> Of course there may be other issues in the code that prevent the finalizers working if it holds the lock. >> >> Barry >> >> >> > From goluhng at gmail.com Wed Mar 11 17:09:49 2020 From: goluhng at gmail.com (Go Luhng) Date: Wed, 11 Mar 2020 17:09:49 -0400 Subject: Is there a Python profiler that preserves function arguments? Message-ID: I'm profiling a Python function `foo()` that takes a single argument, but that argument makes a huge difference in what the function actually does. Currently I'm using `cProfile`, which records every call to `foo()` as if it was the same, preventing me from figuring out what's going on. Is there a way to get `cProfile`, or any other Python profiler, to preserve function call arguments, so when I look at the call stack later (especially using a visualizer like SnakeViz) I can distinguish between `foo('bar')` and `foo('qux')`? P.S. arguably this is a code design issue: since `foo('bar')` and `foo('qux')` do very different things, they should be distinctly-named separate functions, like `foo_bar()` and `foo_qux()`. However, the question is whether I can profile them as-is, without refactoring. From PythonList at DancesWithMice.info Wed Mar 11 22:47:23 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 12 Mar 2020 15:47:23 +1300 Subject: Python question In-Reply-To: <0d44f894-dd2e-4bd2-8383-11aa69d93c6f@kynesim.co.uk> References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> <5d551551-b7e2-d3c5-e624-5d27751705b8@DancesWithMice.info> <387e5713-fcdb-6611-4a1c-fa9a7f8990c7@gmail.com> <0d44f894-dd2e-4bd2-8383-11aa69d93c6f@kynesim.co.uk> Message-ID: <07a6b774-8c2c-a3ed-cea4-982fabc9b73e@DancesWithMice.info> On 12/03/20 3:03 AM, Rhodri James wrote: > On 11/03/2020 04:06, Michael Torrie wrote: >> On 3/10/20 6:49 PM, Souvik Dutta wrote: >>> What about moving on to a social media app completely made in pythoj for >>> python? >> No thanks. I don't want to be on yet another web forum.? I don't need >> "social media" or a "social media app."? Email works exceedingly well >> for this sort of thing, despite Google's antics. > > +100000 > > The best response to "This system breaks when I abuse it" is almost > always "Well stop abusing it then." +1 Didn't someone once claim "do no harm"? There are two sides to every story! Rather than changing the (Discussion List) server, which affects everyone; ask those who don't like Google's tactics/behavior to change their (email) client! -- Regards =dn From miked at dewhirst.com.au Thu Mar 12 03:15:04 2020 From: miked at dewhirst.com.au (Mike Dewhirst) Date: Thu, 12 Mar 2020 18:15:04 +1100 Subject: Python question In-Reply-To: <07a6b774-8c2c-a3ed-cea4-982fabc9b73e@DancesWithMice.info> References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> <5d551551-b7e2-d3c5-e624-5d27751705b8@DancesWithMice.info> <387e5713-fcdb-6611-4a1c-fa9a7f8990c7@gmail.com> <0d44f894-dd2e-4bd2-8383-11aa69d93c6f@kynesim.co.uk> <07a6b774-8c2c-a3ed-cea4-982fabc9b73e@DancesWithMice.info> Message-ID: <75050ff1-5db0-925f-c85b-792998810ebc@dewhirst.com.au> On 12/03/2020 1:47 pm, DL Neil via Python-list wrote: > On 12/03/20 3:03 AM, Rhodri James wrote: >> On 11/03/2020 04:06, Michael Torrie wrote: >>> On 3/10/20 6:49 PM, Souvik Dutta wrote: >>>> What about moving on to a social media app completely made in >>>> pythoj for >>>> python? >>> No thanks. I don't want to be on yet another web forum.? I don't need >>> "social media" or a "social media app."? Email works exceedingly well >>> for this sort of thing, despite Google's antics. >> >> +100000 >> >> The best response to "This system breaks when I abuse it" is almost >> always "Well stop abusing it then." > > > +1 > > Didn't someone once claim "do no harm"? > > There are two sides to every story! Rather than changing the > (Discussion List) server, which affects everyone; ask those who don't > like Google's tactics/behavior to change their (email) client! > I agree email is better than social media, but I suspect Souvik was merely expressing a desire to do something in Python since this is a Python list. That's the motivation of a Python enthusiast and perhaps should be encouraged. From souvik.viksou at gmail.com Thu Mar 12 04:18:26 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Thu, 12 Mar 2020 13:48:26 +0530 Subject: Python question In-Reply-To: <75050ff1-5db0-925f-c85b-792998810ebc@dewhirst.com.au> References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> <5d551551-b7e2-d3c5-e624-5d27751705b8@DancesWithMice.info> <387e5713-fcdb-6611-4a1c-fa9a7f8990c7@gmail.com> <0d44f894-dd2e-4bd2-8383-11aa69d93c6f@kynesim.co.uk> <07a6b774-8c2c-a3ed-cea4-982fabc9b73e@DancesWithMice.info> <75050ff1-5db0-925f-c85b-792998810ebc@dewhirst.com.au> Message-ID: Ya at least I thought that. On Thu, Mar 12, 2020, 12:45 PM Mike Dewhirst wrote: > On 12/03/2020 1:47 pm, DL Neil via Python-list wrote: > > On 12/03/20 3:03 AM, Rhodri James wrote: > >> On 11/03/2020 04:06, Michael Torrie wrote: > >>> On 3/10/20 6:49 PM, Souvik Dutta wrote: > >>>> What about moving on to a social media app completely made in > >>>> pythoj for > >>>> python? > >>> No thanks. I don't want to be on yet another web forum. I don't need > >>> "social media" or a "social media app." Email works exceedingly well > >>> for this sort of thing, despite Google's antics. > >> > >> +100000 > >> > >> The best response to "This system breaks when I abuse it" is almost > >> always "Well stop abusing it then." > > > > > > +1 > > > > Didn't someone once claim "do no harm"? > > > > There are two sides to every story! Rather than changing the > > (Discussion List) server, which affects everyone; ask those who don't > > like Google's tactics/behavior to change their (email) client! > > > > I agree email is better than social media, but I suspect Souvik was > merely expressing a desire to do something in Python since this is a > Python list. That's the motivation of a Python enthusiast and perhaps > should be encouraged. > > > > > > > -- > https://mail.python.org/mailman/listinfo/python-list > From robin at reportlab.com Thu Mar 12 05:07:49 2020 From: robin at reportlab.com (Robin Becker) Date: Thu, 12 Mar 2020 09:07:49 +0000 Subject: link to venv python sees a different sys.path In-Reply-To: <24169.7887.598821.319553@ixdm.fritz.box> References: <90991f4c-976f-37a3-7ecc-b7f8bbf414d4@everest.reportlab.co.uk> <24169.7887.598821.319553@ixdm.fritz.box> Message-ID: <4f670f47-12bb-8673-bc90-8d9078a2c37b@everest.reportlab.co.uk> On 11/03/2020 17:24, Dieter Maurer wrote: > Robin Becker wrote at 2020-3-11 15:26 +0000: >> I'm trying to understand why python 3.8.2 venv behaves differently when it is executed va a link >> >> Make the env >>> rptlab at everest:~/code/hg-repos >>> $ python38 -mvenv __py__/382v ........... >> >> so the linked version of the venv python sees the base python site packages and not the expected venv site-packages. > > I guess (!) that it is using the path to the interpreter program > in order to locate the venv's "site-packages" and falls back to > the system's when this is not possible. > > If my guess is correct, then some links will not work. > But, you should be able to use links which find > "site-packages" via "/../lib/python/site-packages". > Not sure I understand exactly what you are getting at, but a workaround is presumably feasible in any particular script. The documentation says "You don?t specifically need to activate an environment; activation just prepends the virtual environment?s binary directory to your path, so that ?python? invokes the virtual environment?s Python interpreter and you can run installed scripts without having to use their full path. However, all scripts installed in a virtual environment should be runnable without activating it, and run with the virtual environment?s Python automatically." I am not running an installed script, but the actual python, however with venv this is just a link to the base python. It seems as though the above doesn't apply to the python itself which seems kind of dumb. A quick check reveals that the documentation later which says "When a virtual environment is active (i.e., the virtual environment?s Python interpreter is running), the attributes sys.prefix and sys.exec_prefix point to the base directory of the virtual environment, whereas sys.base_prefix and sys.base_exec_prefix point to the non-virtual environment Python installation which was used to create the virtual environment. If a virtual environment is not active, then sys.prefix is the same as sys.base_prefix and sys.exec_prefix is the same as sys.base_exec_prefix (they all point to a non-virtual environment Python installation)." is wrong as if you invoke the env/bin/python directly it does change the sys_exec prefix even though the virtual environment is not 'active'. > $ __py__/382v/bin/python -c"import sys;print(sys.exec_prefix)" > /home/rptlab/code/hg-repos/__py__/382v whereas that's not the case when invoked via a link > $ bin/python382v -c"import sys;print(sys.exec_prefix)" > /home/rptlab/bin/../LOCAL/382 I guess the problem is that the venv python itself is just a link to the base python whereas the virtualenv pythons are actual copies of base so presumably know where they live. I guess I'll continue to use an older mechanism that works for me. -- Robin Becker From dieter at handshake.de Thu Mar 12 05:19:08 2020 From: dieter at handshake.de (Dieter Maurer) Date: Thu, 12 Mar 2020 10:19:08 +0100 Subject: link to venv python sees a different sys.path In-Reply-To: <4f670f47-12bb-8673-bc90-8d9078a2c37b@everest.reportlab.co.uk> References: <90991f4c-976f-37a3-7ecc-b7f8bbf414d4@everest.reportlab.co.uk> <24169.7887.598821.319553@ixdm.fritz.box> <4f670f47-12bb-8673-bc90-8d9078a2c37b@everest.reportlab.co.uk> Message-ID: <24169.65164.406204.979561@ixdm.fritz.box> Robin Becker wrote at 2020-3-12 09:07 +0000: >On 11/03/2020 17:24, Dieter Maurer wrote: >> Robin Becker wrote at 2020-3-11 15:26 +0000: >>> I'm trying to understand why python 3.8.2 venv behaves differently when it is executed va a link >>> >>> Make the env >>>> rptlab at everest:~/code/hg-repos >>>> $ python38 -mvenv __py__/382v >........... >>> >>> so the linked version of the venv python sees the base python site packages and not the expected venv site-packages. >> >> I guess (!) that it is using the path to the interpreter program >> in order to locate the venv's "site-packages" and falls back to >> the system's when this is not possible. >> >> If my guess is correct, then some links will not work. >> But, you should be able to use links which find >> "site-packages" via "/../lib/python/site-packages". >> >Not sure I understand exactly what you are getting at, but a workaround is presumably feasible in any particular script. > >The documentation says > >"You don?t specifically need to activate an environment; activation just prepends the virtual environment?s binary >directory to your path, so that ?python? invokes the virtual environment?s Python interpreter and you can run installed >scripts without having to use their full path. However, all scripts installed in a virtual environment should be >runnable without activating it, and run with the virtual environment?s Python automatically." > >I am not running an installed script, but the actual python, however with venv this is just a link to the base python. > >It seems as though the above doesn't apply to the python itself which seems kind of dumb. A quick check reveals that the >documentation later which says Let me try again: When you start "python", its "site" module extends "sys.path" to include an appropriate "site-packages". For this, it uses a heuristic based on the path with which you have called the interpreter: i.e. it tries to use dirname()/../lib/python/site-packages If this does not exist, it falls back to the base interpreter' "site-packages". This works fine when you do not use symbolic links. It can work when your symbolic links do not let the heuristic fail. As you have observed, some kind of symbolic links break it, however. From robin at reportlab.com Thu Mar 12 06:25:21 2020 From: robin at reportlab.com (Robin Becker) Date: Thu, 12 Mar 2020 10:25:21 +0000 Subject: link to venv python sees a different sys.path In-Reply-To: <24169.65164.406204.979561@ixdm.fritz.box> References: <90991f4c-976f-37a3-7ecc-b7f8bbf414d4@everest.reportlab.co.uk> <24169.7887.598821.319553@ixdm.fritz.box> <4f670f47-12bb-8673-bc90-8d9078a2c37b@everest.reportlab.co.uk> <24169.65164.406204.979561@ixdm.fritz.box> Message-ID: <294865b9-5526-58e4-18c2-cde484566ff6@everest.reportlab.co.uk> On 12/03/2020 09:19, Dieter Maurer wrote: ........ > > Let me try again: > > When you start "python", its "site" module extends "sys.path" > to include an appropriate "site-packages". > For this, it uses a heuristic based on the path with which you > have called the interpreter: i.e. it tries to use > dirname()/../lib/python/site-packages > If this does not exist, it falls back to the base interpreter' "site-packages". > > This works fine when you do not use symbolic links. > It can work when your symbolic links do not let the heuristic fail. > As you have observed, some kind of symbolic links break it, however. > Ok I see what you are getting at. However, this sort of defeats the purpose of virtual environments for my case ie when I want many different versions of python all in one place to use for testing. It's fairly clear that links to links to links make it quite hard to decide where the real environment is. However, since the virtual environment does have a lib parallel to the bin it ought not to be impossible. I can continue to use the 'legacy' version of virtualenv, but it seems as though the latest virtualenv (20.0.8) has changed something and its linked python now has the same behaviour as the venv version even when the --copies option is used. -- Robin Becker From joepareti54 at gmail.com Thu Mar 12 06:54:51 2020 From: joepareti54 at gmail.com (joseph pareti) Date: Thu, 12 Mar 2020 11:54:51 +0100 Subject: using classes Message-ID: The following code that uses a class 'Fahrzeug' and an inherited class 'PKW' runs correctly. However, if I use the 'super ' statement in in the PKW class, it ends with the following error message: *Traceback (most recent call last): File "erben_a.py", line 19, in fiat = PKW("Fiat Marea",50,0) File "erben_a.py", line 11, in __init__ super(PKW, self).__init__()TypeError: __init__() missing 2 required positional arguments: 'bez' and 'ge'* ----- CODE THAT WORKS ------- class Fahrzeug: def __init__(self, bez, ge): self.bezeichnung = bez self.geschwindigkeit = ge def beschleunigen(self, wert): self.geschwindigkeit += wert def __str__(self): return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h" class PKW(Fahrzeug): def __init__(self, bez, ge, ins): Fahrzeug.__init__(self, bez, ge) self.insassen = ins def __str__(self): return Fahrzeug.__str__(self) + " " + str(self.insassen) + " Insassen" def einsteigen(self, anzahl): self.insassen += anzahl def aussteigen(self, anzahl): self.insassen -= anzahl fiat = PKW("Fiat Marea",50,0) fiat.einsteigen(3) fiat.aussteigen(1) fiat.beschleunigen(10) print(fiat) -----CODE THAT FAILS -------------- class Fahrzeug: def __init__(self, bez, ge): self.bezeichnung = bez self.geschwindigkeit = ge def beschleunigen(self, wert): self.geschwindigkeit += wert def __str__(self): return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h" class PKW(Fahrzeug): def __init__(self, bez, ge, ins): *super(PKW, self).__init__()* self.insassen = ins def __str__(self): return Fahrzeug.__str__(self) + " " + str(self.insassen) + " Insassen" def einsteigen(self, anzahl): self.insassen += anzahl def aussteigen(self, anzahl): self.insassen -= anzahl fiat = PKW("Fiat Marea",50,0) fiat.einsteigen(3) fiat.aussteigen(1) fiat.beschleunigen(10) print(fiat) -- Regards, Joseph Pareti - Artificial Intelligence consultant Joseph Pareti's AI Consulting Services https://www.joepareti54-ai.com/ cell +49 1520 1600 209 cell +39 339 797 0644 From dieter at handshake.de Thu Mar 12 06:59:19 2020 From: dieter at handshake.de (Dieter Maurer) Date: Thu, 12 Mar 2020 11:59:19 +0100 Subject: link to venv python sees a different sys.path In-Reply-To: <294865b9-5526-58e4-18c2-cde484566ff6@everest.reportlab.co.uk> References: <90991f4c-976f-37a3-7ecc-b7f8bbf414d4@everest.reportlab.co.uk> <24169.7887.598821.319553@ixdm.fritz.box> <4f670f47-12bb-8673-bc90-8d9078a2c37b@everest.reportlab.co.uk> <24169.65164.406204.979561@ixdm.fritz.box> <294865b9-5526-58e4-18c2-cde484566ff6@everest.reportlab.co.uk> Message-ID: <24170.5639.65174.932931@ixdm.fritz.box> Robin Becker wrote at 2020-3-12 10:25 +0000: > ... >I want many different versions of python all in one place to use for testing. I contribute to the `zopefoundation` projects. They, too, have a need to test with many different Python versions -- and use "tox" for it. Maybe, "tox" can also help solve your problem (without a need for symbolic links). From python at mrabarnett.plus.com Thu Mar 12 07:54:29 2020 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 12 Mar 2020 11:54:29 +0000 Subject: using classes In-Reply-To: References: Message-ID: On 2020-03-12 10:54, joseph pareti wrote: > The following code that uses a class 'Fahrzeug' and an inherited class > 'PKW' runs correctly. However, if I use the 'super ' statement in in the > PKW class, it ends with the following error message: > > > > *Traceback (most recent call last): File "erben_a.py", line 19, in > fiat = PKW("Fiat Marea",50,0) File "erben_a.py", line 11, in > __init__ super(PKW, self).__init__()TypeError: __init__() missing 2 > required positional arguments: 'bez' and 'ge'* > > ----- CODE THAT WORKS ------- > class Fahrzeug: > def __init__(self, bez, ge): > self.bezeichnung = bez > self.geschwindigkeit = ge > def beschleunigen(self, wert): > self.geschwindigkeit += wert > def __str__(self): > return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h" > class PKW(Fahrzeug): > def __init__(self, bez, ge, ins): > Fahrzeug.__init__(self, bez, ge) > self.insassen = ins > def __str__(self): > return Fahrzeug.__str__(self) + " " + str(self.insassen) + " > Insassen" > def einsteigen(self, anzahl): > self.insassen += anzahl > def aussteigen(self, anzahl): > self.insassen -= anzahl > fiat = PKW("Fiat Marea",50,0) > fiat.einsteigen(3) > fiat.aussteigen(1) > fiat.beschleunigen(10) > print(fiat) > > -----CODE THAT FAILS -------------- > class Fahrzeug: > def __init__(self, bez, ge): > self.bezeichnung = bez > self.geschwindigkeit = ge > def beschleunigen(self, wert): > self.geschwindigkeit += wert > def __str__(self): > return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h" > class PKW(Fahrzeug): > def __init__(self, bez, ge, ins): > *super(PKW, self).__init__()* > self.insassen = ins > def __str__(self): > return Fahrzeug.__str__(self) + " " + str(self.insassen) + " > Insassen" > def einsteigen(self, anzahl): > self.insassen += anzahl > def aussteigen(self, anzahl): > self.insassen -= anzahl > fiat = PKW("Fiat Marea",50,0) > fiat.einsteigen(3) > fiat.aussteigen(1) > fiat.beschleunigen(10) > print(fiat) > > The traceback tells you what the problem is. The line should be: super(PKW, self).__init__(bez, ge) From joepareti54 at gmail.com Thu Mar 12 10:25:39 2020 From: joepareti54 at gmail.com (joseph pareti) Date: Thu, 12 Mar 2020 15:25:39 +0100 Subject: using classes In-Reply-To: References: Message-ID: thank you, that fixes it. I also noticed that both statements work: super(PKW, self).__init__(bez,ge) or super().__init__(bez,ge) Am Do., 12. M?rz 2020 um 12:58 Uhr schrieb MRAB : > On 2020-03-12 10:54, joseph pareti wrote: > > The following code that uses a class 'Fahrzeug' and an inherited class > > 'PKW' runs correctly. However, if I use the 'super ' statement in in the > > PKW class, it ends with the following error message: > > > > > > > > *Traceback (most recent call last): File "erben_a.py", line 19, in > > fiat = PKW("Fiat Marea",50,0) File "erben_a.py", line 11, in > > __init__ super(PKW, self).__init__()TypeError: __init__() missing 2 > > required positional arguments: 'bez' and 'ge'* > > > > ----- CODE THAT WORKS ------- > > class Fahrzeug: > > def __init__(self, bez, ge): > > self.bezeichnung = bez > > self.geschwindigkeit = ge > > def beschleunigen(self, wert): > > self.geschwindigkeit += wert > > def __str__(self): > > return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h" > > class PKW(Fahrzeug): > > def __init__(self, bez, ge, ins): > > Fahrzeug.__init__(self, bez, ge) > > self.insassen = ins > > def __str__(self): > > return Fahrzeug.__str__(self) + " " + str(self.insassen) + " > > Insassen" > > def einsteigen(self, anzahl): > > self.insassen += anzahl > > def aussteigen(self, anzahl): > > self.insassen -= anzahl > > fiat = PKW("Fiat Marea",50,0) > > fiat.einsteigen(3) > > fiat.aussteigen(1) > > fiat.beschleunigen(10) > > print(fiat) > > > > -----CODE THAT FAILS -------------- > > class Fahrzeug: > > def __init__(self, bez, ge): > > self.bezeichnung = bez > > self.geschwindigkeit = ge > > def beschleunigen(self, wert): > > self.geschwindigkeit += wert > > def __str__(self): > > return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h" > > class PKW(Fahrzeug): > > def __init__(self, bez, ge, ins): > > *super(PKW, self).__init__()* > > self.insassen = ins > > def __str__(self): > > return Fahrzeug.__str__(self) + " " + str(self.insassen) + " > > Insassen" > > def einsteigen(self, anzahl): > > self.insassen += anzahl > > def aussteigen(self, anzahl): > > self.insassen -= anzahl > > fiat = PKW("Fiat Marea",50,0) > > fiat.einsteigen(3) > > fiat.aussteigen(1) > > fiat.beschleunigen(10) > > print(fiat) > > > > > The traceback tells you what the problem is. The line should be: > > super(PKW, self).__init__(bez, ge) > -- > https://mail.python.org/mailman/listinfo/python-list > -- Regards, Joseph Pareti - Artificial Intelligence consultant Joseph Pareti's AI Consulting Services https://www.joepareti54-ai.com/ cell +49 1520 1600 209 cell +39 339 797 0644 From torriem at gmail.com Thu Mar 12 11:57:15 2020 From: torriem at gmail.com (Michael Torrie) Date: Thu, 12 Mar 2020 09:57:15 -0600 Subject: Python question In-Reply-To: <07a6b774-8c2c-a3ed-cea4-982fabc9b73e@DancesWithMice.info> References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> <5d551551-b7e2-d3c5-e624-5d27751705b8@DancesWithMice.info> <387e5713-fcdb-6611-4a1c-fa9a7f8990c7@gmail.com> <0d44f894-dd2e-4bd2-8383-11aa69d93c6f@kynesim.co.uk> <07a6b774-8c2c-a3ed-cea4-982fabc9b73e@DancesWithMice.info> Message-ID: On 3/11/20 8:47 PM, DL Neil via Python-list wrote: > Didn't someone once claim "do no harm"? > > There are two sides to every story! Rather than changing the (Discussion > List) server, which affects everyone; ask those who don't like Google's > tactics/behavior to change their (email) client! In Gmail's case it's a matter of not using gmail at all, as their mailing list -breaking behavior happens whether you use IMAP and thunderbird. I work around gmail's breakage right now by using my own SMTP server for sending messages to the list, so gmail won't recognize my messages and discard them. I could leave gmail, but it's not worth it for me at this point. Python is the only mailing list left of all the open source projects I used to follow. It's pretty sad how they all abandoned a format that works very well for web based formats. From barry at barrys-emacs.org Thu Mar 12 12:27:59 2020 From: barry at barrys-emacs.org (Barry) Date: Thu, 12 Mar 2020 16:27:59 +0000 Subject: using classes In-Reply-To: References: Message-ID: > On 12 Mar 2020, at 14:28, joseph pareti wrote: > > ?thank you, that fixes it. I also noticed that both statements work: > > super(PKW, self).__init__(bez,ge) This form is for python 2 compatibility. > > or > > super().__init__(bez,ge) This is the python 3 way. If you do not have to care about python 2 then this is the form to use. Barry > >> Am Do., 12. M?rz 2020 um 12:58 Uhr schrieb MRAB >> : >> >>> On 2020-03-12 10:54, joseph pareti wrote: >>> The following code that uses a class 'Fahrzeug' and an inherited class >>> 'PKW' runs correctly. However, if I use the 'super ' statement in in the >>> PKW class, it ends with the following error message: >>> >>> >>> >>> *Traceback (most recent call last): File "erben_a.py", line 19, in >>> fiat = PKW("Fiat Marea",50,0) File "erben_a.py", line 11, in >>> __init__ super(PKW, self).__init__()TypeError: __init__() missing 2 >>> required positional arguments: 'bez' and 'ge'* >>> >>> ----- CODE THAT WORKS ------- >>> class Fahrzeug: >>> def __init__(self, bez, ge): >>> self.bezeichnung = bez >>> self.geschwindigkeit = ge >>> def beschleunigen(self, wert): >>> self.geschwindigkeit += wert >>> def __str__(self): >>> return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h" >>> class PKW(Fahrzeug): >>> def __init__(self, bez, ge, ins): >>> Fahrzeug.__init__(self, bez, ge) >>> self.insassen = ins >>> def __str__(self): >>> return Fahrzeug.__str__(self) + " " + str(self.insassen) + " >>> Insassen" >>> def einsteigen(self, anzahl): >>> self.insassen += anzahl >>> def aussteigen(self, anzahl): >>> self.insassen -= anzahl >>> fiat = PKW("Fiat Marea",50,0) >>> fiat.einsteigen(3) >>> fiat.aussteigen(1) >>> fiat.beschleunigen(10) >>> print(fiat) >>> >>> -----CODE THAT FAILS -------------- >>> class Fahrzeug: >>> def __init__(self, bez, ge): >>> self.bezeichnung = bez >>> self.geschwindigkeit = ge >>> def beschleunigen(self, wert): >>> self.geschwindigkeit += wert >>> def __str__(self): >>> return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h" >>> class PKW(Fahrzeug): >>> def __init__(self, bez, ge, ins): >>> *super(PKW, self).__init__()* >>> self.insassen = ins >>> def __str__(self): >>> return Fahrzeug.__str__(self) + " " + str(self.insassen) + " >>> Insassen" >>> def einsteigen(self, anzahl): >>> self.insassen += anzahl >>> def aussteigen(self, anzahl): >>> self.insassen -= anzahl >>> fiat = PKW("Fiat Marea",50,0) >>> fiat.einsteigen(3) >>> fiat.aussteigen(1) >>> fiat.beschleunigen(10) >>> print(fiat) >>> >>> >> The traceback tells you what the problem is. The line should be: >> >> super(PKW, self).__init__(bez, ge) >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > > -- > Regards, > Joseph Pareti - Artificial Intelligence consultant > Joseph Pareti's AI Consulting Services > https://www.joepareti54-ai.com/ > cell +49 1520 1600 209 > cell +39 339 797 0644 > -- > https://mail.python.org/mailman/listinfo/python-list From pieter-l at vanoostrum.org Thu Mar 12 12:34:14 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Thu, 12 Mar 2020 17:34:14 +0100 Subject: using classes References: Message-ID: joseph pareti writes: > thank you, that fixes it. I also noticed that both statements work: > > super(PKW, self).__init__(bez,ge) > > or > > super().__init__(bez,ge) The first is the required Python 2 calling (at least the first argument is required). The second way can be used in Python 3. -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From stephen_tucker at sil.org Thu Mar 12 13:53:39 2020 From: stephen_tucker at sil.org (Stephen Tucker) Date: Thu, 12 Mar 2020 17:53:39 +0000 Subject: Multiple comparisons in a single statement Message-ID: A quickie (I hope!). I am running Python 2.7.10 (and, yes, I know, support for it has been withdrawn.) I have three tuples that have been generated separately and I want to check that they are identical. all I want to do is to terminate the program and report an error if all three are not identical. My initial attempt to do this is to use logic of the form if not (mytup1 == mytup2 == mytup3): raise Exception ("Tuples are not identical") I have tried this logic form in IDLE, and it seems to do what I want. Is this a reasonable way to do this, or is there a better way? Thanks in anticipation. Stephen Tucker. Virus-free. www.avast.com <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> From rosuav at gmail.com Thu Mar 12 14:08:31 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 13 Mar 2020 05:08:31 +1100 Subject: Multiple comparisons in a single statement In-Reply-To: References: Message-ID: On Fri, Mar 13, 2020 at 4:55 AM Stephen Tucker wrote: > > A quickie (I hope!). > > I am running Python 2.7.10 (and, yes, I know, support for it has been > withdrawn.) This is the same in Python 3. > I have three tuples that have been generated separately and I want to check > that they are identical. all I want to do is to terminate the program and > report an error if all three are not identical. > > My initial attempt to do this is to use logic of the form > > if not (mytup1 == mytup2 == mytup3): > raise Exception ("Tuples are not identical") > > I have tried this logic form in IDLE, and it seems to do what I want. > > Is this a reasonable way to do this, or is there a better way? > Yes absolutely! (Although, as a minor quibble, I would say "equal" rather than "identical" here - when you talk about identity, you're usually using the 'is' operator.) The meaning of chained comparisons is broadly equivalent to comparing the middle one against the others ("a==b==c" is "a==b and b==c"), which does the right thing here. It's slightly unusual to negate a query rather than using "!=", but it makes good sense here. ChrisA From python at mrabarnett.plus.com Thu Mar 12 14:21:40 2020 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 12 Mar 2020 18:21:40 +0000 Subject: Multiple comparisons in a single statement In-Reply-To: References: Message-ID: <0b105314-8a91-1b46-9e7a-c9b2a9d2606b@mrabarnett.plus.com> On 2020-03-12 18:08, Chris Angelico wrote: > On Fri, Mar 13, 2020 at 4:55 AM Stephen Tucker wrote: >> >> A quickie (I hope!). >> >> I am running Python 2.7.10 (and, yes, I know, support for it has been >> withdrawn.) > > This is the same in Python 3. > >> I have three tuples that have been generated separately and I want to check >> that they are identical. all I want to do is to terminate the program and >> report an error if all three are not identical. >> >> My initial attempt to do this is to use logic of the form >> >> if not (mytup1 == mytup2 == mytup3): >> raise Exception ("Tuples are not identical") >> >> I have tried this logic form in IDLE, and it seems to do what I want. >> >> Is this a reasonable way to do this, or is there a better way? >> > > Yes absolutely! (Although, as a minor quibble, I would say "equal" > rather than "identical" here - when you talk about identity, you're > usually using the 'is' operator.) The meaning of chained comparisons > is broadly equivalent to comparing the middle one against the others > ("a==b==c" is "a==b and b==c"), which does the right thing here. > There's also the question of whether you consider, say, the int value 0 to be identical to the float value 0.0. Equal? Yes. Identical? Depends what you mean by "identical". > It's slightly unusual to negate a query rather than using "!=", but it > makes good sense here. > From dieter at handshake.de Thu Mar 12 15:08:41 2020 From: dieter at handshake.de (Dieter Maurer) Date: Thu, 12 Mar 2020 20:08:41 +0100 Subject: Lock acquisition by the same thread - deadlock protection In-Reply-To: References: <20200309225302.GA22040@jong.localdomain> <400BDCEC-04F7-482A-9165-2E342B0230AE@barrys-emacs.org> Message-ID: <24170.35001.354491.368799@ixdm.fritz.box> Yonatan wrote at 2020-3-11 16:24 +0200: >That code I'm talking about didn't require a reentrant lock - the >algorithm really wasn't reentrant. > >Let me clarify my point: I'm wondering why the non-reentrant lock >doesn't raise an exception immediately on this >erroneous situation. >I thought it could be altered, or at least we could add an option to >let a `threading.Lock` behave like a pthread >mutex in mode `PTHREAD_MUTEX_ERRORCHECK`: Disallow double locking by >same thread, disallow unlocking >by another thread. The documentation for the basic lock explicitely allows lock release by a foreign thread. As I understand the documentation, this lock type is by design very basic - a mechanism to implement higher level abstractions. I use other synchronisation mechanisms when the basic lock does not fit my requirements. From mal at europython.eu Thu Mar 12 11:07:19 2020 From: mal at europython.eu (M.-A. Lemburg) Date: Thu, 12 Mar 2020 16:07:19 +0100 Subject: EuroPython 2020 and COVID-19 Message-ID: As you probably already know, the Coronavirus is spreading throughout Europe and we wanted to give you an update on our current plans around on the situation. We will update this blog post as new information becomes available: https://blog.europython.eu/post/612393987829039104/europython-2020-and-covid-19 2020-03-12: The number of cases in Ireland is still low compared to other countries, but the Irish government is already starting to put limited bans on larger indoor events. Since EuroPython is planned for July 20-26, we are hopeful that the situation will have improved by then and continue the conference planning with the aim of having the conference on the planned date. We would still like to ask all attendees to take the necessary and recommended hygienic precautions when attending the event and pay close attention to your country?s travel guidelines. If you don?t feel well, please do not attend the conference - instead, please follow the COVID-19 advice of the Irish Health Service. We will refund your ticket. Should the conference need to be canceled as a result of the official ban still being in effect in July, we will refund all tickets - even after the official refund cut-off date (June 19th). We are in discussion with the venue to explore options in case the conference has to be canceled, which we will share with you soon as we have any update. Because the situation is very much in flux, we would recommend that you make booking arrangements with an option to cancel the booking closer to the event date. Resources: - Irish Governement: COVID-19 (Coronavirus): Advice https://www.gov.ie/en/publication/472f64-covid-19-coronavirus-guidance-and-advice/ - Irish Health Service: Coronavirus (COVID-19) https://www2.hse.ie/conditions/coronavirus/coronavirus.html - Coronavirus COVID-19 Global Cases Overview (with daily updates) https://gisanddata.maps.arcgis.com/apps/opsdashboard/index.html#/bda7594740fd40299423467b48e9ecf6 - WHO: Q&A on coronaviruses (COVID-19) https://www.who.int/news-room/q-a-detail/q-a-coronaviruses - Irish Department of Foreign Affairs: Travel Advice https://www.dfa.ie/travel/travel-advice/ Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/post/612393987829039104/europython-2020-and-covid-19 Tweet: https://twitter.com/europython/status/1238115794896240642 Thanks, -- EuroPython 2020 Team https://ep2020.europython.eu/ https://www.europython-society.org/ From johnpote at jptechnical.co.uk Thu Mar 12 18:59:32 2020 From: johnpote at jptechnical.co.uk (John Pote) Date: Thu, 12 Mar 2020 22:59:32 +0000 Subject: Multiple comparisons in a single statement In-Reply-To: References: Message-ID: On 12/03/2020 18:08, Chris Angelico wrote: > On Fri, Mar 13, 2020 at 4:55 AM Stephen Tucker wrote: >> A quickie (I hope!). >> >> I am running Python 2.7.10 (and, yes, I know, support for it has been >> withdrawn.) > This is the same in Python 3. > >> I have three tuples that have been generated separately and I want to check >> that they are identical. all I want to do is to terminate the program and >> report an error if all three are not identical. >> >> My initial attempt to do this is to use logic of the form >> >> if not (mytup1 == mytup2 == mytup3): >> raise Exception ("Tuples are not identical") >> >> I have tried this logic form in IDLE, and it seems to do what I want. >> >> Is this a reasonable way to do this, or is there a better way? >> > Yes absolutely! (Although, as a minor quibble, I would say "equal" > rather than "identical" here - when you talk about identity, you're > usually using the 'is' operator.) The meaning of chained comparisons > is broadly equivalent to comparing the middle one against the others > ("a==b==c" is "a==b and b==c"), which does the right thing here. > > It's slightly unusual to negate a query rather than using "!=", but it > makes good sense here. In case anyone thinks the original expr ???? not (mytup1 == mytup2 == mytup3) could be changed to ???? (mytup1 != mytup2!= mytup3) remember that applying De Morgan's theorem to the original expression would require the 'and' operation used in chained comparisons to change to an 'or' operation (Python always does the 'and' operation in chained comparisions). EG for simple integers instead of tuples, >>> not (1==1==1) False >>> not (2==1==1) True >>> (1!=1!=1) False????????????????????????? correct as before >>> (2!=1!=1) False????????????????????????? oops! John > > ChrisA From joepareti54 at gmail.com Fri Mar 13 04:46:29 2020 From: joepareti54 at gmail.com (joseph pareti) Date: Fri, 13 Mar 2020 09:46:29 +0100 Subject: using classes In-Reply-To: References: Message-ID: one more question. In the code below, there are 2 init() methods, one for the class 'Fahrzeug' and one for the class 'PKW'. The program works when I instantiate the class as: fiat = PKW("Fiat Marea",50,0) but it fails if I say: *fiat = PKW("Fiat Marea",50,0,1)* *Traceback (most recent call last): File "erben_a.py", line 19, in fiat = PKW("Fiat Marea",50,0,1)TypeError: __init__() takes 4 positional arguments but 5 were given* yet the statement in *bold* matches IMO the init() method of the PKW class. Can anyone explain why? Thanks. --- class Fahrzeug: def __init__(self, bez, ge): self.bezeichnung = bez self.geschwindigkeit = ge def beschleunigen(self, wert): self.geschwindigkeit += wert def __str__(self): return self.bezeichnung + " " +str(self.geschwindigkeit) + " km/h" class PKW(Fahrzeug): def __init__(self, bez, ge, ins): super(PKW, self).__init__(bez,ge) self.insassen = ins def __str__(self): return Fahrzeug.__str__(self) + " " + str(self.insassen) + " Insassen" def einsteigen(self, anzahl): self.insassen += anzahl def aussteigen(self, anzahl): self.insassen -= anzahl fiat = PKW("Fiat Marea",50,0,1) fiat = PKW("Fiat Marea",50,0) fiat.einsteigen(3) fiat.aussteigen(1) fiat.beschleunigen(10) print(fiat) Am Do., 12. M?rz 2020 um 17:38 Uhr schrieb Pieter van Oostrum < pieter-l at vanoostrum.org>: > joseph pareti writes: > > > thank you, that fixes it. I also noticed that both statements work: > > > > super(PKW, self).__init__(bez,ge) > > > > or > > > > super().__init__(bez,ge) > > The first is the required Python 2 calling (at least the first argument is > required). The second way can be used in Python 3. > -- > Pieter van Oostrum > www: http://pieter.vanoostrum.org/ > PGP key: [8DAE142BE17999C4] > -- > https://mail.python.org/mailman/listinfo/python-list > -- Regards, Joseph Pareti - Artificial Intelligence consultant Joseph Pareti's AI Consulting Services https://www.joepareti54-ai.com/ cell +49 1520 1600 209 cell +39 339 797 0644 From stephen_tucker at sil.org Fri Mar 13 05:34:35 2020 From: stephen_tucker at sil.org (Stephen Tucker) Date: Fri, 13 Mar 2020 09:34:35 +0000 Subject: Multiple comparisons in a single statement In-Reply-To: References: Message-ID: *Chris:* Thank you for your confirmation. *All: *For the record, I meant that the tuples are all the same. The tuples I have in mind contain strings, so the issue regarding the "equality" (or otherwise) of 0 and 0.0 does not arise in my case. Stephen. To answer the question On Thu, Mar 12, 2020 at 11:26 PM John Pote wrote: > > On 12/03/2020 18:08, Chris Angelico wrote: > > On Fri, Mar 13, 2020 at 4:55 AM Stephen Tucker > wrote: > >> A quickie (I hope!). > >> > >> I am running Python 2.7.10 (and, yes, I know, support for it has been > >> withdrawn.) > > This is the same in Python 3. > > > >> I have three tuples that have been generated separately and I want to > check > >> that they are identical. all I want to do is to terminate the program > and > >> report an error if all three are not identical. > >> > >> My initial attempt to do this is to use logic of the form > >> > >> if not (mytup1 == mytup2 == mytup3): > >> raise Exception ("Tuples are not identical") > >> > >> I have tried this logic form in IDLE, and it seems to do what I want. > >> > >> Is this a reasonable way to do this, or is there a better way? > >> > > Yes absolutely! (Although, as a minor quibble, I would say "equal" > > rather than "identical" here - when you talk about identity, you're > > usually using the 'is' operator.) The meaning of chained comparisons > > is broadly equivalent to comparing the middle one against the others > > ("a==b==c" is "a==b and b==c"), which does the right thing here. > > > > It's slightly unusual to negate a query rather than using "!=", but it > > makes good sense here. > > In case anyone thinks the original expr > not (mytup1 == mytup2 == mytup3) > could be changed to > (mytup1 != mytup2!= mytup3) > remember that applying De Morgan's theorem to the original expression > would require the 'and' operation used in chained comparisons to change > to an 'or' operation (Python always does the 'and' operation in chained > comparisions). EG for simple integers instead of tuples, > > >>> not (1==1==1) > False > >>> not (2==1==1) > True > >>> (1!=1!=1) > False correct as before > >>> (2!=1!=1) > False oops! > > John > > > > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From hjp-python at hjp.at Fri Mar 13 06:12:15 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Fri, 13 Mar 2020 11:12:15 +0100 Subject: using classes In-Reply-To: References: Message-ID: <20200313101215.GA22098@hjp.at> On 2020-03-13 09:46:29 +0100, joseph pareti wrote: > The program works when I instantiate the class as: > > fiat = PKW("Fiat Marea",50,0) > > but it fails if I say: > > *fiat = PKW("Fiat Marea",50,0,1)* The __init__ method of PKW has this signature: > def __init__(self, bez, ge, ins): You are calling it with self = (the newly created object) bez = "Fiat Marea" ge = 50 ins = 0 and an extra Parameter 1, Python doesn't know what to do with that parameter, so it complains about it: Traceback (most recent call last): File "joepareti54", line 19, in fiat = PKW("Fiat Marea",50,0,1) TypeError: __init__() takes 4 positional arguments but 5 were given hp PS: Please add spaces after commas. ?PKW("Fiat Marea", 50, 0, 1)? is much easier to read than ?PKW("Fiat Marea",50,0,1)?. -- _ | 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 rosuav at gmail.com Fri Mar 13 07:13:52 2020 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 13 Mar 2020 22:13:52 +1100 Subject: Multiple comparisons in a single statement In-Reply-To: References: Message-ID: On Fri, Mar 13, 2020 at 8:36 PM Stephen Tucker wrote: > > *Chris:* Thank you for your confirmation. > > *All: *For the record, I meant that the tuples are all the same. The > tuples I have in mind contain strings, so the issue regarding the > "equality" (or otherwise) of 0 and 0.0 does not arise in my case. > > Stephen. If you create the tuples independently, they can be equal but not identical. Example: >>> def cons(x, y): return x, y ... >>> spam = cons("foo", "bar") >>> spon = cons("foo", "bar") >>> spam == spon True >>> spam is spon False For the most part, you won't care about identity, only equality. Everything you said was correct for equality. ChrisA From torriem at gmail.com Fri Mar 13 14:01:11 2020 From: torriem at gmail.com (Michael Torrie) Date: Fri, 13 Mar 2020 12:01:11 -0600 Subject: Python question In-Reply-To: References: <141b2d99d39575e06a7875e1985291b7.squirrel@giyzk7o6dcunb2ry.onion> <6e837b44-eb43-a78b-63fd-5e770b9e330d@gmail.com> <5d551551-b7e2-d3c5-e624-5d27751705b8@DancesWithMice.info> <387e5713-fcdb-6611-4a1c-fa9a7f8990c7@gmail.com> <0d44f894-dd2e-4bd2-8383-11aa69d93c6f@kynesim.co.uk> <07a6b774-8c2c-a3ed-cea4-982fabc9b73e@DancesWithMice.info> Message-ID: <3777d95f-33ce-fbe5-8863-15e277bb2542@gmail.com> On 3/12/20 4:19 PM, Mike Dewhirst wrote: > I'm not sure I understand what you are saying. How is gmail > behaviour breaking things? The problem is if I post to a mailing list from gmail (either the web interface or Thunderbird via Google's SMTP servers), Google will silently discard my own message when the list serv echos it back to me. In the web-based "conversation" view, Google puts my own sent message in the conversation. However via IMAP I see nothing. Thus when looking at my list mail on Thunderbird, my own messages to the list never show up. Does that make sense? There was a lot of fuss about this when gmail first started doing this, but Google ignored it and continues to ignore this issue. They regard this sort of email use as "legacy." Here's an old message describing the problem and showing Google's non-response: https://support.google.com/mail/forum/AAAAK7un8RUduyrfxS01ac/?hl=en The only way to prevent this is to send your message via a non-Gmail SMTP server, and not to put those messages in your Gmail Sent folder. This runs the risk of messages being flagged as untrustworthy, but as long as Python's smtp server accepts them, it works. Of course python's list messages going out are often flagged as suspicious because they have our own "from" addresses on them but come through Python's servers. > I do have a gmail account but don't use it. > > As background, I signed up to the Django google-group list and > traffic there arrives in my Thunderbird client. I also occasionally > use Roundcube web client for my accounts when travelling. I think > that might be a php thing. > > Maybe there is a case for developing a gmail-like web client? No the problem has nothing to do with the web interface or the client. It's a bug/feature of the Google back end. From weaponx4120 at gmail.com Fri Mar 13 10:16:29 2020 From: weaponx4120 at gmail.com (pro_ bro) Date: Fri, 13 Mar 2020 19:46:29 +0530 Subject: Need some GUIDE Message-ID: First of all sry for asking this type of question. I started my Python journey a year ago. From then I learned a lot(Basics to advanced topics ) But when it comes to getting a job(Python related) I failed a lot. Every time I attended the recruitment process they offer python in the coding test but never took me into the python stream after getting placed in that company. PLS someone help me how to get it a job which is purely based on python From pieter-l at vanoostrum.org Fri Mar 13 05:10:05 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Fri, 13 Mar 2020 10:10:05 +0100 Subject: using classes In-Reply-To: References: Message-ID: <24171.19949.537451.644854@cochabamba.vanoostrum.org> joseph pareti wrote: > one more question. In the code below, there are 2 init() methods, one for the class 'Fahrzeug' and > one for the class 'PKW'. > The program works?when I instantiate the class as: > > fiat = PKW("Fiat Marea",50,0) > > but it fails if I say: > > fiat = PKW("Fiat Marea",50,0,1) > > Traceback (most recent call last): > ? File "erben_a.py", line 19, in > ? ? fiat = PKW("Fiat Marea",50,0,1) > TypeError: __init__() takes 4 positional arguments but 5 were given > > yet the statement in bold matches IMO the init() method?of the PKW class. Can anyone explain why? > Thanks. No, the 'self' in the definition of init is the object being initialised. It is supplied by the class code that creates the new instance, not something you provide yourself. Your arguments are bez, ge, ins. class PKW(Fahrzeug): ? ? def __init__(self, bez, ge, ins): -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From jlaatech at gmail.com Fri Mar 13 15:52:01 2020 From: jlaatech at gmail.com (jlaatech at gmail.com) Date: Fri, 13 Mar 2020 12:52:01 -0700 (PDT) Subject: pyttsx3 installation error In-Reply-To: References: Message-ID: <1edd24d2-b3d3-4b18-a525-a289169be123@googlegroups.com> Got the same error here please help ERROR: Command errored out with exit status 1: command: 'c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Jerald Lashy Jeffery\\AppData\\Local\\Temp\\pip-install-ej949hlq\\pyobjc-framework-AddressBook\\setup.py'"'"'; __file__='"'"'C:\\Users\\Jerald Lashy Jeffery\\AppData\\Local\\Temp\\pip-install-ej949hlq\\pyobjc-framework-AddressBook\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\pip-egg-info' cwd: C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\ Complete output (15 lines): Traceback (most recent call last): File "", line 1, in File "C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\setup.py", line 22, in Extension( File "C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\pyobjc_setup.py", line 408, in Extension os_level = get_os_level() File "C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\pyobjc_setup.py", line 218, in get_os_level pl = plistlib.readPlist("/System/Library/CoreServices/SystemVersion.plist") File "c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\lib\plistlib.py", line 99, in readPlist with _maybe_open(pathOrFile, 'rb') as fp: File "c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\lib\contextlib.py", line 113, in __enter__ return next(self.gen) File "c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\lib\plistlib.py", line 82, in _maybe_open with open(pathOrFile, mode) as fp: FileNotFoundError: [Errno 2] No such file or directory: '/System/Library/CoreServices/SystemVersion.plist' ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. From python at mrabarnett.plus.com Fri Mar 13 17:41:45 2020 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 13 Mar 2020 21:41:45 +0000 Subject: pyttsx3 installation error In-Reply-To: <1edd24d2-b3d3-4b18-a525-a289169be123@googlegroups.com> References: <1edd24d2-b3d3-4b18-a525-a289169be123@googlegroups.com> Message-ID: <585c945f-e02b-ebf1-37c3-c2fb5e58083f@mrabarnett.plus.com> On 2020-03-13 19:52, jlaatech at gmail.com wrote: > > Got the same error here please help > ERROR: Command errored out with exit status 1: > command: 'c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Jerald Lashy Jeffery\\AppData\\Local\\Temp\\pip-install-ej949hlq\\pyobjc-framework-AddressBook\\setup.py'"'"'; __file__='"'"'C:\\Users\\Jerald Lashy Jeffery\\AppData\\Local\\Temp\\pip-install-ej949hlq\\pyobjc-framework-AddressBook\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\pip-egg-info' > cwd: C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\ > Complete output (15 lines): > Traceback (most recent call last): > File "", line 1, in > File "C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\setup.py", line 22, in > Extension( > File "C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\pyobjc_setup.py", line 408, in Extension > os_level = get_os_level() > File "C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\pyobjc_setup.py", line 218, in get_os_level > pl = plistlib.readPlist("/System/Library/CoreServices/SystemVersion.plist") > File "c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\lib\plistlib.py", line 99, in readPlist > with _maybe_open(pathOrFile, 'rb') as fp: > File "c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\lib\contextlib.py", line 113, in __enter__ > return next(self.gen) > File "c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\lib\plistlib.py", line 82, in _maybe_open > with open(pathOrFile, mode) as fp: > FileNotFoundError: [Errno 2] No such file or directory: '/System/Library/CoreServices/SystemVersion.plist' > ---------------------------------------- > ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. > Did you try to install from PyPI? It appears that you should clone the project from GitHub. This might help: https://medium.com/better-programming/an-introduction-to-pyttsx3-a-text-to-speech-converter-for-python-4a7e1ce825c3 I haven't tried it myself. From Marco.Sulla.Python at gmail.com Fri Mar 13 17:45:57 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Fri, 13 Mar 2020 22:45:57 +0100 Subject: Need some GUIDE In-Reply-To: References: Message-ID: On Fri, 13 Mar 2020 at 20:06, pro_ bro wrote: > First of all sry for asking this type of question. > I started my Python journey a year ago. From then I learned a lot(Basics to > advanced topics ) Can I ask you what had motivated you? > never took me into the python stream after getting placed in that > company. And which kind of job offered to you? From goluhng at gmail.com Fri Mar 13 18:51:10 2020 From: goluhng at gmail.com (Go Luhng) Date: Fri, 13 Mar 2020 18:51:10 -0400 Subject: Profiler showing path dependency? Message-ID: Consider a simple call graph: `main()` calls `foo()`, which calls `bar()`. Then `main()` calls `qux()` which also calls `bar()`, but with different parameters. When you run the above through cProfile and view the result in SnakeViz, you will see `main()` calling `foo()` and `qux()`, with each of them calling `bar()`. However, if you hover or click on `bar()`, you will see the global aggregate statistics for it. For example, the number of times it has been called, and their total time cost. Is there a way to get a path-dependent profiler breakdown for `bar()`? Specifically for this example, statistics for when it is called by `foo()`, and separately statistics for when it is called by `qux()`. From Marco.Sulla.Python at gmail.com Fri Mar 13 19:08:35 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Sat, 14 Mar 2020 00:08:35 +0100 Subject: pyttsx3 installation error In-Reply-To: <585c945f-e02b-ebf1-37c3-c2fb5e58083f@mrabarnett.plus.com> References: <1edd24d2-b3d3-4b18-a525-a289169be123@googlegroups.com> <585c945f-e02b-ebf1-37c3-c2fb5e58083f@mrabarnett.plus.com> Message-ID: It's a know bug. Solution: https://stackoverflow.com/a/59909885/1763602 From Marco.Sulla.Python at gmail.com Fri Mar 13 19:53:26 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Sat, 14 Mar 2020 00:53:26 +0100 Subject: Have you some experience / link about difference between Python builded with gcc and clang? In-Reply-To: References: Message-ID: Well, I suppose we have a winner: pyperf_bench_3_8_gcc_9_2.json ============================= Performance version: 1.0.0 Report on Linux-4.15.0-76-generic-x86_64-with-glibc2.27 Number of logical CPUs: 4 Start date: 2020-03-13 19:36:17.585796 End date: 2020-03-13 20:35:09.605718 pyperf_bench_3_8_clang_9.json ============================= Performance version: 1.0.0 Report on Linux-4.15.0-76-generic-x86_64-with-glibc2.27 Number of logical CPUs: 4 Start date: 2020-03-13 20:55:54.239018 End date: 2020-03-13 21:59:19.778522 +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | Benchmark | pyperf_bench_3_8_gcc_9_2.json | pyperf_bench_3_8_clang_9.json | Change | Significance | +=========================+===============================+===============================+==============+=========================+ | 2to3 | 477 ms | 527 ms | 1.11x slower | Significant (t=-210.10) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | chameleon | 13.2 ms | 15.9 ms | 1.20x slower | Significant (t=-123.35) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | chaos | 155 ms | 193 ms | 1.25x slower | Significant (t=-176.57) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | crypto_pyaes | 158 ms | 195 ms | 1.24x slower | Significant (t=-81.20) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | deltablue | 10.2 ms | 12.1 ms | 1.19x slower | Significant (t=-50.11) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | django_template | 69.4 ms | 80.9 ms | 1.17x slower | Significant (t=-77.25) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | dulwich_log | 106 ms | 113 ms | 1.06x slower | Significant (t=-62.12) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | fannkuch | 659 ms | 789 ms | 1.20x slower | Significant (t=-62.44) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | float | 165 ms | 198 ms | 1.20x slower | Significant (t=-124.75) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | genshi_text | 40.5 ms | 46.6 ms | 1.15x slower | Significant (t=-111.00) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | genshi_xml | 87.3 ms | 97.2 ms | 1.11x slower | Significant (t=-66.48) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | go | 361 ms | 434 ms | 1.20x slower | Significant (t=-136.23) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | hexiom | 14.0 ms | 16.4 ms | 1.17x slower | Significant (t=-103.53) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | html5lib | 143 ms | 157 ms | 1.10x slower | Significant (t=-14.52) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | json_dumps | 18.2 ms | 20.8 ms | 1.14x slower | Significant (t=-82.67) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | json_loads | 42.9 us | 46.0 us | 1.07x slower | Significant (t=-42.16) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | logging_format | 13.8 us | 16.2 us | 1.17x slower | Significant (t=-72.21) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | logging_silent | 265 ns | 332 ns | 1.25x slower | Significant (t=-70.39) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | logging_simple | 12.4 us | 14.6 us | 1.18x slower | Significant (t=-73.84) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | mako | 23.3 ms | 27.9 ms | 1.20x slower | Significant (t=-159.94) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | mdp | 4.04 sec | 4.48 sec | 1.11x slower | Significant (t=-213.27) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | meteor_contest | 164 ms | 170 ms | 1.04x slower | Significant (t=-21.36) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | nbody | 191 ms | 228 ms | 1.19x slower | Significant (t=-218.81) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | nqueens | 135 ms | 164 ms | 1.22x slower | Significant (t=-177.49) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | pathlib | 31.9 ms | 34.2 ms | 1.07x slower | Significant (t=-57.08) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | pickle | 16.4 us | 15.7 us | 1.05x faster | Significant (t=6.08) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | pickle_dict | 40.3 us | 42.8 us | 1.06x slower | Significant (t=-49.42) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | pickle_list | 6.58 us | 6.15 us | 1.07x faster | Significant (t=47.82) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | pickle_pure_python | 641 us | 746 us | 1.16x slower | Significant (t=-93.74) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | pidigits | 268 ms | 311 ms | 1.16x slower | Significant (t=-965.71) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | pyflate | 969 ms | 1.16 sec | 1.19x slower | Significant (t=-136.22) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | python_startup | 14.7 ms | 13.8 ms | 1.06x faster | Significant (t=451.70) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | python_startup_no_site | 10.1 ms | 9.66 ms | 1.04x faster | Significant (t=313.35) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | raytrace | 678 ms | 825 ms | 1.22x slower | Significant (t=-138.92) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | regex_compile | 254 ms | 294 ms | 1.16x slower | Significant (t=-92.31) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | regex_dna | 294 ms | 300 ms | 1.02x slower | Not significant | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | regex_effbot | 4.43 ms | 5.15 ms | 1.16x slower | Significant (t=-104.93) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | regex_v8 | 34.4 ms | 35.4 ms | 1.03x slower | Significant (t=-9.57) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | richards | 96.5 ms | 121 ms | 1.26x slower | Significant (t=-90.84) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | scimark_fft | 502 ms | 603 ms | 1.20x slower | Significant (t=-177.78) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | scimark_lu | 207 ms | 254 ms | 1.22x slower | Significant (t=-79.82) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | scimark_monte_carlo | 147 ms | 181 ms | 1.24x slower | Significant (t=-97.62) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | scimark_sor | 279 ms | 339 ms | 1.21x slower | Significant (t=-85.97) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | scimark_sparse_mat_mult | 6.54 ms | 7.67 ms | 1.17x slower | Significant (t=-54.66) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | spectral_norm | 194 ms | 233 ms | 1.20x slower | Significant (t=-211.46) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | sqlalchemy_declarative | 259 ms | 269 ms | 1.04x slower | Significant (t=-21.30) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | sqlalchemy_imperative | 48.8 ms | 52.0 ms | 1.06x slower | Significant (t=-15.79) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | sqlite_synth | 4.34 us | 4.81 us | 1.11x slower | Significant (t=-34.82) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | sympy_expand | 722 ms | 761 ms | 1.05x slower | Significant (t=-19.09) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | sympy_integrate | 36.5 ms | 39.0 ms | 1.07x slower | Significant (t=-59.33) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | sympy_str | 485 ms | 519 ms | 1.07x slower | Significant (t=-35.88) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | sympy_sum | 321 ms | 341 ms | 1.06x slower | Significant (t=-46.38) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | telco | 9.03 ms | 9.97 ms | 1.10x slower | Significant (t=-37.14) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | tornado_http | 234 ms | 246 ms | 1.05x slower | Significant (t=-17.41) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | unpack_sequence | 94.7 ns | 102 ns | 1.07x slower | Significant (t=-46.75) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | unpickle | 20.6 us | 24.9 us | 1.21x slower | Significant (t=-53.21) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | unpickle_list | 6.69 us | 6.55 us | 1.02x faster | Significant (t=7.28) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | unpickle_pure_python | 451 us | 544 us | 1.21x slower | Significant (t=-105.28) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | xml_etree_generate | 135 ms | 156 ms | 1.15x slower | Significant (t=-68.77) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | xml_etree_iterparse | 158 ms | 174 ms | 1.10x slower | Significant (t=-59.12) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | xml_etree_parse | 232 ms | 258 ms | 1.11x slower | Significant (t=-53.95) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ | xml_etree_process | 108 ms | 123 ms | 1.14x slower | Significant (t=-95.42) | +-------------------------+-------------------------------+-------------------------------+--------------+-------------------------+ I think that the competition with clang has moved GCC. From jlaatech at gmail.com Sat Mar 14 00:59:19 2020 From: jlaatech at gmail.com (jlaatech at gmail.com) Date: Fri, 13 Mar 2020 21:59:19 -0700 (PDT) Subject: pyttsx3 installation error In-Reply-To: References: <1edd24d2-b3d3-4b18-a525-a289169be123@googlegroups.com> <585c945f-e02b-ebf1-37c3-c2fb5e58083f@mrabarnett.plus.com> Message-ID: <319199a6-7a5e-4199-ae74-b7e3136b9e65@googlegroups.com> On Friday, 13 March 2020 23:45:08 UTC+2, MRAB wrote: > On 2020-03-13 19:52, jlaatech at gmail.com wrote: > > > > Got the same error here please help > > ERROR: Command errored out with exit status 1: > > command: 'c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Jerald Lashy Jeffery\\AppData\\Local\\Temp\\pip-install-ej949hlq\\pyobjc-framework-AddressBook\\setup.py'"'"'; __file__='"'"'C:\\Users\\Jerald Lashy Jeffery\\AppData\\Local\\Temp\\pip-install-ej949hlq\\pyobjc-framework-AddressBook\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\pip-egg-info' > > cwd: C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\ > > Complete output (15 lines): > > Traceback (most recent call last): > > File "", line 1, in > > File "C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\setup.py", line 22, in > > Extension( > > File "C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\pyobjc_setup.py", line 408, in Extension > > os_level = get_os_level() > > File "C:\Users\Jerald Lashy Jeffery\AppData\Local\Temp\pip-install-ej949hlq\pyobjc-framework-AddressBook\pyobjc_setup.py", line 218, in get_os_level > > pl = plistlib.readPlist("/System/Library/CoreServices/SystemVersion.plist") > > File "c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\lib\plistlib.py", line 99, in readPlist > > with _maybe_open(pathOrFile, 'rb') as fp: > > File "c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\lib\contextlib.py", line 113, in __enter__ > > return next(self.gen) > > File "c:\users\jerald lashy jeffery\appdata\local\programs\python\python38-32\lib\plistlib.py", line 82, in _maybe_open > > with open(pathOrFile, mode) as fp: > > FileNotFoundError: [Errno 2] No such file or directory: '/System/Library/CoreServices/SystemVersion.plist' > > ---------------------------------------- > > ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. > > > Did you try to install from PyPI? It appears that you should clone the > project from GitHub. This might help: > > https://medium.com/better-programming/an-introduction-to-pyttsx3-a-text-to-speech-converter-for-python-4a7e1ce825c3 > > I haven't tried it myself. Thank you this worked for me. From jlaatech at gmail.com Sat Mar 14 01:00:21 2020 From: jlaatech at gmail.com (jlaatech at gmail.com) Date: Fri, 13 Mar 2020 22:00:21 -0700 (PDT) Subject: pyttsx3 installation error In-Reply-To: References: <1edd24d2-b3d3-4b18-a525-a289169be123@googlegroups.com> <585c945f-e02b-ebf1-37c3-c2fb5e58083f@mrabarnett.plus.com> Message-ID: On Saturday, 14 March 2020 01:52:51 UTC+2, Marco Sulla wrote: > It's a know bug. Solution: https://stackoverflow.com/a/59909885/1763602 Thank you for your concern.I tried the above solution first and it worked as well. Thank you From dieter at handshake.de Sat Mar 14 12:45:01 2020 From: dieter at handshake.de (Dieter Maurer) Date: Sat, 14 Mar 2020 17:45:01 +0100 Subject: Profiler showing path dependency? In-Reply-To: References: Message-ID: <24173.2573.450033.483124@ixdm.fritz.box> Go Luhng wrote at 2020-3-13 18:51 -0400: >Consider a simple call graph: `main()` calls `foo()`, which calls >`bar()`. Then `main()` calls `qux()` which also calls `bar()`, but >with different parameters. > >When you run the above through cProfile and view the result in >SnakeViz, you will see `main()` calling `foo()` and `qux()`, with each >of them calling `bar()`. However, if you hover or click on `bar()`, >you will see the global aggregate statistics for it. For example, the >number of times it has been called, and their total time cost. > >Is there a way to get a path-dependent profiler breakdown for `bar()`? Again (like for profiling with parameters), you have the problem of mass data: in typical situations, you have a huge number of different call paths. I have not yet used "cProfile" but "profile" and its extension "dm.profile". "profile" collects statistics based on function and caller/callee. This means, that you can derived limited information about the call paths: the immediate caller/callees, but not the complete call paths. Again, you would (almost surely) need to write your own profiler to gather information broken down on the complete call paths. Such a profiler could only be used in restricted situations (where the amount of call paths is quite limited). From cs at cskk.id.au Sat Mar 14 19:17:31 2020 From: cs at cskk.id.au (Cameron Simpson) Date: Sun, 15 Mar 2020 10:17:31 +1100 Subject: Lock acquisition by the same thread - deadlock protection In-Reply-To: <24170.35001.354491.368799@ixdm.fritz.box> References: <24170.35001.354491.368799@ixdm.fritz.box> Message-ID: <20200314231731.GA57809@cskk.homeip.net> On 12Mar2020 20:08, Dieter Maurer wrote: >Yonatan wrote at 2020-3-11 16:24 +0200: >>That code I'm talking about didn't require a reentrant lock - the >>algorithm really wasn't reentrant. >> >>Let me clarify my point: I'm wondering why the non-reentrant lock >>doesn't raise an exception immediately on this >>erroneous situation. >>I thought it could be altered, or at least we could add an option to >>let a `threading.Lock` behave like a pthread >>mutex in mode `PTHREAD_MUTEX_ERRORCHECK`: Disallow double locking by >>same thread, disallow unlocking >>by another thread. > >The documentation for the basic lock explicitely allows >lock release by a foreign thread. >As I understand the documentation, this lock type is by design >very basic - a mechanism to implement higher level abstractions. >I use other synchronisation mechanisms when the basic lock does >not fit my requirements. Aye. I have certainly gone: - take lock associated with some task specific resource - set up task - kick off worker Thread (or queue worker function for later) - worker releases the lock However, having an error check mode disallowing attempts by the same Thread to take a Lock it itself took seems valuable. If the lock object has that piece of information (IIRC it does). Cheers, Cameron Simpson (formerly cs at zip.com.au) From dieter at handshake.de Sun Mar 15 06:32:43 2020 From: dieter at handshake.de (Dieter Maurer) Date: Sun, 15 Mar 2020 11:32:43 +0100 Subject: Lock acquisition by the same thread - deadlock protection In-Reply-To: <20200314231731.GA57809@cskk.homeip.net> References: <24170.35001.354491.368799@ixdm.fritz.box> <20200314231731.GA57809@cskk.homeip.net> Message-ID: <24174.1099.477949.476036@ixdm.fritz.box> Cameron Simpson wrote at 2020-3-15 10:17 +1100: >On 12Mar2020 20:08, Dieter Maurer wrote: > ... >>The documentation for the basic lock explicitely allows >>lock release by a foreign thread. >>As I understand the documentation, this lock type is by design >>very basic - a mechanism to implement higher level abstractions. >>I use other synchronisation mechanisms when the basic lock does >>not fit my requirements. > >Aye. I have certainly gone: >- take lock associated with some task specific resource >- set up task >- kick off worker Thread (or queue worker function for later) >- worker releases the lock > >However, having an error check mode disallowing attempts by the same >Thread to take a Lock it itself took seems valuable. If the lock object >has that piece of information (IIRC it does). Below is a Python 3 implementation for such a lock. The quirks required to get a nested "with" safe might be seen as an indication that it should not be implemented in the base lock class. from _thread import allocate_lock, get_ident class NestedTLockError(RuntimeError): """Special error used to make nested ``with`` statements safe.""" def __init__(self, message, lock): self._lock = lock super().__init__(message, lock) class TLock: """A lock preventing the same thread to get the lock twice.""" def __init__(self): self._lock = allocate_lock() self._tid = None def acquire(self, wait=True, timeout=-1): tid = get_ident() if self._tid == tid: # this remains stable raise NestedTLockError("already acquired", self) acquired = self._lock.acquire(0) or self._lock.acquire(wait, timeout) if acquired: # Lock successfully acquired - no other thread will interfere self._tid = tid return acquired def __enter__(self): return self.acquire() def release(self): # the application is responsible that nothing interferes # with our release self._tid = None self._lock.release() def __exit__(self, t, v, tb): if not self.locked(): return # the ``__enter__`` failed if t is NestedTLockError and v._lock is self: # the ``__enter__`` failed due to nested lock acquisition # we must not release the lock (it would be too early) # but must allow the outer ``__exit__`` to release the lock v._lock = None return self.release() def locked(self): return self._lock.locked() From stephen_tucker at sil.org Mon Mar 16 06:03:51 2020 From: stephen_tucker at sil.org (Stephen Tucker) Date: Mon, 16 Mar 2020 10:03:51 +0000 Subject: Multiple comparisons in a single statement In-Reply-To: References: Message-ID: OK. You are right. I was misleading. I am sorry for wasting your time. Thanks you for helping me to express myself. Stephen. Virus-free. www.avast.com <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> On Fri, Mar 13, 2020 at 7:05 PM Dennis Lee Bieber wrote: > On Fri, 13 Mar 2020 09:34:35 +0000, Stephen Tucker > > declaimed the following: > > > > >*All: *For the record, I meant that the tuples are all the same. The > > > "all the same" is still ambiguous... > > >>> str1 = "A String" > >>> str2 = "Another String" > >>> str3 = "A" + " " + "String" > >>> id(str1), id(str2), id(str3) > (105461360, 105461296, 105461232) > >>> tpl1 = (str1, str2) > >>> tpl2 = (str1, str2) > >>> tpl3 = (str3, str2) > >>> id(tpl1), id(tpl2), id(tpl3) > (90094216, 90094152, 90093576) > >>> tpl1 == tpl2 > True > >>> tpl1 == tpl3 > True > >>> tpl4 = tpl3 > >>> tpl4 == tpl3 > True > >>> tpl1 is tpl2 > False > >>> tpl1 is tpl3 > False > >>> tpl1 is tpl4 > False > >>> tpl3 is tpl4 > True > >>> > > tpl3 IS THE SAME as tpl4 > tpl1 is NOT THE SAME as tpl2, tpl3, or tpl4 > > However, the CONTENTS of tpl4 compare as equivalent to tpl1, tpl2, and tpl3 > > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com > http://wlfraed.microdiversity.freeddns.org/ > > -- > https://mail.python.org/mailman/listinfo/python-list > From Marco.Sulla.Python at gmail.com Sun Mar 15 17:05:04 2020 From: Marco.Sulla.Python at gmail.com (Marco Sulla) Date: Sun, 15 Mar 2020 22:05:04 +0100 Subject: Profiler showing path dependency? In-Reply-To: References: Message-ID: https://docs.python.org/3/library/profile.html#pstats.Stats.print_callers On Sat, 14 Mar 2020 at 00:54, Go Luhng wrote: > Consider a simple call graph: `main()` calls `foo()`, which calls > `bar()`. Then `main()` calls `qux()` which also calls `bar()`, but > with different parameters. > > When you run the above through cProfile and view the result in > SnakeViz, you will see `main()` calling `foo()` and `qux()`, with each > of them calling `bar()`. However, if you hover or click on `bar()`, > you will see the global aggregate statistics for it. For example, the > number of times it has been called, and their total time cost. > > Is there a way to get a path-dependent profiler breakdown for `bar()`? > Specifically for this example, statistics for when it is called by > `foo()`, and separately statistics for when it is called by `qux()`. > -- > https://mail.python.org/mailman/listinfo/python-list > From Irv at furrypants.com Mon Mar 16 14:31:48 2020 From: Irv at furrypants.com (Irv Kalb) Date: Mon, 16 Mar 2020 11:31:48 -0700 Subject: [Mostly OT] Feedback on Python homework using Canvas LMS Message-ID: This is for anyone who teaches Python and uses the Canvas Learning Management System (maybe a small group). I teach Python at two colleges in Silicon Valley in California. At both schools we use Canvas. Overall, it works very well. I use it to post notes, sample programs, build tests, post homework, and correct homework assignment. However, there is a problem (bug!) when I give feedback on student's homework assignments. I often give feedback by writing small snippets of code to explain what a student has done wrong, or how something could be done better. The problem is that in the feedback section for homework assignments, Canvas eliminates any leading space characters. So, I might write: if x == y: # do thing 1 else: # do thing 2 but when it gets posted and viewed by the student, it shows up as: if x == y: # do thing 1 else: # do thing 2 Which obviously is very annoying to me, and not as helpful to the student. Knowing that this happens, I have started to write feedback using periods for indenting: if x == y: ....# do thing 1 else: ....# do thing 2 I have posted about this problem on the Canvas board, pointing out the importance of leading spaces, but I've had no response. I also even wrote the company through snail mail, and got no response. Question 1: Does anyone have any suggestions for indenting besides using periods? Question 2: Does anyone know any other way to reach the appropriate person(s) at Canvas to address this issue. Thanks, Irv From orges.leka at gmail.com Mon Mar 16 13:38:39 2020 From: orges.leka at gmail.com (Orges Leka) Date: Mon, 16 Mar 2020 18:38:39 +0100 Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp Message-ID: Dear Python developers, I am a data scientist and use Python regularly. I have a question: How difficult is it to write a Python web-app, with the following basic functionality: The user writes anonymously without registration where (City, supermarket), when (Date and Time) he plans to go to the supermarket. If this is done by a lot of users, the first user gets to see the number of other buyers at this supermarket and can better plan when to go shopping. This would reduce the waiting queue at the supermarket and possibly the contact to other people thus would help a little bit in slowing down the spread of the Corona virus. One could also add openstreetmap functionality to this. As I am not a professional software developer, I can not predict how long it would take to write such a web-app in python. If you do not have currently time, but know someone who would possibly be interested in working at this project, I would be happy if you let me know. Kind regards, Orges Leka -- Mit freundlichen Gr??en Herr Dipl. Math. Orges Leka Mobil: 015751078391 Email: orges.leka at googlemail.com Holzheimerstra?e 25 65549 Limburg From python at mrabarnett.plus.com Mon Mar 16 15:30:05 2020 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 16 Mar 2020 19:30:05 +0000 Subject: [Mostly OT] Feedback on Python homework using Canvas LMS In-Reply-To: References: Message-ID: <1288db8d-fc2d-9461-df64-4a9ebfbcc8b1@mrabarnett.plus.com> On 2020-03-16 18:31, Irv Kalb wrote: > This is for anyone who teaches Python and uses the Canvas Learning Management System (maybe a small group). > > I teach Python at two colleges in Silicon Valley in California. At both schools we use Canvas. Overall, it works very well. I use it to post notes, sample programs, build tests, post homework, and correct homework assignment. > > However, there is a problem (bug!) when I give feedback on student's homework assignments. I often give feedback by writing small snippets of code to explain what a student has done wrong, or how something could be done better. The problem is that in the feedback section for homework assignments, Canvas eliminates any leading space characters. So, I might write: > > if x == y: > # do thing 1 > else: > # do thing 2 > > but when it gets posted and viewed by the student, it shows up as: > > if x == y: > # do thing 1 > else: > # do thing 2 > > Which obviously is very annoying to me, and not as helpful to the student. > > Knowing that this happens, I have started to write feedback using periods for indenting: > > if x == y: > ....# do thing 1 > else: > ....# do thing 2 > > I have posted about this problem on the Canvas board, pointing out the importance of leading spaces, but I've had no response. I also even wrote the company through snail mail, and got no response. > > Question 1: Does anyone have any suggestions for indenting besides using periods? > > Question 2: Does anyone know any other way to reach the appropriate person(s) at Canvas to address this issue. > For appearances you could indent with non-breaking spaces, '\xA0'. Just be aware that it could be confusing if the user tries to copy and paste it, because although they'll look like spaces, they won't be! From rosuav at gmail.com Mon Mar 16 15:57:31 2020 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 17 Mar 2020 06:57:31 +1100 Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp In-Reply-To: References: Message-ID: On Tue, Mar 17, 2020 at 6:25 AM Orges Leka wrote: > > Dear Python developers, > > I am a data scientist and use Python regularly. I have a question: > How difficult is it to write a Python web-app, with the following basic > functionality: > > The user writes anonymously without registration where (City, supermarket), > when (Date and Time) he plans to go to the supermarket. > If this is done by a lot of users, the first user gets to see the number of > other buyers at this supermarket and can better plan when to go shopping. > This would reduce the waiting queue at the supermarket and possibly the > contact to other people thus would help a little bit in slowing down the > spread of the Corona virus. > One could also add openstreetmap functionality to this. > It'd be pretty easy to write the app. The hard part would be getting enough people to use it, since the app can only see how many other people are also using the app. Since you need it to work with any specified date/time, it can't simply look at current traffic (even if that information were available), which means you're basically limited to information shared by other users. ChrisA From ethan at stoneleaf.us Mon Mar 16 16:01:14 2020 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 16 Mar 2020 13:01:14 -0700 Subject: [Mostly OT] Feedback on Python homework using Canvas LMS In-Reply-To: References: Message-ID: On 03/16/2020 11:31 AM, Irv Kalb wrote: > The problem is that in the feedback section for homework assignments, Canvas > eliminates any leading space characters. So, I might write: > > if x == y: > # do thing 1 > else: > # do thing 2 > > but when it gets posted and viewed by the student, it shows up as: > > if x == y: > # do thing 1 > else: > # do thing 2 Sounds like HTML display -- have you tried enclosing your snippets in
 or  tags?

If that fails, are embedded spaces retained?  If so, maybe

.if x == y
.    # do thing 1
.else:
.    # do thing 2

That would make less work after copy pasting, at least.

--
~Ethan~

From barry at barrys-emacs.org  Mon Mar 16 16:08:02 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Mon, 16 Mar 2020 20:08:02 +0000
Subject: Profiler showing path dependency?
In-Reply-To: 
References: 
 
Message-ID: <22E5884D-55FD-4D65-9530-6832B66198B4@barrys-emacs.org>



> On 15 Mar 2020, at 21:05, Marco Sulla  wrote:
> 
> https://docs.python.org/3/library/profile.html#pstats.Stats.print_callers

And also look at print_callees. Between callers and callees you can
usually find some insight.

Barry


> 
> On Sat, 14 Mar 2020 at 00:54, Go Luhng  wrote:
> 
>> Consider a simple call graph: `main()` calls `foo()`, which calls
>> `bar()`. Then `main()` calls `qux()` which also calls `bar()`, but
>> with different parameters.
>> 
>> When you run the above through cProfile and view the result in
>> SnakeViz, you will see `main()` calling `foo()` and `qux()`, with each
>> of them calling `bar()`. However, if you hover or click on `bar()`,
>> you will see the global aggregate statistics for it. For example, the
>> number of times it has been called, and their total time cost.
>> 
>> Is there a way to get a path-dependent profiler breakdown for `bar()`?
>> Specifically for this example, statistics for when it is called by
>> `foo()`, and separately statistics for when it is called by `qux()`.
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 


From orges.leka at gmail.com  Mon Mar 16 16:19:21 2020
From: orges.leka at gmail.com (Orges Leka)
Date: Mon, 16 Mar 2020 21:19:21 +0100
Subject: Fwd: Reduce waiting queue at supermarket from Corona with
 Python-Webapp
In-Reply-To: 
References: 
 
 
Message-ID: 

---------- Forwarded message ---------
Von: Orges Leka 
Date: Mo., 16. M?rz 2020 um 21:13 Uhr
Subject: Re: Reduce waiting queue at supermarket from Corona with
Python-Webapp
To: Chris Angelico 


Thanks for your insight. The date / time could be from a predefined list,
for example:

10:00-11:00
11:00-12:00
...
20:00-21:00

This would work like a calender function. Where each user can register for
example for three distinct time slots, and then he will see, approximately,
the time distribution of other users.

For the getting enough people to use it, I think word-of-mouth should work,
as it would help those who use it, plus it reduces the chance of physical
contact, so there is a win-win situation in using the app.

Maybe if someone from the media promotes the app, this should boost it also.

Kind regards,
Orges

Am Mo., 16. M?rz 2020 um 21:00 Uhr schrieb Chris Angelico :

> On Tue, Mar 17, 2020 at 6:25 AM Orges Leka  wrote:
> >
> > Dear Python developers,
> >
> > I am a data scientist and use Python regularly. I have a question:
> > How difficult is it to write a Python web-app, with the following basic
> > functionality:
> >
> > The user writes anonymously without registration where (City,
> supermarket),
> > when (Date and Time) he plans to go to the supermarket.
> > If this is done by a lot of users, the first user gets to see the number
> of
> > other buyers at this supermarket and can better plan when to go shopping.
> > This would reduce the waiting queue at the supermarket and possibly the
> > contact to other people thus would help a little bit in slowing down the
> > spread of the Corona virus.
> > One could also add openstreetmap functionality to this.
> >
>
> It'd be pretty easy to write the app. The hard part would be getting
> enough people to use it, since the app can only see how many other
> people are also using the app. Since you need it to work with any
> specified date/time, it can't simply look at current traffic (even if
> that information were available), which means you're basically limited
> to information shared by other users.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Mit freundlichen Gr??en
Herr Dipl. Math. Orges Leka

Mobil: 015751078391
Email: orges.leka at googlemail.com
Holzheimerstra?e 25
65549 Limburg


-- 
Mit freundlichen Gr??en
Herr Dipl. Math. Orges Leka

Mobil: 015751078391
Email: orges.leka at googlemail.com
Holzheimerstra?e 25
65549 Limburg

From rosuav at gmail.com  Mon Mar 16 16:31:09 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 17 Mar 2020 07:31:09 +1100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
 
Message-ID: 

On Tue, Mar 17, 2020 at 7:21 AM Orges Leka  wrote:
> For the getting enough people to use it, I think word-of-mouth should work,
> as it would help those who use it, plus it reduces the chance of physical
> contact, so there is a win-win situation in using the app.
>
> Maybe if someone from the media promotes the app, this should boost it also.

In order to be usefully able to predict how many people will be at a
location, you'd need an appreciable proportion of them to be using
your app. Let's say you accept a 5% saturation (which is pretty low -
if only 5% of people use the app, there's still a LOT of uncertainty
in the estimated figures). Do you think you'll be able to get to the
point of having 5% of *all shoppers* in an area to start using your
app? That is a HUGE number of people to start using an app, and even
then, it would only give a low degree of confidence.

To the early adopters, your app is close to useless. That means word
of mouth isn't going to be very strong. It's something that depends
entirely on already having lots of users.

ChrisA

From orges.leka at gmail.com  Mon Mar 16 16:52:29 2020
From: orges.leka at gmail.com (Orges Leka)
Date: Mon, 16 Mar 2020 21:52:29 +0100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
 
 
Message-ID: 

Am Mo., 16. M?rz 2020 um 21:33 Uhr schrieb Chris Angelico :

> On Tue, Mar 17, 2020 at 7:21 AM Orges Leka  wrote:
> > For the getting enough people to use it, I think word-of-mouth should
> work,
> > as it would help those who use it, plus it reduces the chance of physical
> > contact, so there is a win-win situation in using the app.
> >
> > Maybe if someone from the media promotes the app, this should boost it
> also.
>
> In order to be usefully able to predict how many people will be at a
> location, you'd need an appreciable proportion of them to be using
> your app. Let's say you accept a 5% saturation (which is pretty low -
> if only 5% of people use the app, there's still a LOT of uncertainty
> in the estimated figures). Do you think you'll be able to get to the
> point of having 5% of *all shoppers* in an area to start using your
> app? That is a HUGE number of people to start using an app, and even
> then, it would only give a low degree of confidence.
>
> To the early adopters, your app is close to useless. That means word
> of mouth isn't going to be very strong. It's something that depends
> entirely on already having lots of users.
>
>
Following your reasoning, then radar detection apps / wikipedia / facebook,
which crucially depend on user generated content should not work....



> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Mit freundlichen Gr??en
Herr Dipl. Math. Orges Leka

Mobil: 015751078391
Email: orges.leka at googlemail.com
Holzheimerstra?e 25
65549 Limburg

From barry at barrys-emacs.org  Mon Mar 16 16:16:24 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Mon, 16 Mar 2020 20:16:24 +0000
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
Message-ID: 



> On 16 Mar 2020, at 17:38, Orges Leka  wrote:
> 
> Dear Python developers,
> 
> I am a data scientist and use Python regularly. I have a question:
> How difficult is it to write a Python web-app, with the following basic
> functionality:
> 
> The user writes anonymously without registration where (City, supermarket),
> when (Date and Time) he plans to go to the supermarket.

Without some security the site would be open to abuse.

> If this is done by a lot of users, the first user gets to see the number of
> other buyers at this supermarket and can better plan when to go shopping.
> This would reduce the waiting queue at the supermarket and possibly the
> contact to other people thus would help a little bit in slowing down the
> spread of the Corona virus.
> One could also add openstreetmap functionality to this.
> 
> As I am not a professional software developer, I can not predict how long
> it would take to write such a web-app in python.
> 
> If you do not have currently time, but know someone who would possibly be
> interested in working at this project, I would be happy if you let me know.

If you search google for a shop the right hand panel has a popular times
sections that tells you how busy the store typically is and the current busyness
estimate. Is that what you are after?

Barry

> 
> Kind regards,
> Orges Leka
> 
> -- 
> Mit freundlichen Gr??en
> Herr Dipl. Math. Orges Leka
> 
> Mobil: 015751078391
> Email: orges.leka at googlemail.com
> Holzheimerstra?e 25
> 65549 Limburg
> -- 
> https://mail.python.org/mailman/listinfo/python-list


From Irv at furrypants.com  Mon Mar 16 17:02:56 2020
From: Irv at furrypants.com (Irv Kalb)
Date: Mon, 16 Mar 2020 14:02:56 -0700
Subject: [Mostly OT] Feedback on Python homework using Canvas LMS
In-Reply-To: 
References: 
Message-ID: 

> On Mar 16, 2020, at 11:31 AM, Irv Kalb  wrote:
> 
> This is for anyone who teaches Python and uses the Canvas Learning Management System (maybe a small group).
> 
> I teach Python at two colleges in Silicon Valley in California.  At both schools we use Canvas.  Overall, it works very well.  I use it to post notes, sample programs, build tests, post homework, and correct homework assignment.  
> 
> However, there is a problem (bug!) when I give feedback on student's homework assignments.  I often give feedback by writing small snippets of code to explain what a student has done wrong, or how something could be done better.  The problem is that in the feedback section for homework assignments, Canvas eliminates any leading space characters.  So, I might write:
> 
> if x == y:
>   # do thing 1
> else:
>   # do thing 2
> 
> but when it gets posted and viewed by the student, it shows up as:
> 
> if x == y:
> # do thing 1
> else:
> # do thing 2
> 
> Which obviously is very annoying to me, and not as helpful to the student.  
> 
> Knowing that this happens, I have started to write feedback using periods for indenting:
> 
> if x == y:
> ....# do thing 1
> else:
> ....# do thing 2
> 
> I have posted about this problem on the Canvas board, pointing out the importance of leading spaces, but I've had no response.  I also even wrote the company through snail mail, and got no response.
> 
> Question 1:  Does anyone have any suggestions for indenting besides using periods?
> 
> Question 2:  Does anyone know any other way to reach the appropriate person(s) at Canvas to address this issue.
> 
> Thanks,
> 
> Irv
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

Thanks to MRAB and Ethan for their quick responses.

I like both suggestions, and will probably go with the non-breaking space (Option space on my Mac).  I tested that and it works well.

Irv


From ethan at stoneleaf.us  Mon Mar 16 17:19:38 2020
From: ethan at stoneleaf.us (Ethan Furman)
Date: Mon, 16 Mar 2020 14:19:38 -0700
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
 
 
 
Message-ID: 

On 03/16/2020 01:52 PM, Orges Leka wrote:

> Following your reasoning, then radar detection apps / wikipedia / facebook,
> which crucially depend on user generated content should not work....

Those are global apps, and one user's content can be useful in another user's country.

Who's shopping at the grocery store 100 miles away from me is useless.

--
~Ethan~

From ethan at stoneleaf.us  Mon Mar 16 17:20:35 2020
From: ethan at stoneleaf.us (Ethan Furman)
Date: Mon, 16 Mar 2020 14:20:35 -0700
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
Message-ID: <10f749fb-8ae2-da6e-fb25-82fb99d7a9da@stoneleaf.us>

On 03/16/2020 01:16 PM, Barry Scott wrote:

> If you search google for a shop the right hand panel has a popular times
> sections that tells you how busy the store typically is and the current busyness
> estimate. Is that what you are after?

I suspect that's the general idea, only in real-time.

--
~Ethan~

From rosuav at gmail.com  Mon Mar 16 17:05:20 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 17 Mar 2020 08:05:20 +1100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
 
 
 
Message-ID: 

On Tue, Mar 17, 2020 at 7:54 AM Orges Leka  wrote:
>
> Am Mo., 16. M?rz 2020 um 21:33 Uhr schrieb Chris Angelico  >:
>
> > On Tue, Mar 17, 2020 at 7:21 AM Orges Leka  wrote:
> > > For the getting enough people to use it, I think word-of-mouth should
> > work,
> > > as it would help those who use it, plus it reduces the chance of physical
> > > contact, so there is a win-win situation in using the app.
> > >
> > > Maybe if someone from the media promotes the app, this should boost it
> > also.
> >
> > In order to be usefully able to predict how many people will be at a
> > location, you'd need an appreciable proportion of them to be using
> > your app. Let's say you accept a 5% saturation (which is pretty low -
> > if only 5% of people use the app, there's still a LOT of uncertainty
> > in the estimated figures). Do you think you'll be able to get to the
> > point of having 5% of *all shoppers* in an area to start using your
> > app? That is a HUGE number of people to start using an app, and even
> > then, it would only give a low degree of confidence.
> >
> > To the early adopters, your app is close to useless. That means word
> > of mouth isn't going to be very strong. It's something that depends
> > entirely on already having lots of users.
> >
> >
> Following your reasoning, then radar detection apps / wikipedia / facebook,
> which crucially depend on user generated content should not work....
>

I don't know very much about radar detection, but I suspect that it
can be useful even if only a very small percentage of people use it.
Same with Wikipedia. (Facebook isn't useful even now, so that doesn't
really count.) But to be able to recognize when a shop is going to be
busy and when it's going to be quiet, you actually need to be able to
predict the movements of a lot of people, which means you need either
a very large proportion of people to be using your app, or some other
source of data.

As an example, consider: Suppose a mere 100 people are using
Wikipedia. Those people can create articles (perhaps lifting content
heavily from other sources, if the licenses are compatible), read
articles, edit them, etc, etc. It's not going to be a huge success,
but it is at least useful. And the 101st person to start using
Wikipedia can see some informative articles and learn from them,
and/or see an inaccuracy and correct it. It has value.

But consider that 100 people are using your app. If each person plans
to go shopping every two weeks (yes, I know a lot of people shop more
frequently than that, but ideally they'll be reducing the number of
trips for the same reason that they're trying to go when it's quiet),
then you have an average of 7-10 shoppers per day. Distribute those
shoppers among a set of time slots, and most likely you'll have
between 0 and 3 registered users in each time slot. Now consider: in
the scale of shop activity, how much can you learn by knowing the
movements of just three people? The entire point of the app is to
change people's actions, so you can't assume that the figures you have
are representative. The app actually has no value whatsoever with just
100 people using it.

In order to be useful, you FIRST have to achieve a significant level
of usage. That's extremely hard for a brand new app, so you would need
to leverage some existing data or usage somewhere.

ChrisA

From joseph2001nail at gmail.com  Mon Mar 16 17:19:09 2020
From: joseph2001nail at gmail.com (Joseph Nail)
Date: Mon, 16 Mar 2020 22:19:09 +0100
Subject: Can you help me solve this?
In-Reply-To: 
References: 
Message-ID: 

Hello,
I have one problem. Somehow in my function when I wrote y=x, they are the
same variable and then it also changes age or height (which were x) in the
main program. See more in attached file.
Maybe it is bug or maybe it should run that way.

From ikorot01 at gmail.com  Mon Mar 16 17:53:24 2020
From: ikorot01 at gmail.com (Igor Korot)
Date: Mon, 16 Mar 2020 16:53:24 -0500
Subject: Can you help me solve this?
In-Reply-To: 
References: 
 
Message-ID: 

Hi,

On Mon, Mar 16, 2020 at 4:26 PM Joseph Nail  wrote:
>
> Hello,
> I have one problem. Somehow in my function when I wrote y=x, they are the
> same variable and then it also changes age or height (which were x) in the
> main program. See more in attached file.
> Maybe it is bug or maybe it should run that way.

This is the text only ML -> NO ATTACHMENT.

Please copy and paste the code inside the E-mail body send it out.

Thank you,

> --
> https://mail.python.org/mailman/listinfo/python-list

From barry at barrys-emacs.org  Mon Mar 16 17:55:46 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Mon, 16 Mar 2020 21:55:46 +0000
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
Message-ID: 



> On 16 Mar 2020, at 17:38, Orges Leka  wrote:
> 
> Dear Python developers,
> 
> I am a data scientist and use Python regularly. I have a question:
> How difficult is it to write a Python web-app, with the following basic
> functionality:

Am I right in thinking that you are wondering how to help people visit the super market
in a quite time to help with the social distancing for COVID-19 reasons?

This is an interesting idea. I think if it was a app on Android or Apple it
might be easier to get users, but harder to write.

Maybe exploiting something like https://www.ushahidi.com/  is an alternative?

Barry


> 
> The user writes anonymously without registration where (City, supermarket),
> when (Date and Time) he plans to go to the supermarket.
> If this is done by a lot of users, the first user gets to see the number of
> other buyers at this supermarket and can better plan when to go shopping.
> This would reduce the waiting queue at the supermarket and possibly the
> contact to other people thus would help a little bit in slowing down the
> spread of the Corona virus.
> One could also add openstreetmap functionality to this.
> 
> As I am not a professional software developer, I can not predict how long
> it would take to write such a web-app in python.
> 
> If you do not have currently time, but know someone who would possibly be
> interested in working at this project, I would be happy if you let me know.
> 
> Kind regards,
> Orges Leka
> 
> -- 
> Mit freundlichen Gr??en
> Herr Dipl. Math. Orges Leka
> 
> Mobil: 015751078391
> Email: orges.leka at googlemail.com
> Holzheimerstra?e 25
> 65549 Limburg
> -- 
> https://mail.python.org/mailman/listinfo/python-list


From grant.b.edwards at gmail.com  Mon Mar 16 17:49:20 2020
From: grant.b.edwards at gmail.com (Grant Edwards)
Date: Mon, 16 Mar 2020 21:49:20 -0000 (UTC)
Subject: [Mostly OT] Feedback on Python homework using Canvas LMS
References: 
 
Message-ID: 

On 2020-03-16, Irv Kalb  wrote:

> I like both suggestions, and will probably go with the non-breaking
> space (Option space on my Mac).  I tested that and it works well.

Until somebody tries to cut/paste the snippets you post into a .py
file and run them.  At that point the "distance learning" setup is
definitely good, because you really don't want to hear the names
you'll be called.  ;)





From pieter-l at vanoostrum.org  Mon Mar 16 18:22:57 2020
From: pieter-l at vanoostrum.org (Pieter van Oostrum)
Date: Mon, 16 Mar 2020 23:22:57 +0100
Subject: Can you help me solve this?
References: 
 
 
Message-ID: 

Joseph Nail  writes:

> Hello,
> I have one problem. Somehow in my function when I wrote y=x, they are the
> same variable and then it also changes age or height (which were x) in the
> main program. See more in attached file.
> Maybe it is bug or maybe it should run that way.

If you write y = x, then they are not the same variable, but they point to (the proper Python language is they are bound to) the same object.

Now if you say x.age = 20, then y.age will also be 20 (it's the same object).
-- 
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

From pieter-l at vanoostrum.org  Mon Mar 16 18:26:51 2020
From: pieter-l at vanoostrum.org (Pieter van Oostrum)
Date: Mon, 16 Mar 2020 23:26:51 +0100
Subject: Can you help me solve this?
References: 
 
 
 
Message-ID: 

Pieter van Oostrum  writes:

> Joseph Nail  writes:
>
>> Hello,
>> I have one problem. Somehow in my function when I wrote y=x, they are the
>> same variable and then it also changes age or height (which were x) in the
>> main program. See more in attached file.
>> Maybe it is bug or maybe it should run that way.
>
> If you write y = x, then they are not the same variable, but they point
> to (the proper Python language is they are bound to) the same object.
>
> Now if you say x.age = 20, then y.age will also be 20 (it's the same object).

If you want y to be an independent copy of x (i.e. a new object that has the same values), use:

import copy
y = copy.copy(x)

Now you can change x.age and it won't affect y.age
-- 
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

From orges.leka at gmail.com  Mon Mar 16 19:37:09 2020
From: orges.leka at gmail.com (Orges Leka)
Date: Tue, 17 Mar 2020 00:37:09 +0100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
Message-ID: 

Barry Scott  schrieb am Mo., 16. M?rz 2020, 22:55:

>
>
> On 16 Mar 2020, at 17:38, Orges Leka  wrote:
>
> Dear Python developers,
>
> I am a data scientist and use Python regularly. I have a question:
> How difficult is it to write a Python web-app, with the following basic
> functionality:
>
>
> Am I right in thinking that you are wondering how to help people visit the
> super market
> in a quite time to help with the social distancing for COVID-19 reasons?
>

Yes, that is the intention.


This is an interesting idea. I think if it was a app on Android or Apple it
> might be easier to get users, but harder to write.
>
> Maybe exploiting something like https://www.ushahidi.com/ is an
> alternative?
>
> Barry
>
>
>
> The user writes anonymously without registration where (City, supermarket),
> when (Date and Time) he plans to go to the supermarket.
> If this is done by a lot of users, the first user gets to see the number of
> other buyers at this supermarket and can better plan when to go shopping.
> This would reduce the waiting queue at the supermarket and possibly the
> contact to other people thus would help a little bit in slowing down the
> spread of the Corona virus.
> One could also add openstreetmap functionality to this.
>
> As I am not a professional software developer, I can not predict how long
> it would take to write such a web-app in python.
>
> If you do not have currently time, but know someone who would possibly be
> interested in working at this project, I would be happy if you let me know.
>
> Kind regards,
> Orges Leka
>
> --
> Mit freundlichen Gr??en
> Herr Dipl. Math. Orges Leka
>
> Mobil: 015751078391
> Email: orges.leka at googlemail.com 
> Holzheimerstra?e 25
> 65549 Limburg
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
>

From python at mrabarnett.plus.com  Mon Mar 16 19:41:46 2020
From: python at mrabarnett.plus.com (MRAB)
Date: Mon, 16 Mar 2020 23:41:46 +0000
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
Message-ID: 

On 2020-03-16 21:55, Barry Scott wrote:
> 
> 
>> On 16 Mar 2020, at 17:38, Orges Leka  wrote:
>> 
>> Dear Python developers,
>> 
>> I am a data scientist and use Python regularly. I have a question:
>> How difficult is it to write a Python web-app, with the following basic
>> functionality:
> 
> Am I right in thinking that you are wondering how to help people visit the super market
> in a quite time to help with the social distancing for COVID-19 reasons?
> 
> This is an interesting idea. I think if it was a app on Android or Apple it
> might be easier to get users, but harder to write.
> 
> Maybe exploiting something like https://www.ushahidi.com/  is an alternative?
> 
Or something like Tinder, except that you're trying _not_ to meet 
people. :-)

From none at invalid.com  Mon Mar 16 19:48:17 2020
From: none at invalid.com (mm0fmf)
Date: Mon, 16 Mar 2020 23:48:17 +0000
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
Message-ID: 

On 16/03/2020 21:55, Barry Scott wrote:
> Am I right in thinking that you are wondering how to help people visit the super market
> in a quite time to help with the social distancing for COVID-19 reasons?

In which case all the app needs to do is tell people that the 
supermarket A has great stocks of toilet paper, pasta, dried milk, beans 
etc. so that the users flock to supermarket A to panic buy and fight 
over the stock. Meanwhile you can visit supermarket B at the same time 
which will be quiet.  You get a safer shopping trip.

Or have I got this wrong?




From PythonList at DancesWithMice.info  Mon Mar 16 23:47:36 2020
From: PythonList at DancesWithMice.info (DL Neil)
Date: Tue, 17 Mar 2020 16:47:36 +1300
Subject: [Mostly OT] Feedback on Python homework using Canvas LMS
In-Reply-To: 
References: 
 
 
Message-ID: 

On 17/03/20 10:49 AM, Grant Edwards wrote:
> On 2020-03-16, Irv Kalb  wrote:
> 
>> I like both suggestions, and will probably go with the non-breaking
>> space (Option space on my Mac).  I tested that and it works well.
> 
> Until somebody tries to cut/paste the snippets you post into a .py
> file and run them.  At that point the "distance learning" setup is
> definitely good, because you really don't want to hear the names
> you'll be called.  ;)

Exactly - and if the 'victim' (literally) cannot see why copy-pasted 
code is being violently rejected, learning objectives will be soundly 
defeated!


Whereas "spaces" have been mentioned (and without wishing to enter into 
a 'religious war'), what happens if the white-space character is a tab?

Failing that, consider adding a visible character, eg the 'right arrow' 
that is occasionally used to indicate paragraph-like indentation in 
other contexts. Would still require the trainees to post-edit though - 
albeit only a single global find-replace.


Similar problems existed on Moodle (may not now, or may have an add-on 
solution) and edX (which does have a built-in solution).

Might Canvas (I haven't used that LMS) permit the embedding of a 
"frame"? (allowing greater formatting freedom/character choices within 
its 'enclosure')


Another option may be to link to a post on a 'snippet site' - most seem 
JavaScript-oriented, but may also support, or at least tolerate, Python.


WebRefs:
https://en.wikipedia.org/wiki/Pastebin
https://pastebin.com/
https://codepen.io/
https://jsfiddle.net/
https://gist.github.com/discover

or, to keep things in-house (and possibly better indexed/reusable):
https://gogs.io/
-- 
Regards =dn

From souvik.viksou at gmail.com  Tue Mar 17 00:49:08 2020
From: souvik.viksou at gmail.com (Souvik Dutta)
Date: Tue, 17 Mar 2020 10:19:08 +0530
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
Message-ID: 

I think you might get a man build the app in a manner that allows the
people at the supermarket to update the foot falls of the customers in a
given time period. Like one might count the number on 10 am for a period of
fifteen minutes and say that this will be the number of persons in the mall
for at least an hour, because generally that is the time we spent in
supermarkets.
Then this number could be updated to the customers so that they could plan
accordingly. This will though have a waiting time for the peoples to get
good updates.
And to avoid discrepancy the supermarket workers (s.w) can update the
information when large number of people start coming in to the store.


On Tue, Mar 17, 2020, 12:54 AM Orges Leka  wrote:

> Dear Python developers,
>
> I am a data scientist and use Python regularly. I have a question:
> How difficult is it to write a Python web-app, with the following basic
> functionality:
>
> The user writes anonymously without registration where (City, supermarket),
> when (Date and Time) he plans to go to the supermarket.
> If this is done by a lot of users, the first user gets to see the number of
> other buyers at this supermarket and can better plan when to go shopping.
> This would reduce the waiting queue at the supermarket and possibly the
> contact to other people thus would help a little bit in slowing down the
> spread of the Corona virus.
> One could also add openstreetmap functionality to this.
>
> As I am not a professional software developer, I can not predict how long
> it would take to write such a web-app in python.
>
> If you do not have currently time, but know someone who would possibly be
> interested in working at this project, I would be happy if you let me know.
>
> Kind regards,
> Orges Leka
>
> --
> Mit freundlichen Gr??en
> Herr Dipl. Math. Orges Leka
>
> Mobil: 015751078391
> Email: orges.leka at googlemail.com
> Holzheimerstra?e 25
> 65549 Limburg
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From souvik.viksou at gmail.com  Tue Mar 17 02:21:18 2020
From: souvik.viksou at gmail.com (Souvik Dutta)
Date: Tue, 17 Mar 2020 11:51:18 +0530
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
Message-ID: 

This app might also give real time updates.

On Tue, Mar 17, 2020, 10:19 AM Souvik Dutta  wrote:

> I think you might get a man build the app in a manner that allows the
> people at the supermarket to update the foot falls of the customers in a
> given time period. Like one might count the number on 10 am for a period of
> fifteen minutes and say that this will be the number of persons in the mall
> for at least an hour, because generally that is the time we spent in
> supermarkets.
> Then this number could be updated to the customers so that they could plan
> accordingly. This will though have a waiting time for the peoples to get
> good updates.
> And to avoid discrepancy the supermarket workers (s.w) can update the
> information when large number of people start coming in to the store.
>
>
> On Tue, Mar 17, 2020, 12:54 AM Orges Leka  wrote:
>
>> Dear Python developers,
>>
>> I am a data scientist and use Python regularly. I have a question:
>> How difficult is it to write a Python web-app, with the following basic
>> functionality:
>>
>> The user writes anonymously without registration where (City,
>> supermarket),
>> when (Date and Time) he plans to go to the supermarket.
>> If this is done by a lot of users, the first user gets to see the number
>> of
>> other buyers at this supermarket and can better plan when to go shopping.
>> This would reduce the waiting queue at the supermarket and possibly the
>> contact to other people thus would help a little bit in slowing down the
>> spread of the Corona virus.
>> One could also add openstreetmap functionality to this.
>>
>> As I am not a professional software developer, I can not predict how long
>> it would take to write such a web-app in python.
>>
>> If you do not have currently time, but know someone who would possibly be
>> interested in working at this project, I would be happy if you let me
>> know.
>>
>> Kind regards,
>> Orges Leka
>>
>> --
>> Mit freundlichen Gr??en
>> Herr Dipl. Math. Orges Leka
>>
>> Mobil: 015751078391
>> Email: orges.leka at googlemail.com
>> Holzheimerstra?e 25
>> 65549 Limburg
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>

From greg.ewing at canterbury.ac.nz  Tue Mar 17 03:32:11 2020
From: greg.ewing at canterbury.ac.nz (Greg Ewing)
Date: Tue, 17 Mar 2020 20:32:11 +1300
Subject: `async def` breaks encapsulation?
In-Reply-To: 
References: 
 
Message-ID: 

On 4/03/20 12:52 pm, Marco Sulla wrote:
> Why can't an asynchronous coroutine be simply a coroutine that has an
> `async` or an `await` in its code, without `async` in the signature?

That wouldn't help as much as you seem to think. You still need
to use 'await' whenever you call a coroutine, so switching a
function between coroutine and non-coroutine would still have
just as much of a ripple effect on the rest of your code.

-- 
Greg


From mal at europython.eu  Tue Mar 17 05:46:15 2020
From: mal at europython.eu (M.-A. Lemburg)
Date: Tue, 17 Mar 2020 10:46:15 +0100
Subject: EuroPython 2020: Going virtual / EuroPython 2021: Dublin, Ireland
Message-ID: 

In our blog post on the COVID-19 last week, we were still hopeful that
the situation would improve in time for the event in July. The last
few days have shown us that we need to have a more realistic view on
how things will develop in the coming months:

https://blog.europython.eu/post/612393987829039104/europython-2020-and-covid-19

Right now, we are at a point in the conference organization where we
have invested a lot of time into the preparation of the conference,
but have not started ticket sales, entered sponsorship agreements or
ordered conference and marketing material.

We also had discussions with the venue and caterer on possible options
to address the risk of not being able to hold the event in July due to
government regulations preventing indoor gatherings.


EuroPython 2021
---------------

In our EuroPython Society Board call last night, we discussed the
situation, looked at the options and decided to take the offer of the
venue to postpone the in-person conference to next year.


	 * EuroPython 2021 will be held in Dublin, Ireland, *
		   * from July 26 - August 1 2021 *


How about a virtual EuroPython 2020 ?
-------------------------------------

Since we all love EuroPython, the community and good vibes coming from
such gatherings, we are now considering turning this year?s EuroPython
2020 conference into a virtual event.

For this, we?d like to gather some feedback and have created a form
for you to let us know what your thoughts are on such a virtual setup:


	   * EuroPython 2020 going virtual feedback form *

		 https://forms.gle/dwMYXVR4RFAqvthP6


If we go for the virtual setup for EuroPython 2020, the dates will
likely change a bit, so ticket sales will start a little later. For
now, we will leave the EuroPython 2020 Call for Proposals (CfP)
open. Please note that those talks will then have to be held from your
notebook/desktop without face-to-face audience contact. On the other
hand, many more people could join in, since there?s no travel
involved. We will aim to make the virtual event as interactive as
possible.


Code name: EuroPython Winter Edition
------------------------------------

While we?re at it, we?d also like to use the form to gather some
feedback on the idea to have a winter EuroPython event, one where we
run a BarCamp/Sprint/Hackathon style setup in a smaller setting.


Help spread the word
--------------------

Please help us spread this message by sharing it on your social
networks as widely as possible. Thank you !

Link to the blog post:

https://blog.europython.eu/post/612826526375919616/europython-2020-going-virtual-europython-2021

Tweet:

https://twitter.com/europython/status/1239845360694067201

Thanks,
--
EuroPython 2020 Team
https://ep2020.europython.eu/
https://www.europython-society.org/


From orges.leka at gmail.com  Tue Mar 17 06:16:34 2020
From: orges.leka at gmail.com (Orges Leka)
Date: Tue, 17 Mar 2020 11:16:34 +0100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
Message-ID: 

The web-app could be a simple as one button:

If users are before supermarket and there is a long queue, they click on
the web-app button and warn other users of the queue.

The same principle works for anti-traffi-jam apps, with user generated
content.

If someone would like to work on this project, please let me know.



Am Di., 17. M?rz 2020 um 07:21 Uhr schrieb Souvik Dutta <
souvik.viksou at gmail.com>:

> This app might also give real time updates.
>
> On Tue, Mar 17, 2020, 10:19 AM Souvik Dutta 
> wrote:
>
>> I think you might get a man build the app in a manner that allows the
>> people at the supermarket to update the foot falls of the customers in a
>> given time period. Like one might count the number on 10 am for a period of
>> fifteen minutes and say that this will be the number of persons in the mall
>> for at least an hour, because generally that is the time we spent in
>> supermarkets.
>> Then this number could be updated to the customers so that they could
>> plan accordingly. This will though have a waiting time for the peoples to
>> get good updates.
>> And to avoid discrepancy the supermarket workers (s.w) can update the
>> information when large number of people start coming in to the store.
>>
>>
>> On Tue, Mar 17, 2020, 12:54 AM Orges Leka  wrote:
>>
>>> Dear Python developers,
>>>
>>> I am a data scientist and use Python regularly. I have a question:
>>> How difficult is it to write a Python web-app, with the following basic
>>> functionality:
>>>
>>> The user writes anonymously without registration where (City,
>>> supermarket),
>>> when (Date and Time) he plans to go to the supermarket.
>>> If this is done by a lot of users, the first user gets to see the number
>>> of
>>> other buyers at this supermarket and can better plan when to go shopping.
>>> This would reduce the waiting queue at the supermarket and possibly the
>>> contact to other people thus would help a little bit in slowing down the
>>> spread of the Corona virus.
>>> One could also add openstreetmap functionality to this.
>>>
>>> As I am not a professional software developer, I can not predict how long
>>> it would take to write such a web-app in python.
>>>
>>> If you do not have currently time, but know someone who would possibly be
>>> interested in working at this project, I would be happy if you let me
>>> know.
>>>
>>> Kind regards,
>>> Orges Leka
>>>
>>> --
>>> Mit freundlichen Gr??en
>>> Herr Dipl. Math. Orges Leka
>>>
>>> Mobil: 015751078391
>>> Email: orges.leka at googlemail.com
>>> Holzheimerstra?e 25
>>> 65549 Limburg
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>

-- 
Mit freundlichen Gr??en
Herr Dipl. Math. Orges Leka

Mobil: 015751078391
Email: orges.leka at googlemail.com
Holzheimerstra?e 25
65549 Limburg

From mystirk at gmail.com  Tue Mar 17 09:52:39 2020
From: mystirk at gmail.com (Alex Kaye)
Date: Tue, 17 Mar 2020 06:52:39 -0700
Subject: EuroPython 2020: Going virtual / EuroPython 2021: Dublin, Ireland
In-Reply-To: 
References: 
Message-ID: 

Glad to read this.

It is about time to benefit those of us

that do not travel to events.

AK

On Tue, Mar 17, 2020 at 2:52 AM M.-A. Lemburg  wrote:

> In our blog post on the COVID-19 last week, we were still hopeful that
> the situation would improve in time for the event in July. The last
> few days have shown us that we need to have a more realistic view on
> how things will develop in the coming months:
>
>
> https://blog.europython.eu/post/612393987829039104/europython-2020-and-covid-19
>
> Right now, we are at a point in the conference organization where we
> have invested a lot of time into the preparation of the conference,
> but have not started ticket sales, entered sponsorship agreements or
> ordered conference and marketing material.
>
> We also had discussions with the venue and caterer on possible options
> to address the risk of not being able to hold the event in July due to
> government regulations preventing indoor gatherings.
>
>
> EuroPython 2021
> ---------------
>
> In our EuroPython Society Board call last night, we discussed the
> situation, looked at the options and decided to take the offer of the
> venue to postpone the in-person conference to next year.
>
>
>          * EuroPython 2021 will be held in Dublin, Ireland, *
>                    * from July 26 - August 1 2021 *
>
>
> How about a virtual EuroPython 2020 ?
> -------------------------------------
>
> Since we all love EuroPython, the community and good vibes coming from
> such gatherings, we are now considering turning this year?s EuroPython
> 2020 conference into a virtual event.
>
> For this, we?d like to gather some feedback and have created a form
> for you to let us know what your thoughts are on such a virtual setup:
>
>
>            * EuroPython 2020 going virtual feedback form *
>
>                  https://forms.gle/dwMYXVR4RFAqvthP6
>
>
> If we go for the virtual setup for EuroPython 2020, the dates will
> likely change a bit, so ticket sales will start a little later. For
> now, we will leave the EuroPython 2020 Call for Proposals (CfP)
> open. Please note that those talks will then have to be held from your
> notebook/desktop without face-to-face audience contact. On the other
> hand, many more people could join in, since there?s no travel
> involved. We will aim to make the virtual event as interactive as
> possible.
>
>
> Code name: EuroPython Winter Edition
> ------------------------------------
>
> While we?re at it, we?d also like to use the form to gather some
> feedback on the idea to have a winter EuroPython event, one where we
> run a BarCamp/Sprint/Hackathon style setup in a smaller setting.
>
>
> Help spread the word
> --------------------
>
> Please help us spread this message by sharing it on your social
> networks as widely as possible. Thank you !
>
> Link to the blog post:
>
>
> https://blog.europython.eu/post/612826526375919616/europython-2020-going-virtual-europython-2021
>
> Tweet:
>
> https://twitter.com/europython/status/1239845360694067201
>
> Thanks,
> --
> EuroPython 2020 Team
> https://ep2020.europython.eu/
> https://www.europython-society.org/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From uri at speedy.net  Tue Mar 17 10:07:34 2020
From: uri at speedy.net (=?UTF-8?B?15DXldeo15k=?=)
Date: Tue, 17 Mar 2020 16:07:34 +0200
Subject: EuroPython 2020: Going virtual / EuroPython 2021: Dublin, Ireland
In-Reply-To: 
References: 
Message-ID: 

Hi,

I also don't usually attend conferences abroad, but I would like to
participate in a virtual conference if possible. I would also suggest that
a virtual conference would not require registration or paying for tickets.
I hope you will find a way to get the money from sponsors or other
resources and not from participants. In the past I did attend conferences
abroad and it was very expensive.

Uri.
????
uri at speedy.net


On Tue, Mar 17, 2020 at 11:50 AM M.-A. Lemburg  wrote:

> In our blog post on the COVID-19 last week, we were still hopeful that
> the situation would improve in time for the event in July. The last
> few days have shown us that we need to have a more realistic view on
> how things will develop in the coming months:
>
>
> https://blog.europython.eu/post/612393987829039104/europython-2020-and-covid-19
>
> Right now, we are at a point in the conference organization where we
> have invested a lot of time into the preparation of the conference,
> but have not started ticket sales, entered sponsorship agreements or
> ordered conference and marketing material.
>
> We also had discussions with the venue and caterer on possible options
> to address the risk of not being able to hold the event in July due to
> government regulations preventing indoor gatherings.
>
>
> EuroPython 2021
> ---------------
>
> In our EuroPython Society Board call last night, we discussed the
> situation, looked at the options and decided to take the offer of the
> venue to postpone the in-person conference to next year.
>
>
>          * EuroPython 2021 will be held in Dublin, Ireland, *
>                    * from July 26 - August 1 2021 *
>
>
> How about a virtual EuroPython 2020 ?
> -------------------------------------
>
> Since we all love EuroPython, the community and good vibes coming from
> such gatherings, we are now considering turning this year?s EuroPython
> 2020 conference into a virtual event.
>
> For this, we?d like to gather some feedback and have created a form
> for you to let us know what your thoughts are on such a virtual setup:
>
>
>            * EuroPython 2020 going virtual feedback form *
>
>                  https://forms.gle/dwMYXVR4RFAqvthP6
>
>
> If we go for the virtual setup for EuroPython 2020, the dates will
> likely change a bit, so ticket sales will start a little later. For
> now, we will leave the EuroPython 2020 Call for Proposals (CfP)
> open. Please note that those talks will then have to be held from your
> notebook/desktop without face-to-face audience contact. On the other
> hand, many more people could join in, since there?s no travel
> involved. We will aim to make the virtual event as interactive as
> possible.
>
>
> Code name: EuroPython Winter Edition
> ------------------------------------
>
> While we?re at it, we?d also like to use the form to gather some
> feedback on the idea to have a winter EuroPython event, one where we
> run a BarCamp/Sprint/Hackathon style setup in a smaller setting.
>
>
> Help spread the word
> --------------------
>
> Please help us spread this message by sharing it on your social
> networks as widely as possible. Thank you !
>
> Link to the blog post:
>
>
> https://blog.europython.eu/post/612826526375919616/europython-2020-going-virtual-europython-2021
>
> Tweet:
>
> https://twitter.com/europython/status/1239845360694067201
>
> Thanks,
> --
> EuroPython 2020 Team
> https://ep2020.europython.eu/
> https://www.europython-society.org/
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From joepareti54 at gmail.com  Tue Mar 17 10:35:12 2020
From: joepareti54 at gmail.com (joseph pareti)
Date: Tue, 17 Mar 2020 15:35:12 +0100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
 
Message-ID: 

the use case is VERY valuable.

In order to increase its penetration, how about writing the app as a plug
in for a more widely used one such as google maps?

Am Di., 17. M?rz 2020 um 11:20 Uhr schrieb Orges Leka :

> The web-app could be a simple as one button:
>
> If users are before supermarket and there is a long queue, they click on
> the web-app button and warn other users of the queue.
>
> The same principle works for anti-traffi-jam apps, with user generated
> content.
>
> If someone would like to work on this project, please let me know.
>
>
>
> Am Di., 17. M?rz 2020 um 07:21 Uhr schrieb Souvik Dutta <
> souvik.viksou at gmail.com>:
>
> > This app might also give real time updates.
> >
> > On Tue, Mar 17, 2020, 10:19 AM Souvik Dutta 
> > wrote:
> >
> >> I think you might get a man build the app in a manner that allows the
> >> people at the supermarket to update the foot falls of the customers in a
> >> given time period. Like one might count the number on 10 am for a
> period of
> >> fifteen minutes and say that this will be the number of persons in the
> mall
> >> for at least an hour, because generally that is the time we spent in
> >> supermarkets.
> >> Then this number could be updated to the customers so that they could
> >> plan accordingly. This will though have a waiting time for the peoples
> to
> >> get good updates.
> >> And to avoid discrepancy the supermarket workers (s.w) can update the
> >> information when large number of people start coming in to the store.
> >>
> >>
> >> On Tue, Mar 17, 2020, 12:54 AM Orges Leka  wrote:
> >>
> >>> Dear Python developers,
> >>>
> >>> I am a data scientist and use Python regularly. I have a question:
> >>> How difficult is it to write a Python web-app, with the following basic
> >>> functionality:
> >>>
> >>> The user writes anonymously without registration where (City,
> >>> supermarket),
> >>> when (Date and Time) he plans to go to the supermarket.
> >>> If this is done by a lot of users, the first user gets to see the
> number
> >>> of
> >>> other buyers at this supermarket and can better plan when to go
> shopping.
> >>> This would reduce the waiting queue at the supermarket and possibly the
> >>> contact to other people thus would help a little bit in slowing down
> the
> >>> spread of the Corona virus.
> >>> One could also add openstreetmap functionality to this.
> >>>
> >>> As I am not a professional software developer, I can not predict how
> long
> >>> it would take to write such a web-app in python.
> >>>
> >>> If you do not have currently time, but know someone who would possibly
> be
> >>> interested in working at this project, I would be happy if you let me
> >>> know.
> >>>
> >>> Kind regards,
> >>> Orges Leka
> >>>
> >>> --
> >>> Mit freundlichen Gr??en
> >>> Herr Dipl. Math. Orges Leka
> >>>
> >>> Mobil: 015751078391
> >>> Email: orges.leka at googlemail.com
> >>> Holzheimerstra?e 25
> >>> 65549 Limburg
> >>> --
> >>> https://mail.python.org/mailman/listinfo/python-list
> >>>
> >>
>
> --
> Mit freundlichen Gr??en
> Herr Dipl. Math. Orges Leka
>
> Mobil: 015751078391
> Email: orges.leka at googlemail.com
> Holzheimerstra?e 25
> 65549 Limburg
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644

From python at mrabarnett.plus.com  Tue Mar 17 11:05:01 2020
From: python at mrabarnett.plus.com (MRAB)
Date: Tue, 17 Mar 2020 15:05:01 +0000
Subject: [Mostly OT] Feedback on Python homework using Canvas LMS
In-Reply-To: 
References: 
 
 
Message-ID: <5c5ed98b-974b-5e34-d6d2-9d1b1c578ec5@mrabarnett.plus.com>

On 2020-03-16 21:49, Grant Edwards wrote:
> On 2020-03-16, Irv Kalb  wrote:
> 
>> I like both suggestions, and will probably go with the non-breaking
>> space (Option space on my Mac).  I tested that and it works well.
> 
> Until somebody tries to cut/paste the snippets you post into a .py
> file and run them.  At that point the "distance learning" setup is
> definitely good, because you really don't want to hear the names
> you'll be called.  ;)
> 
I've just tried using non-breaking spaces at the Python prompt in a 
Windows 10 console window. It treated them like spaces!

However, it complained when I used them in a file.

Are there actually any programming languages that will accept 
non-breaking spaces as an alternative to "normal" spaces?

From orges.leka at gmail.com  Tue Mar 17 11:13:10 2020
From: orges.leka at gmail.com (Orges Leka)
Date: Tue, 17 Mar 2020 16:13:10 +0100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
 
 
Message-ID: 

Am Di., 17. M?rz 2020 um 15:35 Uhr schrieb joseph pareti <
joepareti54 at gmail.com>:

> the use case is VERY valuable.
>
> In order to increase its penetration, how about writing the app as a plug
> in for a more widely used one such as google maps?
>
> I don't have the knowledge to do this. Besides I think that this can be
done only by Google ( see:
https://stackoverflow.com/questions/5629779/is-it-possible-to-create-a-plugin-built-on-top-of-google-maps-for-android
) . If you have contact to Google and suggest this, I think that would be a
VERY GOOD THING.

Am Di., 17. M?rz 2020 um 11:20 Uhr schrieb Orges Leka  >:
>
>> The web-app could be a simple as one button:
>>
>> If users are before supermarket and there is a long queue, they click on
>> the web-app button and warn other users of the queue.
>>
>> The same principle works for anti-traffi-jam apps, with user generated
>> content.
>>
>> If someone would like to work on this project, please let me know.
>>
>>
>>
>> Am Di., 17. M?rz 2020 um 07:21 Uhr schrieb Souvik Dutta <
>> souvik.viksou at gmail.com>:
>>
>> > This app might also give real time updates.
>> >
>> > On Tue, Mar 17, 2020, 10:19 AM Souvik Dutta 
>> > wrote:
>> >
>> >> I think you might get a man build the app in a manner that allows the
>> >> people at the supermarket to update the foot falls of the customers in
>> a
>> >> given time period. Like one might count the number on 10 am for a
>> period of
>> >> fifteen minutes and say that this will be the number of persons in the
>> mall
>> >> for at least an hour, because generally that is the time we spent in
>> >> supermarkets.
>> >> Then this number could be updated to the customers so that they could
>> >> plan accordingly. This will though have a waiting time for the peoples
>> to
>> >> get good updates.
>> >> And to avoid discrepancy the supermarket workers (s.w) can update the
>> >> information when large number of people start coming in to the store.
>> >>
>> >>
>> >> On Tue, Mar 17, 2020, 12:54 AM Orges Leka 
>> wrote:
>> >>
>> >>> Dear Python developers,
>> >>>
>> >>> I am a data scientist and use Python regularly. I have a question:
>> >>> How difficult is it to write a Python web-app, with the following
>> basic
>> >>> functionality:
>> >>>
>> >>> The user writes anonymously without registration where (City,
>> >>> supermarket),
>> >>> when (Date and Time) he plans to go to the supermarket.
>> >>> If this is done by a lot of users, the first user gets to see the
>> number
>> >>> of
>> >>> other buyers at this supermarket and can better plan when to go
>> shopping.
>> >>> This would reduce the waiting queue at the supermarket and possibly
>> the
>> >>> contact to other people thus would help a little bit in slowing down
>> the
>> >>> spread of the Corona virus.
>> >>> One could also add openstreetmap functionality to this.
>> >>>
>> >>> As I am not a professional software developer, I can not predict how
>> long
>> >>> it would take to write such a web-app in python.
>> >>>
>> >>> If you do not have currently time, but know someone who would
>> possibly be
>> >>> interested in working at this project, I would be happy if you let me
>> >>> know.
>> >>>
>> >>> Kind regards,
>> >>> Orges Leka
>> >>>
>> >>> --
>> >>> Mit freundlichen Gr??en
>> >>> Herr Dipl. Math. Orges Leka
>> >>>
>> >>> Mobil: 015751078391
>> >>> Email: orges.leka at googlemail.com
>> >>> Holzheimerstra?e 25
>> >>> 65549 Limburg
>> >>> --
>> >>> https://mail.python.org/mailman/listinfo/python-list
>> >>>
>> >>
>>
>> --
>> Mit freundlichen Gr??en
>> Herr Dipl. Math. Orges Leka
>>
>> Mobil: 015751078391
>> Email: orges.leka at googlemail.com
>> Holzheimerstra?e 25
>> 65549 Limburg
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>
> --
> Regards,
> Joseph Pareti - Artificial Intelligence consultant
> Joseph Pareti's AI Consulting Services
> https://www.joepareti54-ai.com/
> cell +49 1520 1600 209
> cell +39 339 797 0644
>


-- 
Mit freundlichen Gr??en
Herr Dipl. Math. Orges Leka

Mobil: 015751078391
Email: orges.leka at googlemail.com
Holzheimerstra?e 25
65549 Limburg

From nelle.varoquaux at gmail.com  Tue Mar 17 11:37:11 2020
From: nelle.varoquaux at gmail.com (Nelle Varoquaux)
Date: Tue, 17 Mar 2020 16:37:11 +0100
Subject: Announcing the 2020 John Hunter Excellence in Plotting Contest
Message-ID: 

Dear all,


I apologize for the cross-posting.


In memory of John Hunter, we are pleased to announce the John Hunter
Excellence in Plotting Contest for 2020. This open competition aims to
highlight the importance of data visualization to scientific progress and
showcase the capabilities of open source software.

Participants are invited to submit scientific plots to be judged by a
panel. The winning entries will be announced and displayed at SciPy 2020 or
announced in the John Hunter Excellence in Plotting Contest website and
youtube channel.

John Hunter?s family are graciously sponsoring cash prizes for the winners
in the following amounts:

- 1st prize: $1000

- 2nd prize: $750

- 3rd prize: $500


   -

   Entries must be submitted by June 1st to the form at
   https://forms.gle/SrexmkDwiAmDc7ej7
   -

   Winners will be announced at Scipy 2020 in Austin, TX or publicly on the
   John Hunter Excellence in Plotting Contest website and youtube channel
   -

   Participants do not need to attend the Scipy conference.
   -

   Entries may take the definition of ?visualization? rather broadly.
   Entries may be, for example, a traditional printed plot, an interactive
   visualization for the web, a dashboard, or an animation.
   -

   Source code for the plot must be provided, in the form of Python code
   and/or a Jupyter notebook, along with a rendering of the plot in a widely
   used format.  The rendering may be, for example, PDF for print, standalone
   HTML and Javascript for an interactive plot, or MPEG-4 for a video. If the
   original data can not be shared for reasons of size or licensing, "fake"
   data may be substituted, along with an image of the plot using real data.
   -

   Each entry must include a 300-500 word abstract describing the plot and
   its importance for a general scientific audience.
   -

   Entries will be judged on their clarity, innovation and aesthetics, but
   most importantly for their effectiveness in communicating a real-world
   problem. Entrants are encouraged to submit plots that were used during the
   course of research or work, rather than merely being hypothetical.
   -

   SciPy and the John Hunter Excellence in Plotting Contest organizers
   reserves the right to display any and all entries, whether prize-winning or
   not, at the conference, use in any materials or on its website, with
   attribution to the original author(s).
   -

   Past entries can be found at https://jhepc.github.io/
   -

   Questions regarding the contest can be sent to jhepc.organizers at gmail.com



John Hunter Excellence in Plotting Contest Co-Chairs

Madicken Munk

Nelle Varoquaux

From auriocus at gmx.de  Tue Mar 17 17:57:44 2020
From: auriocus at gmx.de (Christian Gollwitzer)
Date: Tue, 17 Mar 2020 22:57:44 +0100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
 
 
Message-ID: 

Am 17.03.20 um 11:16 schrieb Orges Leka:
> The web-app could be a simple as one button:
> 
> If users are before supermarket and there is a long queue, they click on
> the web-app button and warn other users of the queue.

It might be possible to make a Facebook "app" out of it. Facebook 
already provides a "login" feature, where it autodetects if you are near 
som point of interest and you only need to confirm that you want to be 
there. Also, the Facebook user base is extensive.

> The same principle works for anti-traffi-jam apps, with user generated
> content.
> 
> If someone would like to work on this project, please let me know.
> 

There is one obvious candidate who could work on this project. It's you.

Best regards,

	Christian

From orges.leka at gmail.com  Wed Mar 18 03:06:03 2020
From: orges.leka at gmail.com (Orges Leka)
Date: Wed, 18 Mar 2020 08:06:03 +0100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
 
 
 
Message-ID: 

Thanks Christian for your suggestion.

I made the start here
https://github.com/orgesleka/supermarket-waiting-queue-alarm
The incomplete Flask/Jquery app is hosted here:
http://www.orges-leka.de/limburg.html
If someone can contribute by hosting this app for his city/community and
spreading the link to his friends, that would be a great thing to help.
If someone with better knowledge in Flask/Jquery can contribute code to
this, that would also be great.

Kind regards,
Orges

Am Di., 17. M?rz 2020 um 23:02 Uhr schrieb Christian Gollwitzer <
auriocus at gmx.de>:

> Am 17.03.20 um 11:16 schrieb Orges Leka:
> > The web-app could be a simple as one button:
> >
> > If users are before supermarket and there is a long queue, they click on
> > the web-app button and warn other users of the queue.
>
> It might be possible to make a Facebook "app" out of it. Facebook
> already provides a "login" feature, where it autodetects if you are near
> som point of interest and you only need to confirm that you want to be
> there. Also, the Facebook user base is extensive.
>
> > The same principle works for anti-traffi-jam apps, with user generated
> > content.
> >
> > If someone would like to work on this project, please let me know.
> >
>
> There is one obvious candidate who could work on this project. It's you.
>
> Best regards,
>
>         Christian
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Mit freundlichen Gr??en
Herr Dipl. Math. Orges Leka

Mobil: 015751078391
Email: orges.leka at googlemail.com
Holzheimerstra?e 25
65549 Limburg

From joepareti54 at gmail.com  Wed Mar 18 04:04:09 2020
From: joepareti54 at gmail.com (joseph pareti)
Date: Wed, 18 Mar 2020 09:04:09 +0100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
 
 
 
 
Message-ID: 

all right, I have informed my contact person at Facebook. I'll let you know
if anything positive comes out of it

Am Mi., 18. M?rz 2020 um 08:09 Uhr schrieb Orges Leka :

> Thanks Christian for your suggestion.
>
> I made the start here
> https://github.com/orgesleka/supermarket-waiting-queue-alarm
> The incomplete Flask/Jquery app is hosted here:
> http://www.orges-leka.de/limburg.html
> If someone can contribute by hosting this app for his city/community and
> spreading the link to his friends, that would be a great thing to help.
> If someone with better knowledge in Flask/Jquery can contribute code to
> this, that would also be great.
>
> Kind regards,
> Orges
>
> Am Di., 17. M?rz 2020 um 23:02 Uhr schrieb Christian Gollwitzer <
> auriocus at gmx.de>:
>
> > Am 17.03.20 um 11:16 schrieb Orges Leka:
> > > The web-app could be a simple as one button:
> > >
> > > If users are before supermarket and there is a long queue, they click
> on
> > > the web-app button and warn other users of the queue.
> >
> > It might be possible to make a Facebook "app" out of it. Facebook
> > already provides a "login" feature, where it autodetects if you are near
> > som point of interest and you only need to confirm that you want to be
> > there. Also, the Facebook user base is extensive.
> >
> > > The same principle works for anti-traffi-jam apps, with user generated
> > > content.
> > >
> > > If someone would like to work on this project, please let me know.
> > >
> >
> > There is one obvious candidate who could work on this project. It's you.
> >
> > Best regards,
> >
> >         Christian
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
>
>
> --
> Mit freundlichen Gr??en
> Herr Dipl. Math. Orges Leka
>
> Mobil: 015751078391
> Email: orges.leka at googlemail.com
> Holzheimerstra?e 25
> 65549 Limburg
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644

From princit at gmail.com  Wed Mar 18 04:59:19 2020
From: princit at gmail.com (princit)
Date: Wed, 18 Mar 2020 01:59:19 -0700 (PDT)
Subject: How to fit & predict in Cat-boost Algorithm
Message-ID: <590ce2a1-e851-4251-b281-28ca7dd61b75@googlegroups.com>

I am new in python. I am trying to predict the "time_to_failure" for given "acoustic_data" in the test CSV file using catboost algorithm.


def catbostregtest(X_train, y_train):  
    # submission format
    submission = pd.read_csv('sample_submission.csv', index_col='seg_id')
    X_test = pd.DataFrame()
    # prepare test data
    for seg_id in submission.index:
        seg = pd.read_csv('test/' + seg_id + '.csv')
        ch = gen_features(seg['acoustic_data'])
        X_test = X_test.append(ch, ignore_index=True)
    # model of choice here
    model = CatBoostRegressor(iterations=10000, loss_function='MAE', boosting_type='Ordered')
    model.fit(X_train, y_train)      #error line
    y_hat = model.predict(X_test)    #error line
    # write submission file LSTM
    submission['time_to_failure'] = y_hat
    submission.to_csv('submissionCAT.csv')
    print(model.best_score_)



This function "catbostregtest" is giving me error with the errorlog
 
Traceback (most recent call last):
File "E:\dir\question.py", line 68, in main()
File "E:\dir\question.py", line 65, in main catbostregtest(X_train, y_train)
File "E:\dir\question.py", line 50, in catbostregtest model.fit(X_train, y_train)
File "C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py", line 4330, in fit save_snapshot, snapshot_file, snapshot_interval, init_model)
File "C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py", line 1690, in _fit train_params["init_model"]
File "C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py", line 1225, in _train self._object._train(train_pool, test_pool, params, allow_clear_pool, init_model._object if init_model else None)
File "_catboost.pyx", line 3870, in _catboost._CatBoost._train
File "_catboost.pyx", line 3916, in _catboost._CatBoost._train
CatBoostError: c:/goagent/pipelines/buildmaster/catboost.git/catboost/libs/data/quantization.cpp:2424: All features are either constant or ignored.
This is gen_features function

def gen_features(X):
  
    strain = []

    strain.append(X.mean())

    strain.append(X.std())

    strain.append(X.min())

    strain.append(X.max())

    strain.append(X.kurtosis())

    strain.append(X.skew())

    strain.append(np.quantile(X,0.01))

    strain.append(np.quantile(X,0.05))

    strain.append(np.quantile(X,0.95))

    strain.append(np.quantile(X,0.99))

    strain.append(np.abs(X).max())

    strain.append(np.abs(X).mean())

    strain.append(np.abs(X).std())

    return pd.Series(strain)


This function is called from the main function

def main():
    train1 = pd.read_csv('train.csv', iterator=True, chunksize=150_000, dtype={'acoustic_data': np.int16, 'time_to_failure': np.float64})
    X_train = pd.DataFrame()
    y_train = pd.Series() 
    for df in train1: 
        ch = gen_features(df['acoustic_data']) 
        X_train = X_train.append(ch, ignore_index=True)
        y_train = y_train.append(pd.Series(df['time_to_failure'].values[-1])) 
    catbostregtest(X_train, y_train)

How I can remove the error that occur during making predict from catboost model? How I can remove this error please help. You can download and run the project in spyder ide from this link https://drive.google.com/file/d/1JFsNfE22ef82e-dS0zsZHDE3zGJxnJ_J/view?usp=sharing or https://github.com/princit/catboostAlgorithm


From barry at barrys-emacs.org  Wed Mar 18 16:00:48 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Wed, 18 Mar 2020 20:00:48 +0000
Subject: How to fit & predict in Cat-boost Algorithm
In-Reply-To: <590ce2a1-e851-4251-b281-28ca7dd61b75@googlegroups.com>
References: <590ce2a1-e851-4251-b281-28ca7dd61b75@googlegroups.com>
Message-ID: <93F81F02-82B3-443A-94F4-B463C5CE0731@barrys-emacs.org>



> On 18 Mar 2020, at 08:59, princit  wrote:
> 
> I am new in python. I am trying to predict the "time_to_failure" for given "acoustic_data" in the test CSV file using catboost algorithm.
> 
> 
> def catbostregtest(X_train, y_train):  
>    # submission format
>    submission = pd.read_csv('sample_submission.csv', index_col='seg_id')
>    X_test = pd.DataFrame()
>    # prepare test data
>    for seg_id in submission.index:
>        seg = pd.read_csv('test/' + seg_id + '.csv')
>        ch = gen_features(seg['acoustic_data'])
>        X_test = X_test.append(ch, ignore_index=True)
>    # model of choice here
>    model = CatBoostRegressor(iterations=10000, loss_function='MAE', boosting_type='Ordered')
>    model.fit(X_train, y_train)      #error line
>    y_hat = model.predict(X_test)    #error line
>    # write submission file LSTM
>    submission['time_to_failure'] = y_hat
>    submission.to_csv('submissionCAT.csv')
>    print(model.best_score_)
> 
> 
> 
> This function "catbostregtest" is giving me error with the errorlog

Have you checked the documentation for the library you are using?
Its clear that the author knows something is wrong, hence the error:

> CatBoostError: c:/goagent/pipelines/buildmaster/catboost.git/catboost/libs/data/quantization.cpp:2424: All features are either constant or ignored.

Hopeful the author documented the error to guide you.

Barry


> 
> Traceback (most recent call last):
> File "E:\dir\question.py", line 68, in main()
> File "E:\dir\question.py", line 65, in main catbostregtest(X_train, y_train)
> File "E:\dir\question.py", line 50, in catbostregtest model.fit(X_train, y_train)
> File "C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py", line 4330, in fit save_snapshot, snapshot_file, snapshot_interval, init_model)
> File "C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py", line 1690, in _fit train_params["init_model"]
> File "C:\Users\xyz\AppData\Local\Continuum\anaconda3\lib\site-packages\catboost\core.py", line 1225, in _train self._object._train(train_pool, test_pool, params, allow_clear_pool, init_model._object if init_model else None)
> File "_catboost.pyx", line 3870, in _catboost._CatBoost._train
> File "_catboost.pyx", line 3916, in _catboost._CatBoost._train
> CatBoostError: c:/goagent/pipelines/buildmaster/catboost.git/catboost/libs/data/quantization.cpp:2424: All features are either constant or ignored.
> This is gen_features function
> 
> def gen_features(X):
> 
>    strain = []
> 
>    strain.append(X.mean())
> 
>    strain.append(X.std())
> 
>    strain.append(X.min())
> 
>    strain.append(X.max())
> 
>    strain.append(X.kurtosis())
> 
>    strain.append(X.skew())
> 
>    strain.append(np.quantile(X,0.01))
> 
>    strain.append(np.quantile(X,0.05))
> 
>    strain.append(np.quantile(X,0.95))
> 
>    strain.append(np.quantile(X,0.99))
> 
>    strain.append(np.abs(X).max())
> 
>    strain.append(np.abs(X).mean())
> 
>    strain.append(np.abs(X).std())
> 
>    return pd.Series(strain)
> 
> 
> This function is called from the main function
> 
> def main():
>    train1 = pd.read_csv('train.csv', iterator=True, chunksize=150_000, dtype={'acoustic_data': np.int16, 'time_to_failure': np.float64})
>    X_train = pd.DataFrame()
>    y_train = pd.Series() 
>    for df in train1: 
>        ch = gen_features(df['acoustic_data']) 
>        X_train = X_train.append(ch, ignore_index=True)
>        y_train = y_train.append(pd.Series(df['time_to_failure'].values[-1])) 
>    catbostregtest(X_train, y_train)
> 
> How I can remove the error that occur during making predict from catboost model? How I can remove this error please help. You can download and run the project in spyder ide from this link https://drive.google.com/file/d/1JFsNfE22ef82e-dS0zsZHDE3zGJxnJ_J/view?usp=sharing or https://github.com/princit/catboostAlgorithm
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 


From ml_news at posteo.de  Wed Mar 18 16:38:45 2020
From: ml_news at posteo.de (Manfred Lotz)
Date: Wed, 18 Mar 2020 21:38:45 +0100
Subject: ZipFile and timestamps
Message-ID: <20200318213845.06346b1c@arcor.com>

I unzip a zip file like follows which works fine.   

 with ZipFile(zip_file, 'r') as zip:
        zip.extractall(tmp_dir)

The only caveat is that the unpacked files and dirs do have a current
timestamp i.e. the timestamps of the files are not preserved.

Is there a way to tell ZipFile to preserve timestamps when unpacking a
zip archive?


-- 
Manfred


From rshepard at appl-ecosys.com  Wed Mar 18 16:39:49 2020
From: rshepard at appl-ecosys.com (Rich Shepard)
Date: Wed, 18 Mar 2020 13:39:49 -0700 (PDT)
Subject: Tkinter: which ttk widget for database table primary key?
Message-ID: 

Subject might be confusing so I'll expand it here.

My application uses a database backend in which each table has a unique and
database-generated sequential numeric key. I want to display that key in the
GUI for that class but it's not entered by the user or altered. It seems to
me that the ttk.Entry and ttk.Spinbox widgets are inappropriate. As a
newcomer to Tkinter I ask for advice on which widget to use.

Rich

From auriocus at gmx.de  Wed Mar 18 17:18:31 2020
From: auriocus at gmx.de (Christian Gollwitzer)
Date: Wed, 18 Mar 2020 22:18:31 +0100
Subject: Tkinter: which ttk widget for database table primary key?
In-Reply-To: 
References: 
 
Message-ID: 

Am 18.03.20 um 21:39 schrieb Rich Shepard:
> Subject might be confusing so I'll expand it here.
> 
> My application uses a database backend in which each table has a unique and
> database-generated sequential numeric key. I want to display that key in 
> the
> GUI for that class but it's not entered by the user or altered. It seems to
> me that the ttk.Entry and ttk.Spinbox widgets are inappropriate. As a
> newcomer to Tkinter I ask for advice on which widget to use.

You can use an Entry and set it to readonly state. Or you can use a 
Label. The advantage of the readonly Entry is, that the user can still 
copy/paste the content, and that it can scroll if the string is very long.

Christian

From python at mrabarnett.plus.com  Wed Mar 18 17:21:10 2020
From: python at mrabarnett.plus.com (MRAB)
Date: Wed, 18 Mar 2020 21:21:10 +0000
Subject: Tkinter: which ttk widget for database table primary key?
In-Reply-To: 
References: 
Message-ID: <1ea064de-7f66-5db4-3b1c-1b99102910dd@mrabarnett.plus.com>

On 2020-03-18 20:39, Rich Shepard wrote:
> Subject might be confusing so I'll expand it here.
> 
> My application uses a database backend in which each table has a unique and
> database-generated sequential numeric key. I want to display that key in the
> GUI for that class but it's not entered by the user or altered. It seems to
> me that the ttk.Entry and ttk.Spinbox widgets are inappropriate. As a
> newcomer to Tkinter I ask for advice on which widget to use.
> 
You can make the Entry widget read-only:

     entry_widget['state'] = 'readonly'

The user will still be able to copy from it.

Alternatively, you can disable it:

     entry_widget['state'] = 'disabled'

The user won't be able to copy from it.

When updating the GUI, you'll need to make it writeable if you have it 
currently read-only or disabled:

     entry_widget['state'] = 'normal'
     :
     # Change the contents here.
     :
     entry_widget['state'] = 'readonly'

From python at mrabarnett.plus.com  Wed Mar 18 17:41:10 2020
From: python at mrabarnett.plus.com (MRAB)
Date: Wed, 18 Mar 2020 21:41:10 +0000
Subject: ZipFile and timestamps
In-Reply-To: <20200318213845.06346b1c@arcor.com>
References: <20200318213845.06346b1c@arcor.com>
Message-ID: 

On 2020-03-18 20:38, Manfred Lotz wrote:
> I unzip a zip file like follows which works fine.
> 
>   with ZipFile(zip_file, 'r') as zip:
>          zip.extractall(tmp_dir)
> 
> The only caveat is that the unpacked files and dirs do have a current
> timestamp i.e. the timestamps of the files are not preserved.
> 
> Is there a way to tell ZipFile to preserve timestamps when unpacking a
> zip archive?
> 
You might have to iterate over the contents yourself and set the 
modification times.

From post at tinita.de  Wed Mar 18 17:48:40 2020
From: post at tinita.de (=?ISO-8859-15?Q?Tina_M=FCller?=)
Date: Wed, 18 Mar 2020 22:48:40 +0100 (CET)
Subject: [ANN] PyYAML-5.3.1: YAML parser and emitter for Python
Message-ID: 

=======================
Announcing PyYAML-5.3.1
=======================

A new release of PyYAML is now available:
https://pypi.org/project/PyYAML/

This release contains a security fix for CVE-2020-1747. FullLoader was still
exploitable for arbitrary command execution.
https://bugzilla.redhat.com/show_bug.cgi?id=1807367

Thanks to Riccardo Schirone (https://github.com/ret2libc) for both reporting
this and providing the fixes to resolve it.

Changes
=======

* https://github.com/yaml/pyyaml/pull/386 -- Prevents arbitrary code execution during python/object/new constructor


Resources
=========

PyYAML IRC Channel: #pyyaml on irc.freenode.net
PyYAML homepage: https://github.com/yaml/pyyaml
PyYAML documentation: http://pyyaml.org/wiki/PyYAMLDocumentation
Source and binary installers: https://pypi.org/project/PyYAML/
GitHub repository: https://github.com/yaml/pyyaml/
Bug tracking: https://github.com/yaml/pyyaml/issues

YAML homepage: http://yaml.org/
YAML-core mailing list: http://lists.sourceforge.net/lists/listinfo/yaml-core


About PyYAML
============

YAML is a data serialization format designed for human readability and
interaction with scripting languages. PyYAML is a YAML parser and emitter for
Python.

PyYAML features a complete YAML 1.1 parser, Unicode support, pickle support,
capable extension API, and sensible error messages. PyYAML supports standard
YAML tags and provides Python-specific tags that allow to represent an
arbitrary Python object.

PyYAML is applicable for a broad range of tasks from complex configuration
files to object serialization and persistence.


Example
=======

>>> import yaml

>>> yaml.full_load("""
... name: PyYAML
... description: YAML parser and emitter for Python
... homepage: https://github.com/yaml/pyyaml
... keywords: [YAML, serialization, configuration, persistence, pickle]
... """)
{'keywords': ['YAML', 'serialization', 'configuration', 'persistence',
'pickle'], 'homepage': 'https://github.com/yaml/pyyaml', 'description':
'YAML parser and emitter for Python', 'name': 'PyYAML'}

>>> print(yaml.dump(_))
name: PyYAML
homepage: https://github.com/yaml/pyyaml
description: YAML parser and emitter for Python
keywords: [YAML, serialization, configuration, persistence, pickle]


Maintainers
===========

The following people are currently responsible for maintaining PyYAML:

* Tina Mueller
* Ingy d?t Net
* Matt Davis

and many thanks to all who have contribributed!
See: https://github.com/yaml/pyyaml/pulls


Copyright
=========

Copyright (c) 2017-2020 Ingy d?t Net 
Copyright (c) 2006-2016 Kirill Simonov 

The PyYAML module was written by Kirill Simonov .
It is currently maintained by the YAML and Python communities.

PyYAML is released under the MIT license.
See the file LICENSE for more details.

From rshepard at appl-ecosys.com  Wed Mar 18 18:02:33 2020
From: rshepard at appl-ecosys.com (Rich Shepard)
Date: Wed, 18 Mar 2020 15:02:33 -0700 (PDT)
Subject: Tkinter: which ttk widget for database table primary key?
In-Reply-To: 
References: 
 
 
Message-ID: 

On Wed, 18 Mar 2020, Christian Gollwitzer wrote:

> You can use an Entry and set it to readonly state. Or you can use a Label.
> The advantage of the readonly Entry is, that the user can still copy/paste
> the content, and that it can scroll if the string is very long.

Christian,

Thank you. I did not find all options for the Entry widget in my quick look
for them. I like this because users will sometimes want to find all data
from that location and being able to copy that number and paste it in a
query will be helpful.

Regards,

Rich

From rshepard at appl-ecosys.com  Wed Mar 18 18:04:01 2020
From: rshepard at appl-ecosys.com (Rich Shepard)
Date: Wed, 18 Mar 2020 15:04:01 -0700 (PDT)
Subject: Tkinter: which ttk widget for database table primary key?
In-Reply-To: <1ea064de-7f66-5db4-3b1c-1b99102910dd@mrabarnett.plus.com>
References: 
 <1ea064de-7f66-5db4-3b1c-1b99102910dd@mrabarnett.plus.com>
Message-ID: 

On Wed, 18 Mar 2020, MRAB wrote:

> You can make the Entry widget read-only:
>    entry_widget['state'] = 'readonly'
> The user will still be able to copy from it.
>
> Alternatively, you can disable it:
>
>    entry_widget['state'] = 'disabled'
>
> The user won't be able to copy from it.
>
> When updating the GUI, you'll need to make it writeable if you have it 
> currently read-only or disabled:
>
>    entry_widget['state'] = 'normal'
>    :
>    # Change the contents here.
>    :
>    entry_widget['state'] = 'readonly'

MRAB,

Thanks very much for expanding on Christian's response. This is the widget
I'll use and set it to 'readonly'.

Regards,

Rich

From mjnash194 at gmail.com  Wed Mar 18 18:05:55 2020
From: mjnash194 at gmail.com (mjnash194 at gmail.com)
Date: Wed, 18 Mar 2020 15:05:55 -0700 (PDT)
Subject: Please Help! Absolute Novice - New Job, have this task.
Message-ID: <7e924289-7f01-415b-a6ee-dd7c44503031@googlegroups.com>

Absolute beginner here, have no idea what I am doing wrong. All I want to do here is have the pushButton in PyQt5 to change to "Working..." and Red when clicked... which it currently does. Thing is I need it to also change back to the default "SCAN" and Green color when done running that method the button is linked to...

I know this is a super simple problem, and forgive any Novice errors in this code. I know very very little but if you guys can help me I would highly appreciate it!!! :)

from PyQt5 import QtCore, QtGui, QtWidgets
import sys
import pyautogui



class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.showMaximized()
        MainWindow.setMinimumSize(QtCore.QSize(0, 0))
        MainWindow.setMaximumSize(QtCore.QSize(3840, 2160))
        font = QtGui.QFont()
        font.setFamily("Arial Black")
        MainWindow.setFont(font)
        MainWindow.setStyleSheet("background-color: rgba(0, 85, 127, 100);")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(250, 250, 400, 150))
        font = QtGui.QFont()
        font.setFamily("Tahoma")
        font.setPointSize(24)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton.setFont(font)
        self.pushButton.setStyleSheet("background-color: rgb(0, 170, 0);\n"
"color: rgb(255, 255, 255);")
        self.pushButton.setObjectName("pushButton")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(730, 300, 701, 111))
        font = QtGui.QFont()
        font.setPointSize(18)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.label.setObjectName("label")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1920, 18))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label.setStyleSheet("background-color: rgba(0, 85, 127, 0);\n"
"color: rgb(255, 255, 255);")
        self.pushButton.setText(_translate("MainWindow", "SCAN"))
        self.label.setText(_translate("MainWindow", "WELCOME"))

        self.pushButton.clicked.connect(self.copy)

    def copy(self, MainWindow):
        self.pushButton.setText('WORKING...')
        self.pushButton.setStyleSheet("background-color: rgb(250, 0, 0);\n"
"color: rgb(255, 255, 255);")
        testprompt=storeid=pyautogui.prompt(text='test', title='test')



class Application():
    def run():
        import sys
        app = QtWidgets.QApplication(sys.argv)
        MainWindow = QtWidgets.QMainWindow()
        ui = Ui_MainWindow()
        ui.setupUi(MainWindow)
        MainWindow.show()
        sys.exit(app.exec_())

Application.run()

From bgailer at gmail.com  Wed Mar 18 19:02:08 2020
From: bgailer at gmail.com (bob gailer)
Date: Wed, 18 Mar 2020 19:02:08 -0400
Subject: Please Help! Absolute Novice - New Job, have this task.
In-Reply-To: <7e924289-7f01-415b-a6ee-dd7c44503031@googlegroups.com>
References: <7e924289-7f01-415b-a6ee-dd7c44503031@googlegroups.com>
Message-ID: 

Request for future: give us a specific subject e.g. how do I restore a 
button's text/color ?

On 3/18/2020 6:05 PM, mjnash194 at gmail.com wrote:
> Absolute beginner here, have no idea what I am doing wrong. All I want to do here is have the pushButton in PyQt5 to change to "Working..." and Red when clicked... which it currently does.
That's amazing since your code sets the text to WORKING...
> Thing is I need it to also change back to the default "SCAN" and Green color when done running that method the button is linked to...
>
> I know this is a super simple problem, and forgive any Novice errors in this code. I know very very little but if you guys can help me I would highly appreciate it!!! :)
>
> from PyQt5 import QtCore, QtGui, QtWidgets
> import sys
> import pyautogui
>
>
>
> class Ui_MainWindow(object):
>      def setupUi(self, MainWindow):
>          MainWindow.setObjectName("MainWindow")
>          MainWindow.showMaximized()
>          MainWindow.setMinimumSize(QtCore.QSize(0, 0))
>          MainWindow.setMaximumSize(QtCore.QSize(3840, 2160))
>          font = QtGui.QFont()
>          font.setFamily("Arial Black")
>          MainWindow.setFont(font)
>          MainWindow.setStyleSheet("background-color: rgba(0, 85, 127, 100);")
>          self.centralwidget = QtWidgets.QWidget(MainWindow)
>          self.centralwidget.setObjectName("centralwidget")
>          self.pushButton = QtWidgets.QPushButton(self.centralwidget)
>          self.pushButton.setGeometry(QtCore.QRect(250, 250, 400, 150))
>          font = QtGui.QFont()
>          font.setFamily("Tahoma")
>          font.setPointSize(24)
>          font.setBold(True)
>          font.setWeight(75)
>          self.pushButton.setFont(font)
>          self.pushButton.setStyleSheet("background-color: rgb(0, 170, 0);\n"
> "color: rgb(255, 255, 255);")
>          self.pushButton.setObjectName("pushButton")
>          self.label = QtWidgets.QLabel(self.centralwidget)
>          self.label.setGeometry(QtCore.QRect(730, 300, 701, 111))
>          font = QtGui.QFont()
>          font.setPointSize(18)
>          font.setBold(True)
>          font.setItalic(False)
>          font.setWeight(75)
>          self.label.setFont(font)
>          self.label.setLayoutDirection(QtCore.Qt.LeftToRight)
>          self.label.setObjectName("label")
>          MainWindow.setCentralWidget(self.centralwidget)
>          self.menubar = QtWidgets.QMenuBar(MainWindow)
>          self.menubar.setGeometry(QtCore.QRect(0, 0, 1920, 18))
>          self.menubar.setObjectName("menubar")
>          MainWindow.setMenuBar(self.menubar)
>          self.statusbar = QtWidgets.QStatusBar(MainWindow)
>          self.statusbar.setObjectName("statusbar")
>          MainWindow.setStatusBar(self.statusbar)
>
>          self.retranslateUi(MainWindow)
>          QtCore.QMetaObject.connectSlotsByName(MainWindow)
>
>      def retranslateUi(self, MainWindow):
>          _translate = QtCore.QCoreApplication.translate
>          MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
>          self.label.setStyleSheet("background-color: rgba(0, 85, 127, 0);\n"
> "color: rgb(255, 255, 255);")
>          self.pushButton.setText(_translate("MainWindow", "SCAN"))
>          self.label.setText(_translate("MainWindow", "WELCOME"))
>
>          self.pushButton.clicked.connect(self.copy)
When user clicks button self.copy is invoked. True?
>      def copy(self, MainWindow):
>          self.pushButton.setText('WORKING...')
Why do you sometimes use _translate and not other times?
>          self.pushButton.setStyleSheet("background-color: rgb(250, 0, 0);\n"
> "color: rgb(255, 255, 255);")
>          testprompt=storeid=pyautogui.prompt(text='test', title='test')

This method does no actual work! If you add

         self.pushButton.setText(_translate("MainWindow", "SCAN"))
         self.pushButton.setStyleSheet # whatever it was originally

it will reset the button. Of course it will so really fast, as there is 
no actual work being done.

So you should first address the issue of actually doing something that 
will take a little time. Also it is not a good idea to duplicate code, 
so I would put those 2 lines in a function and call that function from 2 
places.

Am I going in the right direction? Am I missing something?

> class Application():
>      def run():
>          import sys
>          app = QtWidgets.QApplication(sys.argv)
>          MainWindow = QtWidgets.QMainWindow()
>          ui = Ui_MainWindow()
>          ui.setupUi(MainWindow)
>          MainWindow.show()
>          sys.exit(app.exec_())
>
> Application.run()
Bob Gailer

From hslee911 at yahoo.com  Wed Mar 18 19:06:01 2020
From: hslee911 at yahoo.com (James)
Date: Wed, 18 Mar 2020 16:06:01 -0700 (PDT)
Subject: How to build python binaries including external modules
Message-ID: <068f331e-75a2-4d50-8091-666dff575a62@googlegroups.com>

When you build python binaries from source, how to add external modules?
For example, to install cython, conventional method is building python first, then running setup.py for cython.
I'd like to combine the 2-step into one.

Thanks
James

From torriem at gmail.com  Wed Mar 18 19:44:27 2020
From: torriem at gmail.com (Michael Torrie)
Date: Wed, 18 Mar 2020 17:44:27 -0600
Subject: How to build python binaries including external modules
In-Reply-To: <068f331e-75a2-4d50-8091-666dff575a62@googlegroups.com>
References: <068f331e-75a2-4d50-8091-666dff575a62@googlegroups.com>
Message-ID: <6e661978-d30b-f303-5394-f8b5c6341ee5@gmail.com>

On 2020-03-18 5:06 p.m., James via Python-list wrote:
> When you build python binaries from source, how to add external modules?
> For example, to install cython, conventional method is building python first, then running setup.py for cython.
> I'd like to combine the 2-step into one.

Cython requires a working Python interpreter to run the setup.py.  How
would that work when building python itself?

From drsalists at gmail.com  Wed Mar 18 19:50:17 2020
From: drsalists at gmail.com (Dan Stromberg)
Date: Wed, 18 Mar 2020 16:50:17 -0700
Subject: How to build python binaries including external modules
In-Reply-To: <068f331e-75a2-4d50-8091-666dff575a62@googlegroups.com>
References: <068f331e-75a2-4d50-8091-666dff575a62@googlegroups.com>
Message-ID: 

I'm not completely sure I understand what the question is.

You can 'python3 -m pip install cython'.

You can use a shell/powershell wrapper that invokes the two things in
series.

Does that help?

On Wed, Mar 18, 2020 at 4:10 PM James via Python-list <
python-list at python.org> wrote:

> When you build python binaries from source, how to add external modules?
> For example, to install cython, conventional method is building python
> first, then running setup.py for cython.
> I'd like to combine the 2-step into one.
>
> Thanks
> James
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From drsalists at gmail.com  Wed Mar 18 19:54:43 2020
From: drsalists at gmail.com (Dan Stromberg)
Date: Wed, 18 Mar 2020 16:54:43 -0700
Subject: How to build python binaries including external modules
In-Reply-To: 
References: <068f331e-75a2-4d50-8091-666dff575a62@googlegroups.com>
 
Message-ID: 

For a rather involved example of using a shell wrapper to build a bunch of
python-related stuff, feel free to raid
http://stromberg.dnsalias.org/svn/cpythons/trunk/ for ideas.  Or even just
use it.

It builds python 1.0 - 3.9, and installs some dependencies like cython,
pygobject and numpy.


On Wed, Mar 18, 2020 at 4:50 PM Dan Stromberg  wrote:

>
> I'm not completely sure I understand what the question is.
>
> You can 'python3 -m pip install cython'.
>
> You can use a shell/powershell wrapper that invokes the two things in
> series.
>
> Does that help?
>
> On Wed, Mar 18, 2020 at 4:10 PM James via Python-list <
> python-list at python.org> wrote:
>
>> When you build python binaries from source, how to add external modules?
>> For example, to install cython, conventional method is building python
>> first, then running setup.py for cython.
>> I'd like to combine the 2-step into one.
>>
>> Thanks
>> James
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>

From hslee911 at yahoo.com  Wed Mar 18 21:21:22 2020
From: hslee911 at yahoo.com (James)
Date: Wed, 18 Mar 2020 18:21:22 -0700 (PDT)
Subject: How to build python binaries including external modules
In-Reply-To: 
References: <068f331e-75a2-4d50-8091-666dff575a62@googlegroups.com>
 <6e661978-d30b-f303-5394-f8b5c6341ee5@gmail.com>
 
Message-ID: <81b65531-c0fb-4fd6-869d-1224e121e6b7@googlegroups.com>

On Wednesday, March 18, 2020 at 4:44:46 PM UTC-7, Michael Torrie wrote:

> Cython requires a working Python interpreter to run the setup.py.  How
> would that work when building python itself?

Python binary is built with a host of default modules. My question was how to promote external module(s) to a list of default modules. Or is it possible?
The goal was to build python for cross-platforms with external modules.

James

From souvik.viksou at gmail.com  Wed Mar 18 21:27:45 2020
From: souvik.viksou at gmail.com (Souvik Dutta)
Date: Thu, 19 Mar 2020 06:57:45 +0530
Subject: Why is the program not printing three lines?
Message-ID: 

Hi,
I wrote a purposeless code today.

class first():
    print("From first")
    def second():
        print("From second")
first()
first.second()


Now the output I get is
>From first
>From second

But when I comment the call of first that is the comment the second last
line of the code (#first()).
I get the same output. This is confusing because first() when called alone
prints from first. And first.second() when called alone prints from first
from second. But when both of them are called together, the output is from
first from second. Should not first.second() print only from second. Or
when I call both should I not get three line
from first
from first
from second
Why do I get that output?

From rosuav at gmail.com  Wed Mar 18 21:36:00 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Thu, 19 Mar 2020 12:36:00 +1100
Subject: Why is the program not printing three lines?
In-Reply-To: 
References: 
Message-ID: 

On Thu, Mar 19, 2020 at 12:30 PM Souvik Dutta  wrote:
>
> Hi,
> I wrote a purposeless code today.
> 
> class first():
>     print("From first")
>     def second():
>         print("From second")
> first()
> first.second()
> 
>
> Now the output I get is
> From first
> From second
>
> But when I comment the call of first that is the comment the second last
> line of the code (#first()).
> I get the same output. This is confusing because first() when called alone
> prints from first. And first.second() when called alone prints from first
> from second. But when both of them are called together, the output is from
> first from second. Should not first.second() print only from second. Or
> when I call both should I not get three line
> from first
> from first
> from second
> Why do I get that output?

Creating the class runs all the code in the class block, including
function definitions, assignments, and in this case, a print call.

Classes are not declarations. They are executable code.

ChrisA

From santiago.basulto at gmail.com  Wed Mar 18 22:28:23 2020
From: santiago.basulto at gmail.com (Santiago Basulto)
Date: Wed, 18 Mar 2020 23:28:23 -0300
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired in
 NumPy)
Message-ID: 

Hello community. I have an idea to share with the list to see what you all
think about it.

I happen to use both Python for Data Science (with our regular friends
NumPy and Pandas) as well as for scripting and backend development. Every
time I'm working in server-side Python (not the PyData stack), I find
myself missing A LOT features from NumPy, like fancy indexing or boolean
arrays.

So, has it ever been considered to bake into Python's builtin list and
dictionary types functionality inspired by NumPy? I think multi indexing
alone would be huge addition. A few examples:

For lists and tuples:
    >>> l = ['a', 'b', 'c']
    >>> l[[0, -1]]
    ['a', 'c']

For dictionaries it'd even be more useful:
    d = {
        'first_name': 'Frances',
        'last_name': 'Allen',
        'email': 'fallen at ibm.com'
    }
    fname, lname = d[['first_name', 'last_name']]

I really like the syntax of boolean arrays too, but considering we have
list comprehensions, seems a little more difficult to sell.

I'd love to see if this is something people would support, and see if
there's room to submit a PEP.

-- 
Santiago Basulto.-
Up!

From ml_news at posteo.de  Wed Mar 18 23:51:46 2020
From: ml_news at posteo.de (Manfred Lotz)
Date: Thu, 19 Mar 2020 04:51:46 +0100
Subject: ZipFile and timestamps
References: <20200318213845.06346b1c@arcor.com>
 
 
Message-ID: <20200319045146.260fda55@arcor.com>

On Wed, 18 Mar 2020 21:41:10 +0000
MRAB  wrote:

> On 2020-03-18 20:38, Manfred Lotz wrote:
> > I unzip a zip file like follows which works fine.
> > 
> >   with ZipFile(zip_file, 'r') as zip:
> >          zip.extractall(tmp_dir)
> > 
> > The only caveat is that the unpacked files and dirs do have a
> > current timestamp i.e. the timestamps of the files are not
> > preserved.
> > 
> > Is there a way to tell ZipFile to preserve timestamps when
> > unpacking a zip archive?
> >   
> You might have to iterate over the contents yourself and set the 
> modification times.

Oops, if this is required then I better change my code to invoke unzip.

Thanks,
Manfred


From PythonList at DancesWithMice.info  Thu Mar 19 01:22:34 2020
From: PythonList at DancesWithMice.info (DL Neil)
Date: Thu, 19 Mar 2020 18:22:34 +1300
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: 
References: 
Message-ID: 

On 19/03/20 3:28 PM, Santiago Basulto wrote:
...> myself missing A LOT features from NumPy, like fancy indexing or 
boolean
> arrays.
> So, has it ever been considered to bake into Python's builtin list and
> dictionary types functionality inspired by NumPy? I think multi indexing
> alone would be huge addition. A few examples:
> For lists and tuples:
>      >>> l = ['a', 'b', 'c']
>      >>> l[[0, -1]]
>      ['a', 'c']
> For dictionaries it'd even be more useful:
>      d = {
>          'first_name': 'Frances',
>          'last_name': 'Allen',
>          'email': 'fallen at ibm.com'
>      }
>      fname, lname = d[['first_name', 'last_name']]


I fear that I'm missing your point.

How is
	l[[0, -1]] or fname, lname = d[['first_name', 'last_name']]
any better than
	l[ 0 ], l[ -1 ] or
	fname = d[ 'first_name' ]
	lname = d[ 'last_name' ]

Are you aware, that whilst there is more coverage of "tuple unpacking" 
(at least to my eye), there is also a "list unpacking" feature?

 >>> t = ( 1, 2, 3 )
 >>> a, b, c = t
 >>> print( a, b, c )
1 2 3

 >>> l = [ 1, 2, 3 ]
 >>> a, b, c = l
 >>> print( a, b, c )
1 2 3

and somewhat similarly for dictionaries:

 >>> fname, lname = d[ "first_name" ], d[ "last_name" ]
 >>> fname, lname
('Frances', 'Allen')


That said, I've often wished to be allowed to write:

	d.first_name

for a dict (cf a class/object).

Hmm, I feel a 'utility' coming-on - but first I'll look to see where/how 
such might be used in 'live' code (and be any better than the current 
mechanisms)...

Simple collections are one thing. How would you handle the structure if 
one or more elements contains a second dimension? eg a list within a 
list/a 2D matrix (or if you must, an 'array')?
-- 
Regards =dn

From pieter-l at vanoostrum.org  Thu Mar 19 07:56:26 2020
From: pieter-l at vanoostrum.org (Pieter van Oostrum)
Date: Thu, 19 Mar 2020 12:56:26 +0100
Subject: Why is the program not printing three lines?
References: 
 
 
Message-ID: 

Chris Angelico  writes:

> Creating the class runs all the code in the class block, including
> function definitions, assignments, and in this case, a print call.
>
> Classes are not declarations. They are executable code.

Demo:

In [26]: class first():
     ...     print("From first")
     ...     def second():
     ...         print("From second")
>From first

You see, the print "From first" occurs at class definition time.

In [27]: first()
Out[27]: <__main__.first at 0x10275f880>

Calling the class (i.e. creating an instance) doesn't print anything,
because the print statement is not part of the class __init__ code.

In [28]: first.second()
>From second

That's expected.

In [29]: first.second()
>From second

Again.
-- 
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

From hjp-python at hjp.at  Thu Mar 19 09:00:10 2020
From: hjp-python at hjp.at (Peter J. Holzer)
Date: Thu, 19 Mar 2020 14:00:10 +0100
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: 
References: 
 
Message-ID: <20200319130010.GA5107@hjp.at>

On 2020-03-19 18:22:34 +1300, DL Neil via Python-list wrote:
> On 19/03/20 3:28 PM, Santiago Basulto wrote:
> > myself missing A LOT features from NumPy, like fancy indexing or
> > boolean arrays.
> > So, has it ever been considered to bake into Python's builtin list and
> > dictionary types functionality inspired by NumPy? I think multi indexing
> > alone would be huge addition. A few examples:
> > For lists and tuples:
> >      >>> l = ['a', 'b', 'c']
> >      >>> l[[0, -1]]
> >      ['a', 'c']
> > For dictionaries it'd even be more useful:
> >      d = {
> >          'first_name': 'Frances',
> >          'last_name': 'Allen',
> >          'email': 'fallen at ibm.com'
> >      }
> >      fname, lname = d[['first_name', 'last_name']]
> 
> 
> I fear that I'm missing your point.
> 
> How is
> 	l[[0, -1]] or fname, lname = d[['first_name', 'last_name']]
> any better than
> 	l[ 0 ], l[ -1 ] or
> 	fname = d[ 'first_name' ]
> 	lname = d[ 'last_name' ]

It's more compact, especially, if "d" isn't a one-character variable,
but an expression:

    fname, lname = db[people].employee.object.get(pk=1234)[['first_name', 'last_name']]

vs.

    fname = db[people].employee.object.get(pk=1234)['first_name']
    lname = db[people].employee.object.get(pk=1234)['last_name']

Plus the latter probably performs two database lookups, so you would
want to write:

    person = db[people].employee.object.get(pk=1234)
    fname = person['first_name']
    lname = person['last_name']

(This is one of the Perl features I missed when I started using Python)

        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 orges.leka at gmail.com  Thu Mar 19 09:27:44 2020
From: orges.leka at gmail.com (Orges Leka)
Date: Thu, 19 Mar 2020 14:27:44 +0100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
Message-ID: 

If someone from Germany wants to help creatively against the Virus in a
Hackathon this Weekend:
https://www.bundesregierung.de/breg-de/themen/coronavirus/wir-vs-virus-1731968

Am Mo., 16. M?rz 2020 um 21:16 Uhr schrieb Barry Scott <
barry at barrys-emacs.org>:

>
>
> > On 16 Mar 2020, at 17:38, Orges Leka  wrote:
> >
> > Dear Python developers,
> >
> > I am a data scientist and use Python regularly. I have a question:
> > How difficult is it to write a Python web-app, with the following basic
> > functionality:
> >
> > The user writes anonymously without registration where (City,
> supermarket),
> > when (Date and Time) he plans to go to the supermarket.
>
> Without some security the site would be open to abuse.
>
> > If this is done by a lot of users, the first user gets to see the number
> of
> > other buyers at this supermarket and can better plan when to go shopping.
> > This would reduce the waiting queue at the supermarket and possibly the
> > contact to other people thus would help a little bit in slowing down the
> > spread of the Corona virus.
> > One could also add openstreetmap functionality to this.
> >
> > As I am not a professional software developer, I can not predict how long
> > it would take to write such a web-app in python.
> >
> > If you do not have currently time, but know someone who would possibly be
> > interested in working at this project, I would be happy if you let me
> know.
>
> If you search google for a shop the right hand panel has a popular times
> sections that tells you how busy the store typically is and the current
> busyness
> estimate. Is that what you are after?
>
> Barry
>
> >
> > Kind regards,
> > Orges Leka
> >
> > --
> > Mit freundlichen Gr??en
> > Herr Dipl. Math. Orges Leka
> >
> > Mobil: 015751078391
> > Email: orges.leka at googlemail.com
> > Holzheimerstra?e 25
> > 65549 Limburg
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
>

-- 
Mit freundlichen Gr??en
Herr Dipl. Math. Orges Leka

Mobil: 015751078391
Email: orges.leka at googlemail.com
Holzheimerstra?e 25
65549 Limburg

From souvik.viksou at gmail.com  Thu Mar 19 09:58:07 2020
From: souvik.viksou at gmail.com (Souvik Dutta)
Date: Thu, 19 Mar 2020 19:28:07 +0530
Subject: Why is the program not printing three lines?
In-Reply-To: 
References: 
 
 
 
Message-ID: 

I should have been more clear
class first():
    print("from first")
    def second():
        print("from second")
first()

When I run the above code the output is
"from first"
(2ND CODE)

class first():
    print("from first")
    def second():
        print("from second")
first.second()

When I run this code the output is
"from first"
"from second"

Thus going by the above logic

class first():
    print("from first")
    def second():
        print("from second")
first()
first.second()

This should have given the following output
from first
from first
from second

That is I should have got from first 2 times. But instead I got this output.
from first
from second
Why is this so?

On Thu, Mar 19, 2020, 5:30 PM Pieter van Oostrum 
wrote:

> Chris Angelico  writes:
>
> > Creating the class runs all the code in the class block, including
> > function definitions, assignments, and in this case, a print call.
> >
> > Classes are not declarations. They are executable code.
>
> Demo:
>
> In [26]: class first():
>      ...     print("From first")
>      ...     def second():
>      ...         print("From second")
> From first
>
> You see, the print "From first" occurs at class definition time.
>
> In [27]: first()
> Out[27]: <__main__.first at 0x10275f880>
>
> Calling the class (i.e. creating an instance) doesn't print anything,
> because the print statement is not part of the class __init__ code.
>
> In [28]: first.second()
> From second
>
> That's expected.
>
> In [29]: first.second()
> From second
>
> Again.
> --
> Pieter van Oostrum
> www: http://pieter.vanoostrum.org/
> PGP key: [8DAE142BE17999C4]
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From rhodri at kynesim.co.uk  Thu Mar 19 10:24:35 2020
From: rhodri at kynesim.co.uk (Rhodri James)
Date: Thu, 19 Mar 2020 14:24:35 +0000
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: <20200319130010.GA5107@hjp.at>
References: 
 
 <20200319130010.GA5107@hjp.at>
Message-ID: 

On 19/03/2020 13:00, Peter J. Holzer wrote:
> On 2020-03-19 18:22:34 +1300, DL Neil via Python-list wrote:
>> On 19/03/20 3:28 PM, Santiago Basulto wrote:
>>> myself missing A LOT features from NumPy, like fancy indexing or
>>> boolean arrays.
>>> So, has it ever been considered to bake into Python's builtin list and
>>> dictionary types functionality inspired by NumPy? I think multi indexing
>>> alone would be huge addition. A few examples:
[snip]>> I fear that I'm missing your point.
>>
>> How is
>> 	l[[0, -1]] or fname, lname = d[['first_name', 'last_name']]
>> any better than
>> 	l[ 0 ], l[ -1 ] or
>> 	fname = d[ 'first_name' ]
>> 	lname = d[ 'last_name' ]
> 
> It's more compact, especially, if "d" isn't a one-character variable,
> but an expression:
> 
>      fname, lname = db[people].employee.object.get(pk=1234)[['first_name', 'last_name']]
> 
> vs.
> 
>      fname = db[people].employee.object.get(pk=1234)['first_name']
>      lname = db[people].employee.object.get(pk=1234)['last_name']

I have to say I don't think that's more compact at all.  It's too wide 
to be compact.  I think the second version is more readable (and the 
third version, where you factored out the common lookup is better still).

-- 
Rhodri James *-* Kynesim Ltd

From rosuav at gmail.com  Thu Mar 19 10:26:42 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Fri, 20 Mar 2020 01:26:42 +1100
Subject: Why is the program not printing three lines?
In-Reply-To: 
References: 
 
 
 
 
Message-ID: 

On Fri, Mar 20, 2020 at 1:04 AM Souvik Dutta  wrote:
>
> I should have been more clear
> class first():
>     print("from first")
>     def second():
>         print("from second")
> first()
>
> When I run the above code the output is
> "from first"
> (2ND CODE)
>

Try this *without* the call to first() in it. See how that changes
your expectations.

ChrisA

From rhodri at kynesim.co.uk  Thu Mar 19 10:29:23 2020
From: rhodri at kynesim.co.uk (Rhodri James)
Date: Thu, 19 Mar 2020 14:29:23 +0000
Subject: Why is the program not printing three lines?
In-Reply-To: 
References: 
 
 
 
 
Message-ID: 

On 19/03/2020 13:58, Souvik Dutta wrote:
> I should have been more clear
> class first():
>      print("from first")
>      def second():
>          print("from second")
> first()
> 
> When I run the above code the output is
> "from first"
> (2ND CODE)
> 
> class first():
>      print("from first")
>      def second():
>          print("from second")
> first.second()
> 
> When I run this code the output is
> "from first"
> "from second"
> 
> Thus going by the above logic
> 
> class first():
>      print("from first")
>      def second():
>          print("from second")
> first()
> first.second()
> 
> This should have given the following output
> from first
> from first
> from second

Nope.  You haven't made your logic clear, but I think you are still 
confused about when the code in the class suite is run, and still think 
of it as running when an instance is created.

Try running this code:

class first:
     print("from first")

Just that.  No instantiation, no "first()", nothing else.  Just the 
class suite itself.

-- 
Rhodri James *-* Kynesim Ltd

From pieter-l at vanoostrum.org  Thu Mar 19 10:36:59 2020
From: pieter-l at vanoostrum.org (Pieter van Oostrum)
Date: Thu, 19 Mar 2020 15:36:59 +0100
Subject: Why is the program not printing three lines?
References: 
 
 
 
 
 
Message-ID: 

Souvik Dutta  writes:

> I should have been more clear
> class first():
>     print("from first")
>     def second():
>         print("from second")
> first()
>
> When I run the above code the output is
> "from first"

And where do you think this comes from? Are you thinking this comes from
the call 'first()'?
If so, that is not correct. See my Demo below.
It is from the class definition.

Run only this code, and you will see it also print "from first":

class first():
    print("from first")
    def second():
        print("from second")

> (2ND CODE)
>
> class first():
>     print("from first")
>     def second():
>         print("from second")
> first.second()
>
> When I run this code the output is
> "from first"
> "from second"
>
> Thus going by the above logic

Which logic?

> class first():
>     print("from first")
>     def second():
>         print("from second")
> first()
> first.second()
>
> This should have given the following output
> from first
> from first
> from second

No, because this is not the combination of the first two codes. To have this combination, you should include the class definition twice.

> That is I should have got from first 2 times. But instead I got this output.
> from first
> from second
> Why is this so?

'From first' is the result of the class definition. 'from second' is the result of first.second().
And first() doesn't produce any output.

Your problem is probably that you think that the call first() executes all the statements in the class definition. It doesn't. That's not how Python class definitions work.

Check the Demo below another time.

> On Thu, Mar 19, 2020, 5:30 PM Pieter van Oostrum 
> wrote:
>
>> Chris Angelico  writes:
>>
>> > Creating the class runs all the code in the class block, including
>> > function definitions, assignments, and in this case, a print call.
>> >
>> > Classes are not declarations. They are executable code.
>>
>> Demo:
>>
>> In [26]: class first():
>>      ...     print("From first")
>>      ...     def second():
>>      ...         print("From second")
>> From first
>>
>> You see, the print "From first" occurs at class definition time.
>>
>> In [27]: first()
>> Out[27]: <__main__.first at 0x10275f880>
>>
>> Calling the class (i.e. creating an instance) doesn't print anything,
>> because the print statement is not part of the class __init__ code.
>>
>> In [28]: first.second()
>> From second
>>
>> That's expected.
>>
>> In [29]: first.second()
>> From second
>>
>> Again.

-- 
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

From hjp-python at hjp.at  Thu Mar 19 10:47:00 2020
From: hjp-python at hjp.at (Peter J. Holzer)
Date: Thu, 19 Mar 2020 15:47:00 +0100
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: 
References: 
 
 <20200319130010.GA5107@hjp.at>
 
Message-ID: <20200319144700.GA16812@hjp.at>

On 2020-03-19 14:24:35 +0000, Rhodri James wrote:
> On 19/03/2020 13:00, Peter J. Holzer wrote:
> > It's more compact, especially, if "d" isn't a one-character variable,
> > but an expression:
> > 
> >      fname, lname = db[people].employee.object.get(pk=1234)[['first_name', 'last_name']]
> > 
> > vs.
> > 
> >      fname = db[people].employee.object.get(pk=1234)['first_name']
> >      lname = db[people].employee.object.get(pk=1234)['last_name']
> 
> I have to say I don't think that's more compact at all.  It's too wide
> to be compact.

But 83 characters is still more compact than 121 characters.

        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 souvik.viksou at gmail.com  Thu Mar 19 10:51:52 2020
From: souvik.viksou at gmail.com (Souvik Dutta)
Date: Thu, 19 Mar 2020 20:21:52 +0530
Subject: Why is the program not printing three lines?
In-Reply-To: 
References: 
 
 
 
 
 
 
Message-ID: 

Ooo thanks I understood.

On Thu, 19 Mar, 2020, 8:10 pm Pieter van Oostrum, 
wrote:

> Souvik Dutta  writes:
>
> > I should have been more clear
> > class first():
> >     print("from first")
> >     def second():
> >         print("from second")
> > first()
> >
> > When I run the above code the output is
> > "from first"
>
> And where do you think this comes from? Are you thinking this comes from
> the call 'first()'?
> If so, that is not correct. See my Demo below.
> It is from the class definition.
>
> Run only this code, and you will see it also print "from first":
>
> class first():
>     print("from first")
>     def second():
>         print("from second")
>
> > (2ND CODE)
> >
> > class first():
> >     print("from first")
> >     def second():
> >         print("from second")
> > first.second()
> >
> > When I run this code the output is
> > "from first"
> > "from second"
> >
> > Thus going by the above logic
>
> Which logic?
>
> > class first():
> >     print("from first")
> >     def second():
> >         print("from second")
> > first()
> > first.second()
> >
> > This should have given the following output
> > from first
> > from first
> > from second
>
> No, because this is not the combination of the first two codes. To have
> this combination, you should include the class definition twice.
>
> > That is I should have got from first 2 times. But instead I got this
> output.
> > from first
> > from second
> > Why is this so?
>
> 'From first' is the result of the class definition. 'from second' is the
> result of first.second().
> And first() doesn't produce any output.
>
> Your problem is probably that you think that the call first() executes all
> the statements in the class definition. It doesn't. That's not how Python
> class definitions work.
>
> Check the Demo below another time.
>
> > On Thu, Mar 19, 2020, 5:30 PM Pieter van Oostrum <
> pieter-l at vanoostrum.org>
> > wrote:
> >
> >> Chris Angelico  writes:
> >>
> >> > Creating the class runs all the code in the class block, including
> >> > function definitions, assignments, and in this case, a print call.
> >> >
> >> > Classes are not declarations. They are executable code.
> >>
> >> Demo:
> >>
> >> In [26]: class first():
> >>      ...     print("From first")
> >>      ...     def second():
> >>      ...         print("From second")
> >> From first
> >>
> >> You see, the print "From first" occurs at class definition time.
> >>
> >> In [27]: first()
> >> Out[27]: <__main__.first at 0x10275f880>
> >>
> >> Calling the class (i.e. creating an instance) doesn't print anything,
> >> because the print statement is not part of the class __init__ code.
> >>
> >> In [28]: first.second()
> >> From second
> >>
> >> That's expected.
> >>
> >> In [29]: first.second()
> >> From second
> >>
> >> Again.
>
> --
> Pieter van Oostrum
> www: http://pieter.vanoostrum.org/
> PGP key: [8DAE142BE17999C4]
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From drsalists at gmail.com  Thu Mar 19 11:05:18 2020
From: drsalists at gmail.com (Dan Stromberg)
Date: Thu, 19 Mar 2020 08:05:18 -0700
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: <20200319144700.GA16812@hjp.at>
References: 
 
 <20200319130010.GA5107@hjp.at>
 
 <20200319144700.GA16812@hjp.at>
Message-ID: 

On Thu, Mar 19, 2020 at 7:47 AM Peter J. Holzer  wrote:

> On 2020-03-19 14:24:35 +0000, Rhodri James wrote:
> > On 19/03/2020 13:00, Peter J. Holzer wrote:
> > > It's more compact, especially, if "d" isn't a one-character variable,
> > > but an expression:
> > >
> > >      fname, lname =
> db[people].employee.object.get(pk=1234)[['first_name', 'last_name']]
> > >
> > > vs.
> > >
> > >      fname = db[people].employee.object.get(pk=1234)['first_name']
> > >      lname = db[people].employee.object.get(pk=1234)['last_name']
> >
> > I have to say I don't think that's more compact at all.  It's too wide
> > to be compact.
>
> But 83 characters is still more compact than 121 characters.
>

It's smaller (in a way), but is it more clear?  Compare to regular
expressions: they're small, but they tend to be a mess.

Remember that the complexity of a programming a language varies with the
square of its number of features.  Complex languages are not good
languages.  A good language has a small core and extensibility via
libraries.

From pieter-l at vanoostrum.org  Thu Mar 19 11:20:32 2020
From: pieter-l at vanoostrum.org (Pieter van Oostrum)
Date: Thu, 19 Mar 2020 16:20:32 +0100
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
References: 
 
Message-ID: 

Santiago Basulto  writes:

> Hello community. I have an idea to share with the list to see what you all
> think about it.
>
> I happen to use both Python for Data Science (with our regular friends
> NumPy and Pandas) as well as for scripting and backend development. Every
> time I'm working in server-side Python (not the PyData stack), I find
> myself missing A LOT features from NumPy, like fancy indexing or boolean
> arrays.
>
> So, has it ever been considered to bake into Python's builtin list and
> dictionary types functionality inspired by NumPy? I think multi indexing
> alone would be huge addition. A few examples:
>
> For lists and tuples:
>     >>> l = ['a', 'b', 'c']
>     >>> l[[0, -1]]
>     ['a', 'c']
>
> For dictionaries it'd even be more useful:
>     d = {
>         'first_name': 'Frances',
>         'last_name': 'Allen',
>         'email': 'fallen at ibm.com'
>     }
>     fname, lname = d[['first_name', 'last_name']]
>
> I really like the syntax of boolean arrays too, but considering we have
> list comprehensions, seems a little more difficult to sell.
>
> I'd love to see if this is something people would support, and see if
> there's room to submit a PEP.

How about implementing it yourself:

In [35]: class MultiDict(dict):
     ...     def __getitem__(self, idx):
     ...         if isinstance(idx, list):
     ...             return [self[i] for i in idx]
     ...         return super().__getitem__(idx)

In [36]: d = MultiDict({
     ...         'first_name': 'Frances',
     ...         'last_name': 'Allen',
     ...         'email': 'fallen at ibm.com'
     ...     })

In [37]: d
Out[37]: {'first_name': 'Frances', 'last_name': 'Allen', 'email': 'fallen at ibm.com'}

In [38]: d['email']
Out[38]: 'fallen at ibm.com'

In [39]: d[['first_name', 'last_name']]
Out[39]: ['Frances', 'Allen']

The implementation of other methods, like __setitem__ and __init__, and maybe some more subtle details like exceptions, is left as an exercise for the reader.
-- 
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

From musbur at posteo.org  Thu Mar 19 11:17:54 2020
From: musbur at posteo.org (Musbur)
Date: Thu, 19 Mar 2020 16:17:54 +0100
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: 
References: 
 
 <20200319130010.GA5107@hjp.at>
 
Message-ID: 

Hello,

either it's me or everybody else who's missing the point. I understand 
the OP's proposal like this:

dict[set] == {k: dict[k] for k in set}
list[iterable] == [list[i] for i in iterable]

Am I right?

From tjreedy at udel.edu  Thu Mar 19 05:09:32 2020
From: tjreedy at udel.edu (Terry Reedy)
Date: Thu, 19 Mar 2020 05:09:32 -0400
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: 
References: 
Message-ID: 

On 3/18/2020 10:28 PM, Santiago Basulto wrote:

> For dictionaries it'd even be more useful:
>      d = {
>          'first_name': 'Frances',
>          'last_name': 'Allen',
>          'email': 'fallen at ibm.com'
>      }
>      fname, lname = d[['first_name', 'last_name']]

Insert ordered dicts make this sort of thing less useful.

 >>> d = {
         'first_name': 'Frances',
         'last_name': 'Allen',
         'email': 'fallen at ibm.com'
}
 >>> fname, lname, _ = d
 >>> fname, lname
('first_name', 'last_name')



-- 
Terry Jan Reedy


From ethan at stoneleaf.us  Thu Mar 19 11:42:48 2020
From: ethan at stoneleaf.us (Ethan Furman)
Date: Thu, 19 Mar 2020 08:42:48 -0700
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: 
References: 
 
Message-ID: <0602f65c-faa5-92dc-f317-d0bf31d3cdf7@stoneleaf.us>

On 03/19/2020 02:09 AM, Terry Reedy wrote:
> On 3/18/2020 10:28 PM, Santiago Basulto wrote:
> 
>> For dictionaries it'd even be more useful:
>> ???? d = {
>> ???????? 'first_name': 'Frances',
>> ???????? 'last_name': 'Allen',
>> ???????? 'email': 'fallen at ibm.com'
>> ???? }
>> ???? fname, lname = d[['first_name', 'last_name']]
> 
> Insert ordered dicts make this sort of thing less useful.
> 
>  >>> d = {
>  ??????? 'first_name': 'Frances',
>  ??????? 'last_name': 'Allen',
>  ??????? 'email': 'fallen at ibm.com'
> }
>  >>> fname, lname, _ = d
>  >>> fname, lname
> ('first_name', 'last_name')

I disagree -- the ordered dict would have to be small (maybe five entries) and one would have to know the insertion order.

--
~Ethan~

From hjp-python at hjp.at  Thu Mar 19 11:44:46 2020
From: hjp-python at hjp.at (Peter J. Holzer)
Date: Thu, 19 Mar 2020 16:44:46 +0100
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: 
References: 
 
 <20200319130010.GA5107@hjp.at>
 
 <20200319144700.GA16812@hjp.at>
 
Message-ID: <20200319154446.GA17425@hjp.at>

On 2020-03-19 08:05:18 -0700, Dan Stromberg wrote:
> On Thu, Mar 19, 2020 at 7:47 AM Peter J. Holzer  wrote:
> > On 2020-03-19 14:24:35 +0000, Rhodri James wrote:
> > > On 19/03/2020 13:00, Peter J. Holzer wrote:
> > > > It's more compact, especially, if "d" isn't a one-character variable,
> > > > but an expression:
> > > >
> > > >      fname, lname =
> > > >        db[people].employee.object.get(pk=1234)[['first_name', 'last_name']]
> > > >
> > > > vs.
> > > >
> > > >      fname = db[people].employee.object.get(pk=1234)['first_name']
> > > >      lname = db[people].employee.object.get(pk=1234)['last_name']
> > >
> > > I have to say I don't think that's more compact at all.  It's too wide
> > > to be compact.
> >
> > But 83 characters is still more compact than 121 characters.
> >
> 
> It's smaller (in a way), but is it more clear?

"Compact" is not the same word as "clear". I was claiming that it was
more compact, not that it was more clear. You can argue that it is less
clear, but you (well, Rhodri) can't redefine the meaning of "compact".

> Compare to regular expressions: they're small, but they tend to be a
> mess.

Usually because what they describe is complex. If you had to write a
matcher equivalent to a complex regexp by hand using basic string
operations, it would probably be harder to read. That would be many
lines of Python code and the reader would have to keep a lot of state
in their head while reading it.

So I would say that regular expressions are generally more clear than
the equivalent long-hand code.

This is similar to algebraic expressions: Have you ever tried to read a
mathematical paper from before the time the current notation (which we
of course now all learn in school) was invented? Long, convoluted
sentences instead of what can now be written as a short formula.

So sometimes "more compact" implies "clearer". Not always of course. The
Obfuscated C Code Contest is full of code which is very short but also
very hard to understand.

Would it be clearer in this case? I think so. Especially if you have
several keys to extract. In Python I would probably use a list or dict
comprehension, which probably isn't much longer, but it is an explicit
loop, so the reader has to think about the loop logic, it isn't "just
built in".


> Remember that the complexity of a programming a language varies with the
> square of its number of features.  Complex languages are not good
> languages.

I somewhat disagree with this. Languages which are too simple (think
"Turing machine") make it very hard to write useful programs, and
probably even harder to read them. As languages aquire more useful
features, they get easier to use and easier to read. At some point this
reverses again, especially if features are inconsistent or interact in
surprising ways. However, while you can just not use some features of a
language which is too complex for you, you can't easily extend a
language which is too simple.

> A good language has a small core and extensibility via
> libraries.

This would actually be a feature of the (standard) library.

        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 rosuav at gmail.com  Thu Mar 19 11:44:54 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Fri, 20 Mar 2020 02:44:54 +1100
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: 
References: 
 
Message-ID: 

On Fri, Mar 20, 2020 at 2:37 AM Terry Reedy  wrote:
>
> On 3/18/2020 10:28 PM, Santiago Basulto wrote:
>
> > For dictionaries it'd even be more useful:
> >      d = {
> >          'first_name': 'Frances',
> >          'last_name': 'Allen',
> >          'email': 'fallen at ibm.com'
> >      }
> >      fname, lname = d[['first_name', 'last_name']]
>
> Insert ordered dicts make this sort of thing less useful.
>
>  >>> d = {
>          'first_name': 'Frances',
>          'last_name': 'Allen',
>          'email': 'fallen at ibm.com'
> }
>  >>> fname, lname, _ = d
>  >>> fname, lname
> ('first_name', 'last_name')
>

Uhh, great, but the OP wanted fname = "Frances" and lname = "Allen" :)

But even using d.values() here isn't really a solution. It's assuming
positional information where the code really wants to be grabbing
named attributes.

JavaScript has an elegant syntax for object destructuring:

let { first_name, last_name } = d

Python can do this for positional unpacking, but not for named
attributes. The OP's proposal would allow the existing unpacking
syntax to be used for this, simply by returning an unpackable entity
(a list or tuple).

ChrisA

From David.Raymond at tomtom.com  Thu Mar 19 11:50:34 2020
From: David.Raymond at tomtom.com (David Raymond)
Date: Thu, 19 Mar 2020 15:50:34 +0000
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: 
References: 
Message-ID: 

For dictionaries it'd even be more useful:
    d = {
        'first_name': 'Frances',
        'last_name': 'Allen',
        'email': 'fallen at ibm.com'
    }
    fname, lname = d[['first_name', 'last_name']]

Why not do this?

import operator
first_last = operator.itemgetter("first_name", "last_name")

fname, lname = first_last(d)


https://docs.python.org/3.8/library/operator.html#operator.itemgetter


From rosuav at gmail.com  Thu Mar 19 11:52:38 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Fri, 20 Mar 2020 02:52:38 +1100
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: <20200319154446.GA17425@hjp.at>
References: 
 
 <20200319130010.GA5107@hjp.at>
 
 <20200319144700.GA16812@hjp.at>
 
 <20200319154446.GA17425@hjp.at>
Message-ID: 

On Fri, Mar 20, 2020 at 2:46 AM Peter J. Holzer  wrote:
> > A good language has a small core and extensibility via
> > libraries.
>
> This would actually be a feature of the (standard) library.

I think the line kinda blurs here. This would be a feature of a core
data type, and in CPython, it would be implemented using a slot
function in dictobject.c. But it doesn't need any syntactic changes.
Are the core data types part of the language or the standard library?

In any case, it doesn't much matter. The backward compatibility
considerations would be the same either way, and this would mostly be
used with literals and immediate unpacking.

ChrisA

From rhodri at kynesim.co.uk  Thu Mar 19 12:27:44 2020
From: rhodri at kynesim.co.uk (Rhodri James)
Date: Thu, 19 Mar 2020 16:27:44 +0000
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: <20200319144700.GA16812@hjp.at>
References: 
 
 <20200319130010.GA5107@hjp.at>
 
 <20200319144700.GA16812@hjp.at>
Message-ID: <7101fe68-2825-1876-9bf9-b65a9373635b@kynesim.co.uk>

On 19/03/2020 14:47, Peter J. Holzer wrote:
> On 2020-03-19 14:24:35 +0000, Rhodri James wrote:
>> On 19/03/2020 13:00, Peter J. Holzer wrote:
>>> It's more compact, especially, if "d" isn't a one-character variable,
>>> but an expression:
>>>
>>>       fname, lname = db[people].employee.object.get(pk=1234)[['first_name', 'last_name']]
>>>
>>> vs.
>>>
>>>       fname = db[people].employee.object.get(pk=1234)['first_name']
>>>       lname = db[people].employee.object.get(pk=1234)['last_name']
>>
>> I have to say I don't think that's more compact at all.  It's too wide
>> to be compact.
> 
> But 83 characters is still more compact than 121 characters.

Only if your sole metric is a strict character count.  Width matters in 
perception; two shorter lines are easier to take in than one long line, 
even if the long line contains fewer characters.

Besides, terseness isn't one of Python's objectives.

-- 
Rhodri James *-* Kynesim Ltd

From python at mrabarnett.plus.com  Thu Mar 19 12:45:41 2020
From: python at mrabarnett.plus.com (MRAB)
Date: Thu, 19 Mar 2020 16:45:41 +0000
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: 
References: 
 
 <20200319130010.GA5107@hjp.at>
 
 
Message-ID: <0912d8c1-2be0-a82a-021d-b50dad4af419@mrabarnett.plus.com>

On 2020-03-19 15:17, Musbur wrote:
> Hello,
> 
> either it's me or everybody else who's missing the point. I understand
> the OP's proposal like this:
> 
> dict[set] == {k: dict[k] for k in set}
> list[iterable] == [list[i] for i in iterable]
> 
> Am I right?
> 
"Iterable" is too broad because it includes tuples and strings.

From Marco.Sulla.Python at gmail.com  Thu Mar 19 14:15:57 2020
From: Marco.Sulla.Python at gmail.com (Marco Sulla)
Date: Thu, 19 Mar 2020 19:15:57 +0100
Subject: PEP Idea: Multi-get for lists/tuples and dictionaries (inspired
 in NumPy)
In-Reply-To: <20200319154446.GA17425@hjp.at>
References: 
 
 <20200319130010.GA5107@hjp.at>
 
 <20200319144700.GA16812@hjp.at>
 
 <20200319154446.GA17425@hjp.at>
Message-ID: 

On Thu, 19 Mar 2020 at 16:46, Peter J. Holzer  wrote:
> This is similar to algebraic expressions: Have you ever tried to read a
> mathematical paper from before the time the current notation (which we
> Long, convoluted
> sentences instead of what can now be written as a short formula.

...yes, and as an ex Physics student I have to say that short formulas
are completely unreadable, until someone explain them to you. Like
poetry.

> Would it be clearer in this case? I think so. Especially if you have
> several keys to extract.

Ok, but what is the use case? I mean, how much time you need more than
2, 3 keys?

In my Python implementation of frozendict, I'm doing a different
approach for have something as you want: implement the `set` API. For
example:

d = {
        'first_name': 'Frances',
        'last_name': 'Allen',
        'email': 'fallen at ibm.com'
}

d & ("first_name", "last_name") == {'first_name': 'Frances',
'last_name': 'Allen'}

https://github.com/Marco-Sulla/python-frozendict/commit/b2628e14f3275c6ba488dde220023c14f6a8435a

> you can't easily extend a
> language which is too simple.

So you can't easily extend Python? ^^

From duncan at invalid.invalid  Thu Mar 19 16:08:05 2020
From: duncan at invalid.invalid (duncan smith)
Date: Thu, 19 Mar 2020 20:08:05 +0000
Subject: queue versus list
Message-ID: 

Hello,
      I have generator code along the following lines,


Q = queue.Queue()
Q.put(x)
while not Q.empty():
    x = Q.get()
    if :
        yield x
    else:
      Q.put()


If I change it to,


Q = []
Q.append(x)
for x in Q:
    if :
        yield x
    else:
      Q.append()


then it runs approximately 3 times more quickly. I seem to remember
(from somewhere) that the language specification doesn't guarantee that
the latter will continue to work, but that it's unlikely that future
implementations will break it. Apart from that, is there any good reason
why I shouldn't use the list? Is there another approach that might avoid
the overhead of using a queue? Results from profiling the two
implementations below in case it makes anything clearer. TIA.

Duncan


         88752234 function calls in 68.603 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000   68.603   68.603 :1()
     1009   18.343    0.018   68.602    0.068
bit_trees.py:699(paired_tries_search)
  8425934    6.116    0.000   10.373    0.000 bit_trees.py:751(hamdist)
        1    0.000    0.000    0.000    0.000 bit_trees.py:809(cum_shape)
  2350867    5.970    0.000   18.200    0.000 queue.py:115(put)
  2350867    6.114    0.000   16.639    0.000 queue.py:147(get)
        1    0.000    0.000    0.000    0.000 queue.py:199(_init)
  4701735    1.951    0.000    2.686    0.000 queue.py:202(_qsize)
  2350867    1.149    0.000    1.512    0.000 queue.py:206(_put)
  2350867    1.042    0.000    1.446    0.000 queue.py:210(_get)
        1    0.000    0.000    0.000    0.000 queue.py:27(__init__)
  2350868    2.991    0.000    4.397    0.000 queue.py:90(empty)
        3    0.000    0.000    0.000    0.000 threading.py:215(__init__)
  4701734    2.661    0.000    3.742    0.000 threading.py:239(__enter__)
  4701734    2.097    0.000    2.719    0.000 threading.py:242(__exit__)
  4701734    2.483    0.000    3.872    0.000 threading.py:254(_is_owned)
  4701734    8.185    0.000   12.057    0.000 threading.py:334(notify)
        1    0.000    0.000    0.000    0.000 {built-in method
_thread.allocate_lock}
  8425934    1.874    0.000    1.874    0.000 {built-in method builtins.bin}
        1    0.000    0.000   68.603   68.603 {built-in method
builtins.exec}
  4701736    0.735    0.000    0.735    0.000 {built-in method builtins.len}
  4701734    1.080    0.000    1.080    0.000 {method '__enter__' of
'_thread.lock' objects}
  4701734    0.622    0.000    0.622    0.000 {method '__exit__' of
'_thread.lock' objects}
  4701734    1.389    0.000    1.389    0.000 {method 'acquire' of
'_thread.lock' objects}
  2350867    0.363    0.000    0.363    0.000 {method 'append' of
'collections.deque' objects}
  8425934    2.384    0.000    2.384    0.000 {method 'count' of 'str'
objects}
        1    0.000    0.000    0.000    0.000 {method 'disable' of
'_lsprof.Profiler' objects}
  4701734    0.649    0.000    0.649    0.000 {method 'items' of 'dict'
objects}
  2350867    0.404    0.000    0.404    0.000 {method 'popleft' of
'collections.deque' objects}



32331417 function calls in 26.992 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.142    0.142   26.992   26.992 :1()
     1009   16.741    0.017   26.851    0.027
bit_trees.py:699(paired_tries_search)
  8425934    5.270    0.000    9.175    0.000 bit_trees.py:755(hamdist)
        1    0.000    0.000    0.000    0.000 bit_trees.py:813(cum_shape)
  8425934    1.576    0.000    1.576    0.000 {built-in method builtins.bin}
        1    0.000    0.000   26.992   26.992 {built-in method
builtins.exec}
        1    0.000    0.000    0.000    0.000 {built-in method builtins.len}
  2350867    0.310    0.000    0.310    0.000 {method 'append' of 'list'
objects}
  8425934    2.329    0.000    2.329    0.000 {method 'count' of 'str'
objects}
        1    0.000    0.000    0.000    0.000 {method 'disable' of
'_lsprof.Profiler' objects}
  4701734    0.624    0.000    0.624    0.000 {method 'items' of 'dict'
objects}



From python at mrabarnett.plus.com  Thu Mar 19 16:40:35 2020
From: python at mrabarnett.plus.com (MRAB)
Date: Thu, 19 Mar 2020 20:40:35 +0000
Subject: queue versus list
In-Reply-To: 
References: 
Message-ID: <6a5d1910-7948-5845-e94a-8c596d440d68@mrabarnett.plus.com>

On 2020-03-19 20:08, duncan smith wrote:
> Hello,
>        I have generator code along the following lines,
> 
> 
> Q = queue.Queue()
> Q.put(x)
> while not Q.empty():
>      x = Q.get()
>      if :
>          yield x
>      else:
>        Q.put()
> 
> 
> If I change it to,
> 
> 
> Q = []
> Q.append(x)
> for x in Q:
>      if :
>          yield x
>      else:
>        Q.append()
> 
> 
> then it runs approximately 3 times more quickly. I seem to remember
> (from somewhere) that the language specification doesn't guarantee that
> the latter will continue to work, but that it's unlikely that future
> implementations will break it. Apart from that, is there any good reason
> why I shouldn't use the list? Is there another approach that might avoid
> the overhead of using a queue? Results from profiling the two
> implementations below in case it makes anything clearer. TIA.
> 
[snip]
A number of points:

1. I'm not sure it's a good idea to mutate a list while iterating over it.

2. The example with the list retains all of the results, whereas the one 
with the queue consumes them.

3. Queues are thread-safe because they're used for communication between 
threads, but lists aren't thread-safe; that might be something to do 
with the difference.

4. If it doesn't need to be thread-safe, why not try deques instead?

From greg.ewing at canterbury.ac.nz  Thu Mar 19 18:02:30 2020
From: greg.ewing at canterbury.ac.nz (Greg Ewing)
Date: Fri, 20 Mar 2020 11:02:30 +1300
Subject: How does the super type present itself and do lookups?
In-Reply-To: 
References: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com>
 
 
 
Message-ID: 

On 11/03/20 7:02 am, Adam Preble wrote:
> Is this foo attribute being looked up in an override of __getattr__, __getattribute__, or is it a reserved slot that's internally doing this? That's what I'm trying to figure out.

Looking at the source in Objects/typeobject.c, it uses the
tp_getattro type slot, which corresponds to __getattribute__.

-- 
Greg


From duncan at invalid.invalid  Thu Mar 19 20:37:35 2020
From: duncan at invalid.invalid (duncan smith)
Date: Fri, 20 Mar 2020 00:37:35 +0000
Subject: queue versus list
In-Reply-To: 
References: 
 <6a5d1910-7948-5845-e94a-8c596d440d68@mrabarnett.plus.com>
 
Message-ID: 

On 19/03/2020 20:40, MRAB wrote:
> On 2020-03-19 20:08, duncan smith wrote:
>> Hello,
>> ?????? I have generator code along the following lines,
>>
>>
>> Q = queue.Queue()
>> Q.put(x)
>> while not Q.empty():
>> ???? x = Q.get()
>> ???? if :
>> ???????? yield x
>> ???? else:
>> ?????? Q.put()
>>
>>
>> If I change it to,
>>
>>
>> Q = []
>> Q.append(x)
>> for x in Q:
>> ???? if :
>> ???????? yield x
>> ???? else:
>> ?????? Q.append()
>>
>>
>> then it runs approximately 3 times more quickly. I seem to remember
>> (from somewhere) that the language specification doesn't guarantee that
>> the latter will continue to work, but that it's unlikely that future
>> implementations will break it. Apart from that, is there any good reason
>> why I shouldn't use the list? Is there another approach that might avoid
>> the overhead of using a queue? Results from profiling the two
>> implementations below in case it makes anything clearer. TIA.
>>
> [snip]

Thanks MRAB and Paul,

> A number of points:
> 
> 1. I'm not sure it's a good idea to mutate a list while iterating over it.
> 

AFAICR that's the bit that depends on the implementation of lists. As
long as iteration involves incrementing an index and indexing into the
list it will work.

> 2. The example with the list retains all of the results, whereas the one
> with the queue consumes them.
> 
> 3. Queues are thread-safe because they're used for communication between
> threads, but lists aren't thread-safe; that might be something to do
> with the difference.
> 
> 4. If it doesn't need to be thread-safe, why not try deques instead?

Bingo. Performance is indistinguishable from that of the list. Thread
safety is unimportant (for my purposes), but the docs at
https://docs.python.org/2/library/collections.html#collections.deque
state "Deques support thread-safe, memory efficient appends and pops
from either side of the deque with approximately the same O(1)
performance in either direction". Looking at the output from the
profiler for my implementation with the queue it looks like a deque is
being used but there's various other stuff happening relating to thread
safety. Is the lesson from this that if all you're doing is appending
and popping, then use a deque (rather than a queue) even if you want
thread safety? (It makes quite a difference in performance for my use
case.) Cheers.

Duncan

From cs at cskk.id.au  Thu Mar 19 21:10:33 2020
From: cs at cskk.id.au (Cameron Simpson)
Date: Fri, 20 Mar 2020 12:10:33 +1100
Subject: queue versus list
In-Reply-To: 
References: 
Message-ID: <20200320011033.GA92328@cskk.homeip.net>

On 20Mar2020 00:37, duncan smith  wrote:
>On 19/03/2020 20:40, MRAB wrote:
>> On 2020-03-19 20:08, duncan smith wrote:
>>> ?????? I have generator code along the following lines,
>>>
>>> Q = queue.Queue()
>>> Q.put(x)
>>> while not Q.empty():
>>> ???? x = Q.get()
>>> ???? if :
>>> ???????? yield x
>>> ???? else:
>>> ?????? Q.put()
>>>
>>> If I change it to,
>>>
>>> Q = []
>>> Q.append(x)
>>> for x in Q:
>>> ???? if :
>>> ???????? yield x
>>> ???? else:
>>> ?????? Q.append()
>>>
>>> then it runs approximately 3 times more quickly.

A list is a very simple data structure, and therefore fast (for things 
that are inherently fast, like append; insert is expensive).

A queue takes a lock (cheap but an overhead) and might be expensive for 
get or put (this dependings on the data structure storing the queue 
items). A circular list (essentially a list using a base offset) can be 
fast until it needs resizing, a doubly linked list of nodes is always 
O(1) but is more expensive to add/remove (allocate node, adjust 
pointers); makye 3 times as slow :-) I haven't looked to see how Queue 
stores its items.

>>>I seem to remember
>>> (from somewhere) that the language specification doesn't guarantee that
>>> the latter will continue to work, but that it's unlikely that future
>>> implementations will break it.
[...snip...]
>> [MRAB] 1. I'm not sure it's a good idea to mutate a list while 
>> iterating over it.
>
>AFAICR that's the bit that depends on the implementation of lists. As
>long as iteration involves incrementing an index and indexing into the
>list it will work.

If you're the only person using the list, as you are only _appending_ to 
it then the for loop is probably safe.

If you were inserting elements into the list there would be trouble (an 
iterator basicly needs keep an index as you suggest below, and an insert 
at or before the current index invalidates that, causing the iterator to 
issue the same element again (for example).

>>> Apart from that, is there any good reason
>>> why I shouldn't use the list? Is there another approach that might avoid
>>> the overhead of using a queue? Results from profiling the two
>>> implementations below in case it makes anything clearer. TIA.

Using a list seems fine for me if your code is as simple in reality as 
listed above.

>> 2. The example with the list retains all of the results, whereas the 
>> one with the queue consumes them.
>>
>> 3. Queues are thread-safe because they're used for communication between
>> threads, but lists aren't thread-safe; that might be something to do
>> with the difference.
>>
>> 4. If it doesn't need to be thread-safe, why not try deques instead?
>
>Bingo. Performance is indistinguishable from that of the list.

A deque is implement using a list.

>Thread
>safety is unimportant (for my purposes), but the docs at
>https://docs.python.org/2/library/collections.html#collections.deque
>state "Deques support thread-safe, memory efficient appends and pops
>from either side of the deque with approximately the same O(1)
>performance in either direction". Looking at the output from the
>profiler for my implementation with the queue it looks like a deque is
>being used but there's various other stuff happening relating to thread
>safety. Is the lesson from this that if all you're doing is appending
>and popping, then use a deque (rather than a queue) even if you want
>thread safety? (It makes quite a difference in performance for my use
>case.) Cheers.

A deque will change the ordering of the elements you process. Your list 
loop behaves in FIFO order, as does the queue. A dequeue (you you're 
doing a heappush and a heappop) will issue you the lowest current 
element on each iteration. If you merely need to process all the 
elements you're good. If the order matters you need to consider that.

A deque, being thread safe, will be using a lock. There will be a (quite 
small) overhead for that.

Cheers,
Cameron Simpson 

From antoon.pardon at vub.be  Fri Mar 20 04:45:48 2020
From: antoon.pardon at vub.be (Antoon Pardon)
Date: Fri, 20 Mar 2020 09:45:48 +0100
Subject: queue versus list
In-Reply-To: <20200320011033.GA92328@cskk.homeip.net>
References: 
 <20200320011033.GA92328@cskk.homeip.net>
Message-ID: <8df0fd8c-010f-7a60-4c68-952ddf38e3bc@vub.be>


Op 20/03/20 om 02:10 schreef Cameron Simpson:
> On 20Mar2020 00:37, duncan smith  wrote:
>
>> Thread
>> safety is unimportant (for my purposes), but the docs at
>> https://docs.python.org/2/library/collections.html#collections.deque
>> state "Deques support thread-safe, memory efficient appends and pops
>> from either side of the deque with approximately the same O(1)
>> performance in either direction". Looking at the output from the
>> profiler for my implementation with the queue it looks like a deque is
>> being used but there's various other stuff happening relating to thread
>> safety. Is the lesson from this that if all you're doing is appending
>> and popping, then use a deque (rather than a queue) even if you want
>> thread safety? (It makes quite a difference in performance for my use
>> case.) Cheers.
>
> A deque will change the ordering of the elements you process. Your 
> list loop behaves in FIFO order, as does the queue. A dequeue (you 
> you're doing a heappush and a heappop) will issue you the lowest 
> current element on each iteration. If you merely need to process all 
> the elements you're good. If the order matters you need to consider that.
>
> A deque, being thread safe, will be using a lock. There will be a 
> (quite small) overhead for that.


This doesn't seem correct. A deque is used to simulate a stack or a 
queue. It doesn't use heappush or heappop.

Antoon.


From robin at reportlab.com  Fri Mar 20 07:22:52 2020
From: robin at reportlab.com (Robin Becker)
Date: Fri, 20 Mar 2020 11:22:52 +0000
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
Message-ID: 

On 16/03/2020 17:38, Orges Leka wrote:
> This would reduce the waiting queue at the supermarket and possibly the
> contact to other people thus would help a little bit in slowing down the
> spread of the Corona virus.
Unfortunately, I suspect nothing will alter the number of people in queues in British supermarkets. I am an older person 
and am probably a bit old-fashioned. I have been shocked at the way people are rushing the shops.

Late this week main shops announced first hour would be reserved for us oldies. That hasn't worked with scuffles and the 
elderly being pushed aside etc etc.

Women and children first is long gone the new British attitude is devil take the hindmost :)
--
Robin Becker

From orges.leka at gmail.com  Fri Mar 20 07:35:23 2020
From: orges.leka at gmail.com (Orges Leka)
Date: Fri, 20 Mar 2020 12:35:23 +0100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
Message-ID: 

Dear Robin,

I am sad to hear this. The same thing is / will happen(ing) in Germany I
suspect. But after the panic buys has gone, the supermarkets will leave
only a handful of people in, as it is happening in Italy. The app is meant
to inform others of those queues. But maybe it is just a silly idea. I am
not sure about it yet.

Kind regards,
Orges

Am Fr., 20. M?rz 2020 um 12:22 Uhr schrieb Robin Becker :

> On 16/03/2020 17:38, Orges Leka wrote:
> > This would reduce the waiting queue at the supermarket and possibly the
> > contact to other people thus would help a little bit in slowing down the
> > spread of the Corona virus.
> Unfortunately, I suspect nothing will alter the number of people in queues
> in British supermarkets. I am an older person
> and am probably a bit old-fashioned. I have been shocked at the way people
> are rushing the shops.
>
> Late this week main shops announced first hour would be reserved for us
> oldies. That hasn't worked with scuffles and the
> elderly being pushed aside etc etc.
>
> Women and children first is long gone the new British attitude is devil
> take the hindmost :)
> --
> Robin Becker
>


-- 
Mit freundlichen Gr??en
Herr Dipl. Math. Orges Leka

Mobil: 015751078391
Email: orges.leka at googlemail.com
Holzheimerstra?e 25
65549 Limburg

From joepareti54 at gmail.com  Fri Mar 20 08:20:02 2020
From: joepareti54 at gmail.com (joseph pareti)
Date: Fri, 20 Mar 2020 13:20:02 +0100
Subject: Reduce waiting queue at supermarket from Corona with Python-Webapp
In-Reply-To: 
References: 
 
 
Message-ID: 

>  the supermarkets will leave only a handful of people
better later than never :-)
meanwhile folks are staging idiotic things like (NOT EVEN 2 WEEKS AGO) a
leipzig vs. tottenhame match with FULL STADION, or bragging about their
social stupidities on facebook and co.

I always thought (and I am getting more convinced by the day) that
autoritarian rule is the way to go

Am Fr., 20. M?rz 2020 um 12:39 Uhr schrieb Orges Leka :

> Dear Robin,
>
> I am sad to hear this. The same thing is / will happen(ing) in Germany I
> suspect. But after the panic buys has gone, the supermarkets will leave
> only a handful of people in, as it is happening in Italy. The app is meant
> to inform others of those queues. But maybe it is just a silly idea. I am
> not sure about it yet.
>
> Kind regards,
> Orges
>
> Am Fr., 20. M?rz 2020 um 12:22 Uhr schrieb Robin Becker <
> robin at reportlab.com
> >:
>
> > On 16/03/2020 17:38, Orges Leka wrote:
> > > This would reduce the waiting queue at the supermarket and possibly the
> > > contact to other people thus would help a little bit in slowing down
> the
> > > spread of the Corona virus.
> > Unfortunately, I suspect nothing will alter the number of people in
> queues
> > in British supermarkets. I am an older person
> > and am probably a bit old-fashioned. I have been shocked at the way
> people
> > are rushing the shops.
> >
> > Late this week main shops announced first hour would be reserved for us
> > oldies. That hasn't worked with scuffles and the
> > elderly being pushed aside etc etc.
> >
> > Women and children first is long gone the new British attitude is devil
> > take the hindmost :)
> > --
> > Robin Becker
> >
>
>
> --
> Mit freundlichen Gr??en
> Herr Dipl. Math. Orges Leka
>
> Mobil: 015751078391
> Email: orges.leka at googlemail.com
> Holzheimerstra?e 25
> 65549 Limburg
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644

From drsalists at gmail.com  Fri Mar 20 09:50:29 2020
From: drsalists at gmail.com (Dan Stromberg)
Date: Fri, 20 Mar 2020 06:50:29 -0700
Subject: queue versus list
In-Reply-To: <20200320011033.GA92328@cskk.homeip.net>
References: 
 <20200320011033.GA92328@cskk.homeip.net>
Message-ID: 

On Thu, Mar 19, 2020 at 6:11 PM Cameron Simpson  wrote:

> >> 4. If it doesn't need to be thread-safe, why not try deques instead?
> >
> >Bingo. Performance is indistinguishable from that of the list.
>
> A deque is implement using a list.
>

Actually, I think a deque is a doubly linked list of python lists.

From 2QdxY4RzWzUUiLuE at potatochowder.com  Fri Mar 20 10:12:45 2020
From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers)
Date: Fri, 20 Mar 2020 10:12:45 -0400
Subject: queue versus list
In-Reply-To: 
References: 
 <20200320011033.GA92328@cskk.homeip.net>
 
Message-ID: <20200320101245.fbb19e3e13390e1bb4675ba5@potatochowder.com>

On Fri, 20 Mar 2020 06:50:29 -0700
Dan Stromberg  wrote:

> On Thu, Mar 19, 2020 at 6:11 PM Cameron Simpson  wrote:
> 
> > >> 4. If it doesn't need to be thread-safe, why not try deques instead?
> > >
> > >Bingo. Performance is indistinguishable from that of the list.
> >
> > A deque is implement using a list.
> >
> 
> Actually, I think a deque is a doubly linked list of python lists.

According to the source?:

    Data for deque objects is stored in a doubly-linked list of fixed
    length blocks.

    [...]

    Textbook implementations of doubly-linked lists store one datum per
    link, but that gives them a 200% memory overhead (a prev and next
    link for each datum) and it costs one malloc() call per data
    element.  By using fixed-length blocks, the link to data ratio is
    significantly improved and there are proportionally fewer calls to
    malloc() and free().  The data blocks of consecutive pointers also
    improve cache locality.

? https://github.com/python/cpython/blob/3.8/Modules/_collectionsmodule.c#L19-L78

Dan

-- 
?Atoms are not things.? ? Werner Heisenberg
Dan Sommers, http://www.tombstonezero.net/dan

From pie.denis at skynet.be  Thu Mar 19 16:05:47 2020
From: pie.denis at skynet.be (pie.denis at skynet.be)
Date: Thu, 19 Mar 2020 21:05:47 +0100
Subject: A simple probabilistic model  for COVID-19
Message-ID: <001901d5fe29$c860f7d0$5922e770$@skynet.be>

Hi!

I've created a Jupyter notebook that presents a simple probabilistic model
linking diseases (cold, flu, COVID-19) to symptoms (fever, cough):

http://mybinder.org/v2/gh/piedenis/lea_mini_tutorials/master?filepath=Lea_CO
VID19.ipynb

Assuming that this model is accurate (which is probably not!), it allows you
to answer questions like:

                What is the probability of having COVID-19 in the occurrence
of fever but without cough?

This model is programmed in Python, using Lea, a package dedicated to
probabilistic programming (PP).

Note that the goal is to let you discover PP and Bayesian reasoning, not to
provide you usable/trustable figures (even if the calculations are plainly
correct).

Take care of you!

Pierre Denis


From djb at qvii.com  Fri Mar 20 09:43:53 2020
From: djb at qvii.com (Barraclough, Dominic (ext. 414))
Date: Fri, 20 Mar 2020 13:43:53 +0000
Subject: [EXTERNAL] A simple probabilistic model  for COVID-19
In-Reply-To: <005a01d5fe2a$9af1b130$d0d51390$@skynet.be>
References: <005a01d5fe2a$9af1b130$d0d51390$@skynet.be>
Message-ID: 

Hi Pierre,

I'm interested in your Lea project and notice it is in a mercurial repo on bitbucket, what are your plans for the repo given that bitbucket are dropping support for mercurial repos in the summer?

https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket
[https://rlmr51w5rw3n7zek1m7tizzg-wpengine.netdna-ssl.com/wp-content/uploads/2019/08/bitbucket-logo-gradient-blue at 2x.png]
Sunsetting Mercurial support in Bitbucket - Bitbucket
The version control software market has evolved a lot since Bitbucket began in 2008. When we launched, centralized version control was the norm and we only supported Mercurial repos.
bitbucket.org


Dominic
________________________________
From: pie.denis at skynet.be 
Sent: Thursday, March 19, 2020 4:11 PM
To: python-announce-list at python.org 
Subject: [EXTERNAL] A simple probabilistic model for COVID-19

CAUTION:
This email originated from outside of QVI. Do not click links or open attachments unless you recognize the sender and are expecting to receive this content from them. If you suspect the email is not legitimate, please forward it as an attachment to SPAM at qvii.com and delete it from your Inbox.


Hi!

I've created a Jupyter notebook that presents a simple probabilistic model
linking diseases (cold, flu, COVID-19) to symptoms (fever, cough):

http://mybinder.org/v2/gh/piedenis/lea_mini_tutorials/master?filepath=Lea_CO
VID19.ipynb

Assuming that this model is accurate (which is probably not!), it allows you
to answer questions like:

                What is the probability of having COVID-19 in the occurrence
of fever but without cough?

This model is programmed in Python, using Lea, a package dedicated to
probabilistic programming (PP).

Note that the goal is to let you discover PP and Bayesian reasoning, not to
provide you usable/trustable figures (even if the calculations are plainly
correct).

Take care of you!

Pierre Denis



--
Python-announce-list mailing list -- python-announce-list at python.org
To unsubscribe send an email to python-announce-list-leave at python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/

        Support the Python Software Foundation:
        http://www.python.org/psf/donations/

From barry at barrys-emacs.org  Fri Mar 20 17:57:42 2020
From: barry at barrys-emacs.org (Barry)
Date: Fri, 20 Mar 2020 21:57:42 +0000
Subject: queue versus list
In-Reply-To: 
References: 
Message-ID: 



> On 20 Mar 2020, at 00:42, duncan smith  wrote:
> 
> Bingo. Performance is indistinguishable from that of the list. Thread
> safety is unimportant (for my purposes), but the docs at
> https://docs.python.org/2/library/collections.html#collections.deque
> state "Deques support thread-safe, memory efficient appends and pops
> from either side of the deque with approximately the same O(1)

I did a performance test of list vs sequel as a fifo that had 10k elements in them.
Then I timed insert elements at the tail and popping from the head.

Duque is 10x faster then list, rest run macOS python 3.8

Barry



From rshepard at appl-ecosys.com  Fri Mar 20 18:43:52 2020
From: rshepard at appl-ecosys.com (Rich Shepard)
Date: Fri, 20 Mar 2020 15:43:52 -0700 (PDT)
Subject: datepicker fails to find firstweekday in calendar
Message-ID: 

I'm running Python3-3.8.2 on Slackware-14.2/x86_64 and I tried to run Miguel
Martinez Lopez's datepicker.py (version 1.0.7) before learning how I can use
it in my application. It fails to find the attribute in the imported
calendar module:

$ python3 datepicker.py 
Traceback (most recent call last):
   File "datepicker.py", line 53, in 
     class Calendar(ttk.Frame):
   File "datepicker.py", line 57, in Calendar
     def __init__(self, master=None, year=None, month=None,
firstweekday=calendar.MONDAY, locale=None, activebackground='#b1dcfb',
activeforeground='black', selectbackground='#003eff',
selectforeground='white', command=None, borderwidth=1, relief="solid",
on_click_month_button=None):
AttributeError: module 'calendar' has no attribute 'MONDAY'

(N.B. The above itiation is line wrapped here but not in the trace back.)

Line 53 starts the calendar class:

class Calendar(ttk.Frame):
     datetime = calendar.datetime.datetime
     timedelta = calendar.datetime.timedelta

     def __init__(self, master=None, year=None, month=None,
firstweekday=calendar.MONDAY, locale=None, activebackground='#b1dcfb',
activeforeground='black', selectbackground='#003eff',
selectforeground='white', command=None, borderwidth=1, relief="solid",
on_click_month_button=None):

(N.B. Local line wrapping; in the code it's all on one line.)

Since calendar is built in to Python3-3.8.2 where do I look for the source
of the problem so I can fix it?

Rich

From cs at cskk.id.au  Fri Mar 20 19:54:08 2020
From: cs at cskk.id.au (Cameron Simpson)
Date: Sat, 21 Mar 2020 10:54:08 +1100
Subject: queue versus list
In-Reply-To: <8df0fd8c-010f-7a60-4c68-952ddf38e3bc@vub.be>
 
References: <8df0fd8c-010f-7a60-4c68-952ddf38e3bc@vub.be>
 
Message-ID: <20200320235408.GA38101@cskk.homeip.net>

On 20Mar2020 06:50, Dan Stromberg  wrote:
>Actually, I think a deque is a doubly linked list of python lists.

On 20Mar2020 09:45, Antoon Pardon  wrote:
>This doesn't seem correct. A deque is used to simulate a stack or a 
>queue. It doesn't use heappush or heappop.

You are both correct; brain fade on my part. I do not know why I 
conflated a deque with a heap.

Apologies for the confusion.

Cheers,
Cameron Simpson 

From python at mrabarnett.plus.com  Fri Mar 20 20:13:15 2020
From: python at mrabarnett.plus.com (MRAB)
Date: Sat, 21 Mar 2020 00:13:15 +0000
Subject: datepicker fails to find firstweekday in calendar
In-Reply-To: 
References: 
Message-ID: 

On 2020-03-20 22:43, Rich Shepard wrote:
> I'm running Python3-3.8.2 on Slackware-14.2/x86_64 and I tried to run Miguel
> Martinez Lopez's datepicker.py (version 1.0.7) before learning how I can use
> it in my application. It fails to find the attribute in the imported
> calendar module:
> 
> $ python3 datepicker.py
> Traceback (most recent call last):
>     File "datepicker.py", line 53, in 
>       class Calendar(ttk.Frame):
>     File "datepicker.py", line 57, in Calendar
>       def __init__(self, master=None, year=None, month=None,
> firstweekday=calendar.MONDAY, locale=None, activebackground='#b1dcfb',
> activeforeground='black', selectbackground='#003eff',
> selectforeground='white', command=None, borderwidth=1, relief="solid",
> on_click_month_button=None):
> AttributeError: module 'calendar' has no attribute 'MONDAY'
> 
> (N.B. The above itiation is line wrapped here but not in the trace back.)
> 
> Line 53 starts the calendar class:
> 
> class Calendar(ttk.Frame):
>       datetime = calendar.datetime.datetime
>       timedelta = calendar.datetime.timedelta
> 
>       def __init__(self, master=None, year=None, month=None,
> firstweekday=calendar.MONDAY, locale=None, activebackground='#b1dcfb',
> activeforeground='black', selectbackground='#003eff',
> selectforeground='white', command=None, borderwidth=1, relief="solid",
> on_click_month_button=None):
> 
> (N.B. Local line wrapping; in the code it's all on one line.)
> 
> Since calendar is built in to Python3-3.8.2 where do I look for the source
> of the problem so I can fix it?
> 
Is there another file called "calendar.py" somewhere?

Try putting "print(calendar.__file__)" after the import in the 
datepicker module.

From duncan at invalid.invalid  Fri Mar 20 20:15:41 2020
From: duncan at invalid.invalid (duncan smith)
Date: Sat, 21 Mar 2020 00:15:41 +0000
Subject: queue versus list
In-Reply-To: 
References: 
 
 
Message-ID: 

On 20/03/2020 21:57, Barry wrote:
> 
> 
>> On 20 Mar 2020, at 00:42, duncan smith  wrote:
>>
>> Bingo. Performance is indistinguishable from that of the list. Thread
>> safety is unimportant (for my purposes), but the docs at
>> https://docs.python.org/2/library/collections.html#collections.deque
>> state "Deques support thread-safe, memory efficient appends and pops
>> from either side of the deque with approximately the same O(1)
> 
> I did a performance test of list vs sequel as a fifo that had 10k elements in them.
> Then I timed insert elements at the tail and popping from the head.
> 
> Duque is 10x faster then list, rest run macOS python 3.8
> 
> Barry
> 
> 

Yes, I avoided the cost of popping elements from the head by just
iterating over the list. So the timings came out very similar. But the
deque allows me to remove those elements efficiently. It's also neat
because it lets me switch from what is basically a breadth first search
of a graph to a depth first search by simply changing popleft() to
popright(). Cheers.

Duncan

From rshepard at appl-ecosys.com  Fri Mar 20 21:31:39 2020
From: rshepard at appl-ecosys.com (Rich Shepard)
Date: Fri, 20 Mar 2020 18:31:39 -0700 (PDT)
Subject: datepicker fails to find firstweekday in calendar [FIXED]
In-Reply-To: 
References: 
 
Message-ID: 

On Sat, 21 Mar 2020, MRAB wrote:

> Is there another file called "calendar.py" somewhere?

MRAB,

Mea culpa! There was a 'calendar.py' file I had downloaded in the past in
the same directory. I assumed that Python would use the built-in one before
the one in the directory. Removing that file solved the problem.

> Try putting "print(calendar.__file__)" after the import in the datepicker 
> module.

I did this prior to removing the existing calendar.py file and nothing but
the two previously reported errors displayed in the terminal. It didn't
point to the on-disk file.

I learned a valuable lesson.

Thanks very much,

Rich

From frank at chagford.com  Sat Mar 21 09:43:19 2020
From: frank at chagford.com (Frank Millman)
Date: Sat, 21 Mar 2020 15:43:19 +0200
Subject: Intermittent bug with asyncio and MS Edge
Message-ID: 

Hi all

I have a strange intermittent bug.

The role-players -
     asyncio on Python 3.8 running on Windows 10
     Microsoft Edge running as a browser on the same machine

The bug does not occur with Python 3.7.
It does not occur with Chrome or Firefox.
It does not occur when MS Edge connects to another host on the network, 
running the same Python program (Python 3.8 on Fedora 31).

The symptoms -
     On receiving a connection, I send an HTML page to the browser,
         which has 20 lines like this -

     
     
     ...

Intermittently, one or other of the script files is not received by MS Edge.

I have checked the Network tab in Developer Tools in MS Edge. It shows 
the first few requests getting a Status 200 OK, then some are shown as 
'Pending'. This seems to be where the problem occurs.

I am hoping that someone can give me some hints about how to debug this.

My function to send the script file looks like this -

     async def send_file(writer, fname):

         status = 'HTTP/1.1 200 OK\r\n'
         writer.write(status.encode())

         headers = []
         headers.append(('CONNECTION', 'keep-alive'))
         headers.append(('DATE',
             email.utils.formatdate(usegmt=True)))
         headers.append(('SERVER',
            f'Python {sys.version.split()[0]} asyncio'))
         headers.append(('Content-type', 'text/javascript'))
         headers('Transfer-Encoding', 'chunked'))
         for key, val in headers:
             writer.write(f'{key}: {val}\r\n'.encode())
         writer.write('\r\n'.encode())
         await writer.drain()

         with open(fname 'rb') as fd:
             chunk = fd.read(8192)
             while chunk:
                 writer.write(hex(len(chunk))[2:].encode() + b'\r\n')
                 writer.write(chunk + b'\r\n')
                 await writer.drain()
                 chunk = fd.read(8192)
             writer.write(b'0\r\n\r\n')
             await writer.drain()

         writer.close()
         await writer.wait_closed()

I have asked the same question on StackOverflow, from an MS Edge 
perspective -
 
https://stackoverflow.com/questions/60785767/ms-edge-randomly-does-not-load-script

I don't know whether the problem lies with Python or MS Edge, but as it 
does not happen with Python 3.7, I am suspecting that something changed 
in 3.8 which does not match MS Edge's expectations.

Any hints much appreciated.

Frank Millman


From duncan at invalid.invalid  Sat Mar 21 13:19:21 2020
From: duncan at invalid.invalid (duncan smith)
Date: Sat, 21 Mar 2020 17:19:21 +0000
Subject: inheriting from long on Python2 or int on Python3
Message-ID: 

Hello,
      I have a class I wrote for Python2 that needs to be made to work
on Python3. On Python2 it inherited from long, so it needs to inherit
from int on Python3. The following works, but I'm not sure it's the
cleanest solution. It's the first time I've wanted / needed to make a
parent class conditional on the Python version, and I'm not sure it's
even a good idea. I used inheritance because I wanted to perform bitwise
operations on instances, but I could probably switch to composition.
Just wondering how bad the following really is (in a code smell kind of
a away). TIA.

Duncan


import sys

class C_hash(int if sys.version_info.major >= 3 else long):
    def __new__(cls, bits, m, N=1):
        obj = super(C_hash, cls).__new__(cls, bits)
        obj._m = m
        obj._N = N
        return obj

From barry at barrys-emacs.org  Sat Mar 21 14:04:11 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Sat, 21 Mar 2020 18:04:11 +0000
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
Message-ID: <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>



> On 21 Mar 2020, at 13:43, Frank Millman  wrote:
> 
> Hi all
> 
> I have a strange intermittent bug.
> 
> The role-players -
>    asyncio on Python 3.8 running on Windows 10
>    Microsoft Edge running as a browser on the same machine
> 
> The bug does not occur with Python 3.7.
> It does not occur with Chrome or Firefox.
> It does not occur when MS Edge connects to another host on the network, running the same Python program (Python 3.8 on Fedora 31).
> 
> The symptoms -
>    On receiving a connection, I send an HTML page to the browser,
>        which has 20 lines like this -
> 
>    
>    
>    ...
> 
> Intermittently, one or other of the script files is not received by MS Edge.
> 
> I have checked the Network tab in Developer Tools in MS Edge. It shows the first few requests getting a Status 200 OK, then some are shown as 'Pending'. This seems to be where the problem occurs.
> 
> I am hoping that someone can give me some hints about how to debug this.
> 
> My function to send the script file looks like this -
> 
>    async def send_file(writer, fname):
> 
>        status = 'HTTP/1.1 200 OK\r\n'
>        writer.write(status.encode())
> 
>        headers = []
>        headers.append(('CONNECTION', 'keep-alive'))
>        headers.append(('DATE',
>            email.utils.formatdate(usegmt=True)))
>        headers.append(('SERVER',
>           f'Python {sys.version.split()[0]} asyncio'))
>        headers.append(('Content-type', 'text/javascript'))
>        headers('Transfer-Encoding', 'chunked'))
>        for key, val in headers:
>            writer.write(f'{key}: {val}\r\n'.encode())
>        writer.write('\r\n'.encode())
>        await writer.drain()
> 
>        with open(fname 'rb') as fd:
>            chunk = fd.read(8192)
>            while chunk:
>                writer.write(hex(len(chunk))[2:].encode() + b'\r\n')
>                writer.write(chunk + b'\r\n')
>                await writer.drain()
>                chunk = fd.read(8192)
>            writer.write(b'0\r\n\r\n')
>            await writer.drain()
> 
>        writer.close()
>        await writer.wait_closed()
> 
> I have asked the same question on StackOverflow, from an MS Edge perspective -
> https://stackoverflow.com/questions/60785767/ms-edge-randomly-does-not-load-script
> 
> I don't know whether the problem lies with Python or MS Edge, but as it does not happen with Python 3.7, I am suspecting that something changed in 3.8 which does not match MS Edge's expectations.

I'd look at the network  traffic with wireshark to see if there is anything different between edge and the other browsers.

Aside: headers are case blind, but usually written capitalised. Some buggy software expects that its capitalised.

I wonder if it will start working if you do not do chunked (your chunked encoding looks correct).
You can use os.stat to find the size of the file for the Content-Length header.

Barry



> 
> Any hints much appreciated.
> 
> Frank Millman
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 


From rosuav at gmail.com  Sat Mar 21 15:52:05 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Sun, 22 Mar 2020 06:52:05 +1100
Subject: inheriting from long on Python2 or int on Python3
In-Reply-To: 
References: 
Message-ID: 

On Sun, Mar 22, 2020 at 4:21 AM duncan smith  wrote:
>
> Hello,
>       I have a class I wrote for Python2 that needs to be made to work
> on Python3. On Python2 it inherited from long, so it needs to inherit
> from int on Python3. The following works, but I'm not sure it's the
> cleanest solution. It's the first time I've wanted / needed to make a
> parent class conditional on the Python version, and I'm not sure it's
> even a good idea. I used inheritance because I wanted to perform bitwise
> operations on instances, but I could probably switch to composition.

try: int = long
except NameError: pass

Then just inherit from int. On Py3 it'll just work fine, and you can
drop those two lines of code once you drop Py2 support. On Py2 (which
is becoming less and less important now), it'll do that assignment.

Alternatively, don't worry about Py2 any more, and just change it to
inherit from it.

ChrisA

From skip.montanaro at gmail.com  Sat Mar 21 17:55:33 2020
From: skip.montanaro at gmail.com (Skip Montanaro)
Date: Sat, 21 Mar 2020 14:55:33 -0700
Subject: inheriting from long on Python2 or int on Python3
In-Reply-To: 
References: 
Message-ID: 

> import sys
>
> class C_hash(int if sys.version_info.major >= 3 else long):
...

There's nothing incorrect with your solution. Chris offered another. I
was going to suggest you consider running your code through 2to3 to
see what it does. I created a C_hash class similar to yours:

class C_hash(long):
    def __new__(cls, bits, m, N=1):
        obj = super(C_hash, cls).__new__(cls, bits)
        obj._m = m
        obj._N = N
        return obj

    def meth(self):
        pass

When I ran it through 2to3, it didn't make any transformations, which
I thought odd. Still, assuming I did something wrong, you might poke
around with it a bit to see if you can get it to do the work for you.

Skip

From duncan at invalid.invalid  Sat Mar 21 20:25:22 2020
From: duncan at invalid.invalid (duncan smith)
Date: Sun, 22 Mar 2020 00:25:22 +0000
Subject: inheriting from long on Python2 or int on Python3
In-Reply-To: 
References: 
 
 
Message-ID: 

On 21/03/2020 21:55, Skip Montanaro wrote:
>> import sys
>>
>> class C_hash(int if sys.version_info.major >= 3 else long):
> ...
> 
> There's nothing incorrect with your solution. Chris offered another. I
> was going to suggest you consider running your code through 2to3 to
> see what it does. I created a C_hash class similar to yours:
> 
> class C_hash(long):
>     def __new__(cls, bits, m, N=1):
>         obj = super(C_hash, cls).__new__(cls, bits)
>         obj._m = m
>         obj._N = N
>         return obj
> 
>     def meth(self):
>         pass
> 
> When I ran it through 2to3, it didn't make any transformations, which
> I thought odd. Still, assuming I did something wrong, you might poke
> around with it a bit to see if you can get it to do the work for you.
> 
> Skip
> 

According to the docs (https://docs.python.org/2/library/2to3.html) it
should have renamed long to int. I also tried something closer to
Chris's suggestion,


try:
    long
except NameError:
    long = int

class C_hash(long):
    # etc.


but (tentatively) opted for something that avoided creating new names at
the module level. If it doesn't look too terrible I might stick with it
for now (although I am quite tempted to go back to the above). Thanks
Skip and Chris.

Duncan

From rosuav at gmail.com  Sat Mar 21 20:59:32 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Sun, 22 Mar 2020 11:59:32 +1100
Subject: inheriting from long on Python2 or int on Python3
In-Reply-To: 
References: 
 
 
 
Message-ID: 

On Sun, Mar 22, 2020 at 11:31 AM duncan smith  wrote:
> but (tentatively) opted for something that avoided creating new names at
> the module level. If it doesn't look too terrible I might stick with it
> for now (although I am quite tempted to go back to the above). Thanks
> Skip and Chris.

Nah, nothing wrong with creating module-level names for things that
would otherwise be builtins. It's like how a __future__ directive
applies to the module it's in. Go ahead! It's a nice practical easy
way to do things.

ChrisA

From tjreedy at udel.edu  Sat Mar 21 14:00:29 2020
From: tjreedy at udel.edu (Terry Reedy)
Date: Sat, 21 Mar 2020 14:00:29 -0400
Subject: inheriting from long on Python2 or int on Python3
In-Reply-To: 
References: 
Message-ID: 

On 3/21/2020 1:19 PM, duncan smith wrote:
> Hello,
>        I have a class I wrote for Python2 that needs to be made to work
> on Python3. On Python2 it inherited from long, so it needs to inherit
> from int on Python3.

In general, if you want code to work on both 2 and 3, look into the 
bi-version packages such as 'six' and 'future' and documents such as
https://python-future.org/compatible_idioms.html.

If 'long' appears more than once in your code, you might prefer using 
this at the top.

if sys.version_info.major >= 3:
     long = int

This has the plus of indicating that this is a 2 and 3 file, if anyone 
else reads it.

> The following works, but I'm not sure it's the cleanest solution.

It does not bother me.

> It's the first time I've wanted / needed to make a
> parent class conditional on the Python version, and I'm not sure it's
> even a good idea. I used inheritance because I wanted to perform bitwise
> operations on instances, but I could probably switch to composition.
> Just wondering how bad the following really is (in a code smell kind of
> a away). TIA.

> import sys
> 
> class C_hash(int if sys.version_info.major >= 3 else long):
>      def __new__(cls, bits, m, N=1):
>          obj = super(C_hash, cls).__new__(cls, bits)
>          obj._m = m
>          obj._N = N
>          return obj

-- 
Terry Jan Reedy


From greg.ewing at canterbury.ac.nz  Sun Mar 22 00:47:28 2020
From: greg.ewing at canterbury.ac.nz (Greg Ewing)
Date: Sun, 22 Mar 2020 17:47:28 +1300
Subject: Python 3.8.2 on MacOSX Sierra?
Message-ID: 

I'm trying to compile a framework build of Python 3.8.2 on
MacOSX 10.12.6 (Sierra). I'm getting:

./Modules/posixmodule.c:4696:12: warning: 'utimensat' is only available 
on macOS
       10.13 or newer [-Wunguarded-availability-new]
     return utimensat(dir_fd, path, time, flags);

./Modules/posixmodule.c:4721:12: warning: 'futimens' is only available 
on macOS
       10.13 or newer [-Wunguarded-availability-new]
     return futimens(fd, time);

And later when linking:

dyld: lazy symbol binding failed: Symbol not found: _utimensat
   Referenced from: 
/Local/Build/Python/Python-3.8.2/Python.framework/Versions/3.8/Python
   Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _utimensat
   Referenced from: 
/Local/Build/Python/Python-3.8.2/Python.framework/Versions/3.8/Python
   Expected in: /usr/lib/libSystem.B.dylib

make: *** [sharedinstall] Abort trap: 6

Am I out of luck? Is Python 3.8 only intended work on very recent
versions of MacOSX?

-- 
Greg

From auriocus at gmx.de  Sun Mar 22 03:06:41 2020
From: auriocus at gmx.de (Christian Gollwitzer)
Date: Sun, 22 Mar 2020 08:06:41 +0100
Subject: Converting program from shell to tkinter
In-Reply-To: 
References: 
Message-ID: 

Hi Randall,

I assume you are asking about the Python programming language 
(tkinter??). This group discusses the Tcl programming language, from 
which Tk originates. See 2 answers below.
Xpost and Fup2 c.l.p

Christian

Am 22.03.20 um 00:59 schrieb Randall Wert:
> I am trying to enhance a shell program -- you know, the kind that communicates with the user through simple lines of text, using print() and input() statements -- by adding a tkinter interface. I have successfully completed three projects using tkinter in the past, but this one is proving more difficult. The essence of the problem is, I want the program to still have the same control flow as in the "shell" program. It should issue messages to the user and receive their input. But tkinter seems to be purely designed for event-driven programs (responding to button clicks, for example).
> 
> To be more specific: It is a hangman game. The user enters different types of input as the program runs (choice of difficulty level, letters (guesses), Y/N for playing another game, etc.). I would like to be able to use a single user entry field for all of those purposes, and accept input from it when the user presses Enter, instead of having a different button for each type of user input.
> 
> I hope I am explaining it clearly. I would appreciate any tips on converting to a tkinter interface while maintaining the same program flow.
> 

You must convert the program into a state machine. Luckily, both Tcl and 
Python can help you with this, in the form of a coroutine. For Tcl, take 
a look to this page

https://wiki.tcl-lang.org/page/Coroutines+for+event-based+programming

For Python, look up generators and google "asyncio tkinter".

Christian


From frank at chagford.com  Sun Mar 22 03:56:29 2020
From: frank at chagford.com (Frank Millman)
Date: Sun, 22 Mar 2020 09:56:29 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
Message-ID: 

On 2020-03-21 8:04 PM, Barry Scott wrote:
> 
> 
>> On 21 Mar 2020, at 13:43, Frank Millman  wrote:
>>
>> Hi all
>>
>> I have a strange intermittent bug.
>>
>> The role-players -
>>     asyncio on Python 3.8 running on Windows 10
>>     Microsoft Edge running as a browser on the same machine
>>
>> The bug does not occur with Python 3.7.
>> It does not occur with Chrome or Firefox.
>> It does not occur when MS Edge connects to another host on the network, running the same Python program (Python 3.8 on Fedora 31).
>>
>> The symptoms -
>>     On receiving a connection, I send an HTML page to the browser,
>>         which has 20 lines like this -
>>
>>     
>>     
>>     ...
>>
>> Intermittently, one or other of the script files is not received by MS Edge.
>>
[...]
>> >> I don't know whether the problem lies with Python or MS Edge, but as 
it does not happen with Python 3.7, I am suspecting that something 
changed in 3.8 which does not match MS Edge's expectations.
> 
> I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
> 

You are leading me into deep waters here :-)  I have never used 
Wireshark before. I have now downloaded it and am running it - it 
generates a *lot* of data, most of which I do not understand yet!

One thing immediately stands out. When I run it with MS Edge and 
Python3.8, it shows a lot of lines highlighted in red, with the symbols 
[RST,ACK]. They do not appear when running Chrome, and they do not 
appear when running Python3.7.

I have another data point. I tried putting an asyncio.sleep() after 
sending each file. A value of 0.01 made no difference, but a value of 
0.1 makes the problem go away.

I will keep digging, but I thought I would post this information now in 
case it helps with diagnosis.

Frank


From frank at chagford.com  Sun Mar 22 03:56:29 2020
From: frank at chagford.com (Frank Millman)
Date: Sun, 22 Mar 2020 09:56:29 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
Message-ID: 

On 2020-03-21 8:04 PM, Barry Scott wrote:
> 
> 
>> On 21 Mar 2020, at 13:43, Frank Millman  wrote:
>>
>> Hi all
>>
>> I have a strange intermittent bug.
>>
>> The role-players -
>>     asyncio on Python 3.8 running on Windows 10
>>     Microsoft Edge running as a browser on the same machine
>>
>> The bug does not occur with Python 3.7.
>> It does not occur with Chrome or Firefox.
>> It does not occur when MS Edge connects to another host on the network, running the same Python program (Python 3.8 on Fedora 31).
>>
>> The symptoms -
>>     On receiving a connection, I send an HTML page to the browser,
>>         which has 20 lines like this -
>>
>>     
>>     
>>     ...
>>
>> Intermittently, one or other of the script files is not received by MS Edge.
>>
[...]
>> >> I don't know whether the problem lies with Python or MS Edge, but as 
it does not happen with Python 3.7, I am suspecting that something 
changed in 3.8 which does not match MS Edge's expectations.
> 
> I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
> 

You are leading me into deep waters here :-)  I have never used 
Wireshark before. I have now downloaded it and am running it - it 
generates a *lot* of data, most of which I do not understand yet!

One thing immediately stands out. When I run it with MS Edge and 
Python3.8, it shows a lot of lines highlighted in red, with the symbols 
[RST,ACK]. They do not appear when running Chrome, and they do not 
appear when running Python3.7.

I have another data point. I tried putting an asyncio.sleep() after 
sending each file. A value of 0.01 made no difference, but a value of 
0.1 makes the problem go away.

I will keep digging, but I thought I would post this information now in 
case it helps with diagnosis.

Frank

From rosuav at gmail.com  Sun Mar 22 04:45:15 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Sun, 22 Mar 2020 19:45:15 +1100
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
Message-ID: 

On Sun, Mar 22, 2020 at 6:58 PM Frank Millman  wrote:
> > I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
> >
>
> You are leading me into deep waters here :-)  I have never used
> Wireshark before. I have now downloaded it and am running it - it
> generates a *lot* of data, most of which I do not understand yet!
>
> One thing immediately stands out. When I run it with MS Edge and
> Python3.8, it shows a lot of lines highlighted in red, with the symbols
> [RST,ACK]. They do not appear when running Chrome, and they do not
> appear when running Python3.7.

Interesting. RST means "Reset" and is sent when the connection is
closed. Which direction were these packets sent (Edge to Python or
Python to Edge)? You can tell by the source and destination ports -
one of them is going to be the port Python is listening on (eg 80 or
443), so if the destination port is 80, it's being sent *to* Python,
and if the source port is 80, it's being sent *from* Python.

> I have another data point. I tried putting an asyncio.sleep() after
> sending each file. A value of 0.01 made no difference, but a value of
> 0.1 makes the problem go away.

Interesting also.

Can you recreate the problem without Edge? It sounds like something's
going on with concurrent transfers, so it'd be awesome if you can
replace Edge with another Python program, and then post both programs.

Also of interest: Does the problem go away if you change "Connection:
Keep-Alive" to "Connection: Close" in your headers?

ChrisA

From barry at barrys-emacs.org  Sun Mar 22 04:55:10 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Sun, 22 Mar 2020 08:55:10 +0000
Subject: Python 3.8.2 on MacOSX Sierra?
In-Reply-To: 
References: 
Message-ID: <189164B5-2F9B-4F95-ABFF-1E9E51F33018@barrys-emacs.org>



> On 22 Mar 2020, at 04:47, Greg Ewing  wrote:
> 
> I'm trying to compile a framework build of Python 3.8.2 on
> MacOSX 10.12.6 (Sierra).

I guess you are using an old Mac that will not update to something newer?

> I'm getting:
> 
> ./Modules/posixmodule.c:4696:12: warning: 'utimensat' is only available on macOS
>      10.13 or newer [-Wunguarded-availability-new]
>    return utimensat(dir_fd, path, time, flags);
> 
> ./Modules/posixmodule.c:4721:12: warning: 'futimens' is only available on macOS
>      10.13 or newer [-Wunguarded-availability-new]
>    return futimens(fd, time);
> 
> And later when linking:
> 
> dyld: lazy symbol binding failed: Symbol not found: _utimensat
>  Referenced from: /Local/Build/Python/Python-3.8.2/Python.framework/Versions/3.8/Python
>  Expected in: /usr/lib/libSystem.B.dylib
> 
> dyld: Symbol not found: _utimensat
>  Referenced from: /Local/Build/Python/Python-3.8.2/Python.framework/Versions/3.8/Python
>  Expected in: /usr/lib/libSystem.B.dylib
> 
> make: *** [sharedinstall] Abort trap: 6
> 
> Am I out of luck? Is Python 3.8 only intended work on very recent
> versions of MacOSX?

if your XCode is new enough you might be able to build it with 

	export MACOSX_DEPLOYMENT_TARGET=10.13

But I guess the result will not run.

Barry

> 
> -- 
> Greg
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 


From barry at barrys-emacs.org  Sun Mar 22 05:00:41 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Sun, 22 Mar 2020 09:00:41 +0000
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
Message-ID: 



> On 22 Mar 2020, at 07:56, Frank Millman  wrote:
> 
> On 2020-03-21 8:04 PM, Barry Scott wrote:
>>> On 21 Mar 2020, at 13:43, Frank Millman  wrote:
>>> 
>>> Hi all
>>> 
>>> I have a strange intermittent bug.
>>> 
>>> The role-players -
>>>    asyncio on Python 3.8 running on Windows 10
>>>    Microsoft Edge running as a browser on the same machine
>>> 
>>> The bug does not occur with Python 3.7.
>>> It does not occur with Chrome or Firefox.
>>> It does not occur when MS Edge connects to another host on the network, running the same Python program (Python 3.8 on Fedora 31).
>>> 
>>> The symptoms -
>>>    On receiving a connection, I send an HTML page to the browser,
>>>        which has 20 lines like this -
>>> 
>>>    
>>>    
>>>    ...
>>> 
>>> Intermittently, one or other of the script files is not received by MS Edge.
>>> 
> [...]
>>> >> I don't know whether the problem lies with Python or MS Edge, but as 
> it does not happen with Python 3.7, I am suspecting that something changed in 3.8 which does not match MS Edge's expectations.
>> I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
> 
> You are leading me into deep waters here :-)  I have never used Wireshark before. I have now downloaded it and am running it - it generates a *lot* of data, most of which I do not understand yet!

You can tell wireshark to only capture on one interface and to only capture packets for port 80.
(Captureing HTTPS means you cannot decode the packets without going deeper I recall)

Then you can tell wireshark to decode the captured data for http to drop a lot of the lower level details.


> 
> One thing immediately stands out. When I run it with MS Edge and Python3.8, it shows a lot of lines highlighted in red, with the symbols [RST,ACK]. They do not appear when running Chrome, and they do not appear when running Python3.7.

As Chris said that should not happen.

> 
> I have another data point. I tried putting an asyncio.sleep() after sending each file. A value of 0.01 made no difference, but a value of 0.1 makes the problem go away.

What is the async wait to wait for the transmit buffers to drain?

> 
> I will keep digging, but I thought I would post this information now in case it helps with diagnosis.
> 
> Frank
> -- 
> https://mail.python.org/mailman/listinfo/python-list 
Barry

From greg.ewing at canterbury.ac.nz  Sun Mar 22 05:20:14 2020
From: greg.ewing at canterbury.ac.nz (Greg Ewing)
Date: Sun, 22 Mar 2020 22:20:14 +1300
Subject: Python 3.8.2 on MacOSX Sierra?
In-Reply-To: 
References: 
 <189164B5-2F9B-4F95-ABFF-1E9E51F33018@barrys-emacs.org>
 
Message-ID: 

On 22/03/20 9:55 pm, Barry Scott wrote:
> I guess you are using an old Mac that will not update to something newer?

It's more that I don't *want* to update to something newer if I
don't have to. Also it seems very un-python-like to depend on a
specific OS version like this, which leads me to believe that
something is wrong somewhere.

> if your XCode is new enough you might be able to build it with
> 
> 	export MACOSX_DEPLOYMENT_TARGET=10.13

Actually it seems to be more a matter of my XCode being *too*
new. I was using XCode 9, which turns out to contain an SDK
for 10.13. Which shouldn't matter, except that there seems to
be a bug in autoconf that makes it think some things are there
even though they're not:

https://bugs.python.org/issue31359

That's talking about a slightly different scenario (building
with one version and running on an older version) but I think
I'm being bitten by the same underlying issue.

I'm going to try again with XCode 8, which purportedly comes
with a 10.12 SDK, and see if that fixes it.

-- 
Greg


From frank at chagford.com  Sun Mar 22 05:26:22 2020
From: frank at chagford.com (Frank Millman)
Date: Sun, 22 Mar 2020 11:26:22 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
Message-ID: <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>

On 2020-03-22 10:45 AM, Chris Angelico wrote:
> On Sun, Mar 22, 2020 at 6:58 PM Frank Millman  wrote:
>>> I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
>>>
>>
>> You are leading me into deep waters here :-)  I have never used
>> Wireshark before. I have now downloaded it and am running it - it
>> generates a *lot* of data, most of which I do not understand yet!
>>
>> One thing immediately stands out. When I run it with MS Edge and
>> Python3.8, it shows a lot of lines highlighted in red, with the symbols
>> [RST,ACK]. They do not appear when running Chrome, and they do not
>> appear when running Python3.7.
> 
> Interesting. RST means "Reset" and is sent when the connection is
> closed. Which direction were these packets sent (Edge to Python or
> Python to Edge)? You can tell by the source and destination ports -
> one of them is going to be the port Python is listening on (eg 80 or
> 443), so if the destination port is 80, it's being sent *to* Python,
> and if the source port is 80, it's being sent *from* Python.
> 

They are all being sent *from* Python *to* Edge.

>> I have another data point. I tried putting an asyncio.sleep() after
>> sending each file. A value of 0.01 made no difference, but a value of
>> 0.1 makes the problem go away.
> 
> Interesting also.
> 
> Can you recreate the problem without Edge? It sounds like something's
> going on with concurrent transfers, so it'd be awesome if you can
> replace Edge with another Python program, and then post both programs.
> 

Do you mean write a program that emulates a browser - make a connection, 
receive the HTML page, send a GET request for each file, and receive the 
results?

I will give it a go!

> Also of interest: Does the problem go away if you change "Connection:
> Keep-Alive" to "Connection: Close" in your headers?
> 

Yes, the problem does go away.

Frank


From frank at chagford.com  Sun Mar 22 05:26:22 2020
From: frank at chagford.com (Frank Millman)
Date: Sun, 22 Mar 2020 11:26:22 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
Message-ID: <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>

On 2020-03-22 10:45 AM, Chris Angelico wrote:
> On Sun, Mar 22, 2020 at 6:58 PM Frank Millman  wrote:
>>> I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
>>>
>>
>> You are leading me into deep waters here :-)  I have never used
>> Wireshark before. I have now downloaded it and am running it - it
>> generates a *lot* of data, most of which I do not understand yet!
>>
>> One thing immediately stands out. When I run it with MS Edge and
>> Python3.8, it shows a lot of lines highlighted in red, with the symbols
>> [RST,ACK]. They do not appear when running Chrome, and they do not
>> appear when running Python3.7.
> 
> Interesting. RST means "Reset" and is sent when the connection is
> closed. Which direction were these packets sent (Edge to Python or
> Python to Edge)? You can tell by the source and destination ports -
> one of them is going to be the port Python is listening on (eg 80 or
> 443), so if the destination port is 80, it's being sent *to* Python,
> and if the source port is 80, it's being sent *from* Python.
> 

They are all being sent *from* Python *to* Edge.

>> I have another data point. I tried putting an asyncio.sleep() after
>> sending each file. A value of 0.01 made no difference, but a value of
>> 0.1 makes the problem go away.
> 
> Interesting also.
> 
> Can you recreate the problem without Edge? It sounds like something's
> going on with concurrent transfers, so it'd be awesome if you can
> replace Edge with another Python program, and then post both programs.
> 

Do you mean write a program that emulates a browser - make a connection, 
receive the HTML page, send a GET request for each file, and receive the 
results?

I will give it a go!

> Also of interest: Does the problem go away if you change "Connection:
> Keep-Alive" to "Connection: Close" in your headers?
> 

Yes, the problem does go away.

Frank

From frank at chagford.com  Sun Mar 22 05:41:09 2020
From: frank at chagford.com (Frank Millman)
Date: Sun, 22 Mar 2020 11:41:09 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
Message-ID: 

On 2020-03-22 11:00 AM, Barry Scott wrote:
> 
> 
>> On 22 Mar 2020, at 07:56, Frank Millman  wrote:
>>
>> On 2020-03-21 8:04 PM, Barry Scott wrote:
>>> I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
>>
>> You are leading me into deep waters here :-)  I have never used Wireshark before. I have now downloaded it and am running it - it generates a *lot* of data, most of which I do not understand yet!
> 
> You can tell wireshark to only capture on one interface and to only capture packets for port 80.
> (Captureing HTTPS means you cannot decode the packets without going deeper I recall)
> 
> Then you can tell wireshark to decode the captured data for http to drop a lot of the lower level details.
> 

Thanks. I am more or less doing that. Interestingly the [RST,ACK] 
messages appear on the tcp packets, so if I filter on http I do not see 
them.

> 
>>
>> One thing immediately stands out. When I run it with MS Edge and Python3.8, it shows a lot of lines highlighted in red, with the symbols [RST,ACK]. They do not appear when running Chrome, and they do not appear when running Python3.7.
> 
> As Chris said that should not happen.
> 

As I replied to Chris, they appear in packets sent *from* Python *to* Edge.

>>
>> I have another data point. I tried putting an asyncio.sleep() after sending each file. A value of 0.01 made no difference, but a value of 0.1 makes the problem go away.
> 
> What is the async wait to wait for the transmit buffers to drain?
> 

Not sure what you are asking. I am just doing what it says in the docs -

=================

write(data)
The method attempts to write the data to the underlying socket 
immediately. If that fails, the data is queued in an internal write 
buffer until it can be sent.

The method should be used along with the drain() method:

stream.write(data)
await stream.drain()

=================

coroutine drain()
Wait until it is appropriate to resume writing to the stream. Example:

writer.write(data)
await writer.drain()
This is a flow control method that interacts with the underlying IO 
write buffer. When the size of the buffer reaches the high watermark, 
drain() blocks until the size of the buffer is drained down to the low 
watermark and writing can be resumed. When there is nothing to wait for, 
the drain() returns immediately.

=================

Frank


From frank at chagford.com  Sun Mar 22 05:41:09 2020
From: frank at chagford.com (Frank Millman)
Date: Sun, 22 Mar 2020 11:41:09 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
Message-ID: 

On 2020-03-22 11:00 AM, Barry Scott wrote:
> 
> 
>> On 22 Mar 2020, at 07:56, Frank Millman  wrote:
>>
>> On 2020-03-21 8:04 PM, Barry Scott wrote:
>>> I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
>>
>> You are leading me into deep waters here :-)  I have never used Wireshark before. I have now downloaded it and am running it - it generates a *lot* of data, most of which I do not understand yet!
> 
> You can tell wireshark to only capture on one interface and to only capture packets for port 80.
> (Captureing HTTPS means you cannot decode the packets without going deeper I recall)
> 
> Then you can tell wireshark to decode the captured data for http to drop a lot of the lower level details.
> 

Thanks. I am more or less doing that. Interestingly the [RST,ACK] 
messages appear on the tcp packets, so if I filter on http I do not see 
them.

> 
>>
>> One thing immediately stands out. When I run it with MS Edge and Python3.8, it shows a lot of lines highlighted in red, with the symbols [RST,ACK]. They do not appear when running Chrome, and they do not appear when running Python3.7.
> 
> As Chris said that should not happen.
> 

As I replied to Chris, they appear in packets sent *from* Python *to* Edge.

>>
>> I have another data point. I tried putting an asyncio.sleep() after sending each file. A value of 0.01 made no difference, but a value of 0.1 makes the problem go away.
> 
> What is the async wait to wait for the transmit buffers to drain?
> 

Not sure what you are asking. I am just doing what it says in the docs -

=================

write(data)
The method attempts to write the data to the underlying socket 
immediately. If that fails, the data is queued in an internal write 
buffer until it can be sent.

The method should be used along with the drain() method:

stream.write(data)
await stream.drain()

=================

coroutine drain()
Wait until it is appropriate to resume writing to the stream. Example:

writer.write(data)
await writer.drain()
This is a flow control method that interacts with the underlying IO 
write buffer. When the size of the buffer reaches the high watermark, 
drain() blocks until the size of the buffer is drained down to the low 
watermark and writing can be resumed. When there is nothing to wait for, 
the drain() returns immediately.

=================

Frank

From rosuav at gmail.com  Sun Mar 22 06:11:27 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Sun, 22 Mar 2020 21:11:27 +1100
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
Message-ID: 

On Sun, Mar 22, 2020 at 8:30 PM Frank Millman  wrote:
>
> On 2020-03-22 10:45 AM, Chris Angelico wrote:
> > On Sun, Mar 22, 2020 at 6:58 PM Frank Millman  wrote:
> >>> I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
> >>>
> >>
> >> You are leading me into deep waters here :-)  I have never used
> >> Wireshark before. I have now downloaded it and am running it - it
> >> generates a *lot* of data, most of which I do not understand yet!
> >>
> >> One thing immediately stands out. When I run it with MS Edge and
> >> Python3.8, it shows a lot of lines highlighted in red, with the symbols
> >> [RST,ACK]. They do not appear when running Chrome, and they do not
> >> appear when running Python3.7.
> >
> > Interesting. RST means "Reset" and is sent when the connection is
> > closed. Which direction were these packets sent (Edge to Python or
> > Python to Edge)? You can tell by the source and destination ports -
> > one of them is going to be the port Python is listening on (eg 80 or
> > 443), so if the destination port is 80, it's being sent *to* Python,
> > and if the source port is 80, it's being sent *from* Python.
> >
>
> They are all being sent *from* Python *to* Edge.

Very interesting indeed. What that *might* mean is that Python is
misinterpreting something and then believing that the connection has
been closed, so it responds "Okay, I'm closing the connection". Or
possibly it sees some sort of error condition.

> >> I have another data point. I tried putting an asyncio.sleep() after
> >> sending each file. A value of 0.01 made no difference, but a value of
> >> 0.1 makes the problem go away.
> >
> > Interesting also.
> >
> > Can you recreate the problem without Edge? It sounds like something's
> > going on with concurrent transfers, so it'd be awesome if you can
> > replace Edge with another Python program, and then post both programs.
> >
>
> Do you mean write a program that emulates a browser - make a connection,
> receive the HTML page, send a GET request for each file, and receive the
> results?
>
> I will give it a go!

Yes - although the HTML page is most likely irrelevant. You could just
make a connection and then spam requests. Or make multiple
connections.

Actually, that's another thing worth checking. Is Edge using a single
connection for all requests, or separate connections for each request,
or something in between (eg a pool of four connections and spreading
requests between them)? You'll be able to recognize different
connections by the port numbers Edge uses, which are guaranteed unique
among concurrent connections, and are most likely to not be reused for
a while even if the other is closed.

> > Also of interest: Does the problem go away if you change "Connection:
> > Keep-Alive" to "Connection: Close" in your headers?
> >
>
> Yes, the problem does go away.
>

This makes me think that the answer to the previous question is going
to involve some connection reuse.

If you can recreate the problem with a single socket and multiple
requests, that would be extremely helpful. I also think it's highly
likely that this is the case.

My theory: Your program is sending a large amount of data to the lower
level API functions, which attempt to send a large amount of data to
the socket. At some point, something gets told "sorry, can't handle
all that data, hold some of it back" at a time when it's not prepared
to do so, and it misinterprets it as an error. This error results in
the connection being closed.

But that's just a theory.

ChrisA

From rosuav at gmail.com  Sun Mar 22 06:13:51 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Sun, 22 Mar 2020 21:13:51 +1100
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 
Message-ID: 

On Sun, Mar 22, 2020 at 8:42 PM Frank Millman  wrote:
>
> On 2020-03-22 11:00 AM, Barry Scott wrote:
> >
> >
> >> On 22 Mar 2020, at 07:56, Frank Millman  wrote:
> >>
> >> On 2020-03-21 8:04 PM, Barry Scott wrote:
> >>> I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
> >>
> >> You are leading me into deep waters here :-)  I have never used Wireshark before. I have now downloaded it and am running it - it generates a *lot* of data, most of which I do not understand yet!
> >
> > You can tell wireshark to only capture on one interface and to only capture packets for port 80.
> > (Captureing HTTPS means you cannot decode the packets without going deeper I recall)
> >
> > Then you can tell wireshark to decode the captured data for http to drop a lot of the lower level details.
> >
>
> Thanks. I am more or less doing that. Interestingly the [RST,ACK]
> messages appear on the tcp packets, so if I filter on http I do not see
> them.
>

I'm not 100% sure what "filter on HTTP" actually means, and it might
show only the data packets. Instead, filter on "from port 80 or to
port 80", which should show you the entire connection including the
SYN - SYN/ACK - ACK handshake, every data and acknowledgement packet,
and then whichever closing sequence gets used.

> >> I have another data point. I tried putting an asyncio.sleep() after sending each file. A value of 0.01 made no difference, but a value of 0.1 makes the problem go away.
> >
> > What is the async wait to wait for the transmit buffers to drain?
> >
>
> Not sure what you are asking. I am just doing what it says in the docs -
>

I think his question is "what would asyncio be sleeping for, since you
already made it wait till it was drained". And my guess is that
there's a bug somewhere; the question is where.

ChrisA

From rosuav at gmail.com  Sun Mar 22 07:01:54 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Sun, 22 Mar 2020 22:01:54 +1100
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
Message-ID: 

On Sun, Mar 22, 2020 at 12:45 AM Frank Millman  wrote:
>
> Hi all
>
> I have a strange intermittent bug.
>
> The role-players -
>      asyncio on Python 3.8 running on Windows 10
>      Microsoft Edge running as a browser on the same machine
>
> The bug does not occur with Python 3.7.
> It does not occur with Chrome or Firefox.
> It does not occur when MS Edge connects to another host on the network,
> running the same Python program (Python 3.8 on Fedora 31).

What exact version of Python 3.7 did you test? I'm looking through the
changes to asyncio and came across this one, which may have some
impact.

https://bugs.python.org/issue36801

Also this one made a change that introduced a regression that was
subsequently fixed. Could be interesting.

https://bugs.python.org/issue36802

What happens if you try awaiting your writes? I think it probably
won't make any difference, though - from my reading of the source, I
believe that "await writer.write(...)" is the same as
"writer.write(...); await writer.drain()", so it's going to be exactly
the same as you're already doing.

ChrisA

From greg.ewing at canterbury.ac.nz  Sun Mar 22 07:26:23 2020
From: greg.ewing at canterbury.ac.nz (Greg Ewing)
Date: Mon, 23 Mar 2020 00:26:23 +1300
Subject: Python 3.8.2 on MacOSX Sierra?
In-Reply-To: 
References: 
 <189164B5-2F9B-4F95-ABFF-1E9E51F33018@barrys-emacs.org>
 
 
Message-ID: 

On 22/03/20 10:20 pm, Greg Ewing wrote:
> I'm going to try again with XCode 8, which purportedly comes
> with a 10.12 SDK, and see if that fixes it.

It does.

-- 
Greg


From dev at kou.li  Sun Mar 22 07:30:44 2020
From: dev at kou.li (Kouli)
Date: Sun, 22 Mar 2020 12:30:44 +0100
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 
Message-ID: 

The RST from Python is probably caused here by HTTP 1.1 server closing TCP
connection without signalling "Connection: Close" in response headers: a
fast HTTP client will send another HTTP request before its TCP stack
detects the connection is being closed - and packets containing this new
requests will be replied with RST.

When you delay your response (as you mentioned), the Edge browser probably
opens more HTTP connections and will not send more HTTP requests in a
single connection as described above.

You should search for the cause Python closes the TCP connection (instead
of waiting for another HTTP request).

Kouli

On Sun, Mar 22, 2020 at 12:04 PM Chris Angelico  wrote:

> On Sun, Mar 22, 2020 at 12:45 AM Frank Millman  wrote:
> >
> > Hi all
> >
> > I have a strange intermittent bug.
> >
> > The role-players -
> >      asyncio on Python 3.8 running on Windows 10
> >      Microsoft Edge running as a browser on the same machine
> >
> > The bug does not occur with Python 3.7.
> > It does not occur with Chrome or Firefox.
> > It does not occur when MS Edge connects to another host on the network,
> > running the same Python program (Python 3.8 on Fedora 31).
>
> What exact version of Python 3.7 did you test? I'm looking through the
> changes to asyncio and came across this one, which may have some
> impact.
>
> https://bugs.python.org/issue36801
>
> Also this one made a change that introduced a regression that was
> subsequently fixed. Could be interesting.
>
> https://bugs.python.org/issue36802
>
> What happens if you try awaiting your writes? I think it probably
> won't make any difference, though - from my reading of the source, I
> believe that "await writer.write(...)" is the same as
> "writer.write(...); await writer.drain()", so it's going to be exactly
> the same as you're already doing.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From frank at chagford.com  Sun Mar 22 07:59:50 2020
From: frank at chagford.com (Frank Millman)
Date: Sun, 22 Mar 2020 13:59:50 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 
Message-ID: <820c2408-172b-b056-2eae-4fabb3d355c6@chagford.com>

On 2020-03-22 1:01 PM, Chris Angelico wrote:
> On Sun, Mar 22, 2020 at 12:45 AM Frank Millman  wrote:
>>
>> Hi all
>>
>> I have a strange intermittent bug.
>>
>> The role-players -
>>       asyncio on Python 3.8 running on Windows 10
>>       Microsoft Edge running as a browser on the same machine
>>
>> The bug does not occur with Python 3.7.
>> It does not occur with Chrome or Firefox.
>> It does not occur when MS Edge connects to another host on the network,
>> running the same Python program (Python 3.8 on Fedora 31).
> 
> What exact version of Python 3.7 did you test? I'm looking through the
> changes to asyncio and came across this one, which may have some
> impact.

Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 
64 bit (AMD64)] on win32

Frank


From frank at chagford.com  Sun Mar 22 07:59:50 2020
From: frank at chagford.com (Frank Millman)
Date: Sun, 22 Mar 2020 13:59:50 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 
Message-ID: <820c2408-172b-b056-2eae-4fabb3d355c6@chagford.com>

On 2020-03-22 1:01 PM, Chris Angelico wrote:
> On Sun, Mar 22, 2020 at 12:45 AM Frank Millman  wrote:
>>
>> Hi all
>>
>> I have a strange intermittent bug.
>>
>> The role-players -
>>       asyncio on Python 3.8 running on Windows 10
>>       Microsoft Edge running as a browser on the same machine
>>
>> The bug does not occur with Python 3.7.
>> It does not occur with Chrome or Firefox.
>> It does not occur when MS Edge connects to another host on the network,
>> running the same Python program (Python 3.8 on Fedora 31).
> 
> What exact version of Python 3.7 did you test? I'm looking through the
> changes to asyncio and came across this one, which may have some
> impact.

Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 
64 bit (AMD64)] on win32

Frank

From aishan0403 at gmail.com  Sun Mar 22 10:47:38 2020
From: aishan0403 at gmail.com (A S)
Date: Sun, 22 Mar 2020 07:47:38 -0700 (PDT)
Subject: How to copy paragraphs (with number formatting) and images from Words
 (.docx) and paste into Excel (.xlsx) using Python
Message-ID: 

I have contract clauses in Words (.docx) format that needs to be frequently copy and pasted into Excel (.xlsx) to be sent to the third party. The clauses are often updated hence there's always a need to copy and paste these clauses over. I only need to copy and paste all the paragraphs and images after the contents page. Here is a sample of the Clause document (https://drive.google.com/open?id=1ZzV29R6y2q0oU3HAVrqsFa158OhvpxEK).

I have tried doing up a code using Python to achieve this outcome. Here is the code that I have done so far:

!pip install python-docx
import docx
import xlsxwriter

document = docx.Document("Clauses Sample.docx")
wb = xlsxwriter.Workbook('C:/xxxx/xxxxxx/xxxx/clauses sample.xlsx')

docText = []
index_row = 0
Sheet1 = wb.add_worksheet("Sheetttt")

for paragraph in document.paragraphs:
    if paragraph.text:
        docText.append(paragraph.text)
        xx = '\n'.join(docText)

        Sheet1.write(index_row,0, xx)

        index_row = index_row+1

wb.close()        
#print(xx) 
However, my Excel file output looks like this:

I can't seem to paste pictures into this discussion so please see both my current and desired Excel output here:

https://stackoverflow.com/questions/60800494/how-to-copy-paragraphs-with-number-formatting-and-images-from-words-docx-an

From antoon.pardon at rece.vub.ac.be  Sun Mar 22 11:04:59 2020
From: antoon.pardon at rece.vub.ac.be (Antoon Pardon)
Date: Sun, 22 Mar 2020 16:04:59 +0100
Subject: How to incorporate environment from with python.
Message-ID: <370ce0ac-9aca-8b7e-3097-436a61ee928b@rece.vub.ac.be>

I think I can best explain what I want by showing two bash sessions:

Session 1)
----------

$ /opt/csw/bin/python
Python 2.6.4 (r264:75706, Sep  9 2015, 15:05:38) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named cx_Oracle
>>> ^D

===================================

Session 2)
----------
$ ORACLE_OWNER=...
$ LD_LIBRARY_PATH=...
$ ORACLE_SID=...
$ TNS_ADMIN=...
$ LD_RUN_PATH=...
$ ORA_NLS33=...

$ export export LDFLAGS ORACLE_OWNER LD_LIBRARY_PATH ORACLE_SID TNS_ADMIN LD_RUN_PATH ORA_NLS33

$ /opt/csw/bin/python
Python 2.6.7 (r267:88850, Feb 10 2012, 01:39:24) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>>

========================================================

As you can see the import works in the second session because I
had done the needed assignments and exports in bash.

Now I was wondering, if I could do those kind of preparations in python.
I would like to start python from an unprepared bash, and do the necessary
stuff to make the import work.

I already tried changing os.environ and using os.putenv, but that didn't
seem to work.

-- 
Antoon Pardon

From __peter__ at web.de  Sun Mar 22 12:22:54 2020
From: __peter__ at web.de (Peter Otten)
Date: Sun, 22 Mar 2020 17:22:54 +0100
Subject: How to incorporate environment from with python.
References: <370ce0ac-9aca-8b7e-3097-436a61ee928b@rece.vub.ac.be>
Message-ID: 

Antoon Pardon wrote:

> I think I can best explain what I want by showing two bash sessions:

> Python 2.6.4 (r264:75706, Sep  9 2015, 15:05:38) [C] on sunos5
> ImportError: No module named cx_Oracle

> Python 2.6.7 (r267:88850, Feb 10 2012, 01:39:24) [C] on sunos5
>>>> import cx_Oracle
>>>>

> As you can see the import works in the second session because I
> had done the needed assignments and exports in bash.

These seem to be different python interpreters. Maybe you just need to 
install cx_Oracle with the first one, or append the path containing 
cx_Oracle.so or whatever it's called to sys.path.



From PythonList at DancesWithMice.info  Sun Mar 22 12:24:32 2020
From: PythonList at DancesWithMice.info (DL Neil)
Date: Mon, 23 Mar 2020 05:24:32 +1300
Subject: How to incorporate environment from with python.
In-Reply-To: <370ce0ac-9aca-8b7e-3097-436a61ee928b@rece.vub.ac.be>
References: <370ce0ac-9aca-8b7e-3097-436a61ee928b@rece.vub.ac.be>
Message-ID: 


On 23/03/20 4:04 AM, Antoon Pardon wrote:
> I think I can best explain what I want by showing two bash sessions:
> 
> Session 1)
> ----------
> 
> $ /opt/csw/bin/python
> Python 2.6.4 (r264:75706, Sep  9 2015, 15:05:38) [C] on sunos5
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import cx_Oracle
> Traceback (most recent call last):
>    File "", line 1, in 
> ImportError: No module named cx_Oracle
>>>> ^D
> 
> ===================================
> 
> Session 2)
> ----------
> $ ORACLE_OWNER=...
> $ LD_LIBRARY_PATH=...
> $ ORACLE_SID=...
> $ TNS_ADMIN=...
> $ LD_RUN_PATH=...
> $ ORA_NLS33=...
> 
> $ export export LDFLAGS ORACLE_OWNER LD_LIBRARY_PATH ORACLE_SID TNS_ADMIN LD_RUN_PATH ORA_NLS33
> 
> $ /opt/csw/bin/python
> Python 2.6.7 (r267:88850, Feb 10 2012, 01:39:24) [C] on sunos5
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import cx_Oracle
>>>>
> 
> ========================================================
> 
> As you can see the import works in the second session because I
> had done the needed assignments and exports in bash.
> 
> Now I was wondering, if I could do those kind of preparations in python.
> I would like to start python from an unprepared bash, and do the necessary
> stuff to make the import work.
> 
> I already tried changing os.environ and using os.putenv, but that didn't
> seem to work.


It is possible to trap the import error using try...except.

The 'traditional' way to interrogate/modify the OS environment used 
https://docs.python.org/3/library/os.html#os.system

However, these days most prefer 
https://docs.python.org/3/library/subprocess.html

Please read the pros-and-cons carefully!
-- 
Regards =dn

From hjp-python at hjp.at  Sun Mar 22 12:44:53 2020
From: hjp-python at hjp.at (Peter J. Holzer)
Date: Sun, 22 Mar 2020 17:44:53 +0100
Subject: How to incorporate environment from with python.
In-Reply-To: <370ce0ac-9aca-8b7e-3097-436a61ee928b@rece.vub.ac.be>
References: <370ce0ac-9aca-8b7e-3097-436a61ee928b@rece.vub.ac.be>
Message-ID: <20200322164453.GA29555@hjp.at>

On 2020-03-22 16:04:59 +0100, Antoon Pardon wrote:
> $ /opt/csw/bin/python
> Python 2.6.4 (r264:75706, Sep  9 2015, 15:05:38) [C] on sunos5
> Type "help", "copyright", "credits" or "license" for more information.

Hmm. Solaris

> As you can see the import works in the second session because I
> had done the needed assignments and exports in bash.
> 
> Now I was wondering, if I could do those kind of preparations in python.
> I would like to start python from an unprepared bash, and do the necessary
> stuff to make the import work.
> 
> I already tried changing os.environ and using os.putenv, but that didn't
> seem to work.

I remember that once upon a time setting LD_LIBRARY_PATH had no effect
on the process itself (only on child processes) on 64 bit Linux, because
the runtime saved that value before loading the first shared library.
Maybe Solaris does the same?

In this case it might help to reexec the program. Something like

    if "ORACLE_HOME" not in os.environ:
        # Need to set env and reexec
        os.environ["ORACLE_HOME"] = ...
        os.environ["LD_LIBRARY_PATH"] = ...
        ...

        os.execv(sys.argv[0], sys.argv)

    # real content starts here

        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 barry at barrys-emacs.org  Sun Mar 22 12:48:18 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Sun, 22 Mar 2020 16:48:18 +0000
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <820c2408-172b-b056-2eae-4fabb3d355c6@chagford.com>
References: 
 
 <820c2408-172b-b056-2eae-4fabb3d355c6@chagford.com>
Message-ID: <21D0A17E-CAD7-469B-9680-36DDCEA7D087@barrys-emacs.org>



> On 22 Mar 2020, at 11:59, Frank Millman  wrote:
> 
> On 2020-03-22 1:01 PM, Chris Angelico wrote:
>> On Sun, Mar 22, 2020 at 12:45 AM Frank Millman  wrote:
>>> 
>>> Hi all
>>> 
>>> I have a strange intermittent bug.
>>> 
>>> The role-players -
>>>      asyncio on Python 3.8 running on Windows 10
>>>      Microsoft Edge running as a browser on the same machine
>>> 
>>> The bug does not occur with Python 3.7.
>>> It does not occur with Chrome or Firefox.
>>> It does not occur when MS Edge connects to another host on the network,
>>> running the same Python program (Python 3.8 on Fedora 31).
>> What exact version of Python 3.7 did you test? I'm looking through the
>> changes to asyncio and came across this one, which may have some
>> impact.
> 
> Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32

Can you confirm that you have implemented Connection: keep-alive?
This means that the browser can send a 2nd GET on the same connection.

Barry


> 
> Frank
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 


From barry at barrys-emacs.org  Sun Mar 22 12:52:09 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Sun, 22 Mar 2020 16:52:09 +0000
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 
Message-ID: 



> On 22 Mar 2020, at 09:41, Frank Millman  wrote:
> 
> On 2020-03-22 11:00 AM, Barry Scott wrote:
>>> On 22 Mar 2020, at 07:56, Frank Millman  wrote:
>>> 
>>> On 2020-03-21 8:04 PM, Barry Scott wrote:
>>>> I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers.
>>> 
>>> You are leading me into deep waters here :-)  I have never used Wireshark before. I have now downloaded it and am running it - it generates a *lot* of data, most of which I do not understand yet!
>> You can tell wireshark to only capture on one interface and to only capture packets for port 80.
>> (Captureing HTTPS means you cannot decode the packets without going deeper I recall)
>> Then you can tell wireshark to decode the captured data for http to drop a lot of the lower level details.
> 
> Thanks. I am more or less doing that. Interestingly the [RST,ACK] messages appear on the tcp packets, so if I filter on http I do not see them.
> 
>>> 
>>> One thing immediately stands out. When I run it with MS Edge and Python3.8, it shows a lot of lines highlighted in red, with the symbols [RST,ACK]. They do not appear when running Chrome, and they do not appear when running Python3.7.
>> As Chris said that should not happen.
> 
> As I replied to Chris, they appear in packets sent *from* Python *to* Edge.
> 
>>> 
>>> I have another data point. I tried putting an asyncio.sleep() after sending each file. A value of 0.01 made no difference, but a value of 0.1 makes the problem go away.
>> What is the async wait to wait for the transmit buffers to drain?
> 
> Not sure what you are asking. I am just doing what it says in the docs -
> 
> =================
> 
> write(data)
> The method attempts to write the data to the underlying socket immediately. If that fails, the data is queued in an internal write buffer until it can be sent.
> 
> The method should be used along with the drain() method:
> 
> stream.write(data)
> await stream.drain()
> 
> =================
> 
> coroutine drain()
> Wait until it is appropriate to resume writing to the stream. Example:
> 
> writer.write(data)
> await writer.drain()
> This is a flow control method that interacts with the underlying IO write buffer. When the size of the buffer reaches the high watermark, drain() blocks until the size of the buffer is drained down to the low watermark and writing can be resumed. When there is nothing to wait for, the drain() returns immediately.
> 
> =================

That you called drain() is what I was asking. I'm a Twisted user and have not used asyncio yet.

Barry

> 
> Frank
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 


From rosuav at gmail.com  Sun Mar 22 13:06:11 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Mon, 23 Mar 2020 04:06:11 +1100
Subject: How to incorporate environment from with python.
In-Reply-To: 
References: <370ce0ac-9aca-8b7e-3097-436a61ee928b@rece.vub.ac.be>
 
Message-ID: 

On Mon, Mar 23, 2020 at 3:24 AM Peter Otten <__peter__ at web.de> wrote:
>
> Antoon Pardon wrote:
>
> > I think I can best explain what I want by showing two bash sessions:
>
> > Python 2.6.4 (r264:75706, Sep  9 2015, 15:05:38) [C] on sunos5
> > ImportError: No module named cx_Oracle
>
> > Python 2.6.7 (r267:88850, Feb 10 2012, 01:39:24) [C] on sunos5
> >>>> import cx_Oracle
> >>>>
>
> > As you can see the import works in the second session because I
> > had done the needed assignments and exports in bash.
>
> These seem to be different python interpreters. Maybe you just need to
> install cx_Oracle with the first one, or append the path containing
> cx_Oracle.so or whatever it's called to sys.path.

I think everything else is irrelevant, and this is the only part that
matters. Why are there two distinct builds of Python 2.6, accessed via
the exact same path? What's going on here?

(Also, Python 2.6 is quite quite old by now. One of them was built in
2012 and hasn't been updated since. Any chance of installing something
newer?)

ChrisA

From countryone77 at gmail.com  Sun Mar 22 13:58:23 2020
From: countryone77 at gmail.com (Beverly Pope)
Date: Sun, 22 Mar 2020 12:58:23 -0500
Subject: How to copy paragraphs (with number formatting) and images from
 Words (.docx) and paste into Excel (.xlsx) using Python
In-Reply-To: 
References: 
Message-ID: <8B127F03-B6C2-4BE1-B068-5B89CF065F0E@gmail.com>



> On Mar 22, 2020, at 9:47 AM, A S  wrote:
> 
> I can't seem to paste pictures into this discussion so please see both my current and desired Excel output here:
> 
> https://stackoverflow.com/questions/60800494/how-to-copy-paragraphs-with-number-formatting-and-images-from-words-docx-an 
Did you try using the 2 part answer on the stackoverflow webpage?

Bev in TX

From rosuav at gmail.com  Sun Mar 22 15:00:41 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Mon, 23 Mar 2020 06:00:41 +1100
Subject: Confusing textwrap parameters, and request for RE help
Message-ID: 

When using textwrap.fill() or friends, setting break_long_words=False
without also setting break_on_hyphens=False has the very strange
behaviour that a long hyphenated word will still be wrapped. I
discovered this as a very surprising result when trying to wrap a
paragraph that contained a URL, and wanting the URL to be kept
unchanged:

import shutil, re, textwrap
w = textwrap.TextWrapper(width=shutil.get_terminal_size().columns,
    initial_indent=">>>> ", subsequent_indent="     ",
    break_long_words=False)
text = ("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
    "Praesent facilisis risus sed quam ultricies tempus. Vestibulum "
    "quis tincidunt turpis, id euismod turpis. Etiam pellentesque sem "
    "a magna laoreet sagittis. Proin id convallis odio, vel ornare "
    "ipsum. Vivamus tincidunt sodales orci. Proin egestas sollicitudin "
    "viverra. Etiam egestas, erat ac elementum tincidunt, risus nisl "
    "fermentum ex, ut iaculis lorem quam vel erat. Pellentesque "
    "condimentum ipsum varius ligula volutpat, sit amet pulvinar ipsum "
    "condimentum. Nulla ut orci et mi sollicitudin vehicula. In "
    "consectetur aliquet tortor, sed commodo orci porta malesuada. "
    "Nulla urna sapien, sollicitudin et nunc et, ultrices euismod "
    "lorem. Curabitur tempor est mauris, a ultricies urna mattis id. "
    "Nam efficitur turpis a sem tristique sagittis. "
    "https://example.com/long-url-goes-here/with-multiple-parts/wider-than-your-terminal/should-not-be-wrapped
"
    "more words go here")
print(w.fill(text))

Unless you also add break_on_hyphens, this will appear to ignore the
break_long_words setting. Logically, it would seem that
break_long_words=False should take precedence over break_on_hyphens -
if you're not allowed to break a long word, why break it at a hyphen?

Second point, and related to the above. The regex that defines break
points, as found in the source code, is:

wordsep_re = re.compile(r'''
        ( # any whitespace
          %(ws)s+
        | # em-dash between words
          (?<=%(wp)s) -{2,} (?=\w)
        | # word, possibly hyphenated
          %(nws)s+? (?:
            # hyphenated word
              -(?: (?<=%(lt)s{2}-) | (?<=%(lt)s-%(lt)s-))
              (?= %(lt)s -? %(lt)s)
            | # end of word
              (?=%(ws)s|\Z)
            | # em-dash
              (?<=%(wp)s) (?=-{2,}\w)
            )
        )''' % {'wp': word_punct, 'lt': letter,
                'ws': whitespace, 'nws': nowhitespace},

It's built primarily out of small matches with long assertions, eg
"match a hyphen, as long as it's preceded by two letters or a letter
and a hyphen". What I want to do is create a *negative* assertion:
specifically, to disallow any breaking between "\b[a-z]+://" and "\b",
which will mean that a URL will never be broken ("https://.........."
until the next whitespace boundary). Regex assertions of this form
have to be fixed lengths, though, so as described, this isn't
possible. Regexperts, any ideas? How can I modify this to never break
inside a URL?

Ultimately it would be great to have a break_urls parameter
(defaulting to True, and if False, will change the RE as described),
but since I can just patch in a different RE, that would work for
current Pythons.

I'd prefer to still be able to break words on hyphens while keeping
URLs intact, but if it's not possible, I'll just deny all hyphen
breaking. Seems unnecessary though.

ChrisA

From bobimapexa at gmail.com  Sun Mar 22 16:42:27 2020
From: bobimapexa at gmail.com (bobimapexa at gmail.com)
Date: Sun, 22 Mar 2020 13:42:27 -0700 (PDT)
Subject: php to python code converter
In-Reply-To: 
References: 
Message-ID: <3ea63a62-03dc-48ff-b240-61b2b8b22acf@googlegroups.com>

On Friday, May 8, 2009 at 1:38:25 PM UTC+3, bvidinli wrote:
> if anybody needs:
> http://code.google.com/p/phppython/

hi

From p_s_d_a_s_i_l_v_a_ns at netcabo.pt  Sun Mar 22 22:18:30 2020
From: p_s_d_a_s_i_l_v_a_ns at netcabo.pt (Paulo da Silva)
Date: Mon, 23 Mar 2020 02:18:30 +0000
Subject: Like c enumeration in python3
Message-ID: 

Hi!

Suppose a class C.
I want something like this:

class C:
	KA=0
	KB=1
	KC=1
	...
	Kn=n

	def __init__ ...
		...


These constants come from an enum in a .h (header of C file).
They are many and may change from time to time.
Is there a way to somehow define them from inside __init__ giving for
example a list of names as strings?
There is an additional problem: C is not recognized inside __init__!

Thanks.

From p_s_d_a_s_i_l_v_a_ns at netcabo.pt  Sun Mar 22 22:32:35 2020
From: p_s_d_a_s_i_l_v_a_ns at netcabo.pt (Paulo da Silva)
Date: Mon, 23 Mar 2020 02:32:35 +0000
Subject: Like c enumeration in python3 [ERRATA]
References: 
Message-ID: 

?s 02:18 de 23/03/20, Paulo da Silva escreveu:
> Hi!
> 
> Suppose a class C.
> I want something like this:
> 
> class C:
> 	KA=0
> 	KB=1
	KC=2
> 	...
> 	Kn=n
> 
> 	def __init__ ...
> 		...
> 
> 
> These constants come from an enum in a .h (header of C file).
> They are many and may change from time to time.
> Is there a way to somehow define them from inside __init__ giving for
> example a list of names as strings?
> There is an additional problem: C is not recognized inside __init__!
Of course I'm talking about C class name, not C language.
> 
> Thanks.
> 


From PythonList at DancesWithMice.info  Sun Mar 22 23:37:52 2020
From: PythonList at DancesWithMice.info (DL Neil)
Date: Mon, 23 Mar 2020 16:37:52 +1300
Subject: Like c enumeration in python3 [ERRATA]
In-Reply-To: 
References:  
Message-ID: <0e9c471d-62c8-e07a-719b-6c22b0b76bf1@DancesWithMice.info>

On 23/03/20 3:32 PM, Paulo da Silva wrote:
> ?s 02:18 de 23/03/20, Paulo da Silva escreveu:
>> Hi!

Ol?,


>> Suppose a class C.
>> I want something like this:
>>
>> class C:
>> 	KA=0
>> 	KB=1
> 	KC=2
>> 	...
>> 	Kn=n
>>
>> 	def __init__ ...
>> 		...
>>
>>
>> These constants come from an enum in a .h (header of C file).
>> They are many and may change from time to time.
>> Is there a way to somehow define them from inside __init__ giving for
>> example a list of names as strings?
>> There is an additional problem: C is not recognized inside __init__!


Please read the PSL docs carefully, because Python's enums seem to 
differ from those in other languages - sometimes in significant ways, 
and sometimes in a subtle manner!


I have been asking similar questions recently - particularly wanting to 
(also) use the "strings", because of the effort of upgrading many 
modules of code at the same time (the manual, or was it the PEP(?) 
refers to the need to upgrade the PSL to use enums, and to the effort 
that might cost - I suggest there has been little/v.slow take-up, but 
then keeping the PSL updated is a subject of a great many conversations, 
elsewhere).

Python's enums cannot be changed. Once set, C.KA cannot be changed to 1 
(for example). We may not add element Km (where m>n) at some later 
occasion after class definition-time (in fact the __new__() constructor 
is 're-wired' in order to prohibit its use post-definition). It is not 
permitted to sub-class an existing enum class, eg C(), perhaps to 
enlarge it with more members, if the 'super class' contains "members".

There is usually no need for an __init__. Plus, I've had a distinct lack 
of satisfaction playing with that - but YMMV!

Sub-classing, and even attempting to use the meta-class seems to be a 
major challenge (see StackOverflow).

It is possible to list the elements using the built-in iterator:

	for c in C: print( c )

or iterator-conversion:

	list( C )

and/or accessing the class's 'data-dict' directly:

	for name, value in C.__members__.items():
-- 
Regards =dn

From aishan0403 at gmail.com  Mon Mar 23 00:12:59 2020
From: aishan0403 at gmail.com (A S)
Date: Sun, 22 Mar 2020 21:12:59 -0700 (PDT)
Subject: How to copy paragraphs (with number formatting) and images from
 Words (.docx) and paste into Excel (.xlsx) using Python
In-Reply-To: 
References: 
 <8B127F03-B6C2-4BE1-B068-5B89CF065F0E@gmail.com>
 
Message-ID: <88ea4f75-ab5f-4f68-8425-19855b4f148e@googlegroups.com>

On Monday, 23 March 2020 01:58:38 UTC+8, Beverly Pope  wrote:
> > On Mar 22, 2020, at 9:47 AM, A S  wrote:
> > 
> > I can't seem to paste pictures into this discussion so please see both my current and desired Excel output here:
> > 
> > https://stackoverflow.com/questions/60800494/how-to-copy-paragraphs-with-number-formatting-and-images-from-words-docx-an 
> Did you try using the 2 part answer on the stackoverflow webpage?
> 
> Bev in TX

I'm able to get the paragraphs copied correctly now! But i'm trying to figure out if there's a way to copy and paste the images into the Excel, along with the paragraphs as well. Do you have an idea? :)

From adam.preble at gmail.com  Mon Mar 23 02:40:37 2020
From: adam.preble at gmail.com (Adam Preble)
Date: Sun, 22 Mar 2020 23:40:37 -0700 (PDT)
Subject: How does the super type present itself and do lookups?
In-Reply-To: 
References: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com>
 
 
 
 
Message-ID: <367c16f0-eea4-42a1-b869-164b40a64c0d@googlegroups.com>

On Thursday, March 19, 2020 at 5:02:46 PM UTC-5, Greg Ewing wrote:
> On 11/03/20 7:02 am, Adam Preble wrote:
> > Is this foo attribute being looked up in an override of __getattr__, __getattribute__, or is it a reserved slot that's internally doing this? That's what I'm trying to figure out.
> 
> Looking at the source in Objects/typeobject.c, it uses the
> tp_getattro type slot, which corresponds to __getattribute__.

Thanks for taking the time to look this up for me. I saw the message soon after you originally posted it, but it took me this long to sit down and poke at everything some more.

I don't doubt what you got from the source, but I am trying to figure out how I could have inferred that from the code I was trying. It looks like child_instance.__getattribute__ == child_instance.super().__getattribute__. They print out with the same address and pass an equality comparison. That implies that they are the same, and that the super type is NOT doing something special with that slot.

Given that super().__getattribute__ internally ultimately should be something else, I am guessing there is something else at play causing an indirection.

I have two reasons to be interested in this:
1. There may be obscure behavior I should worry about in general if I'm trying to default to mimicking Python and the data model for my own stuff.
2. I need to improve my kung fu when I'm inspecting these objects so I don't get hung up on stuff like this in the future.

The bright side is having a custom get attribute implementation is pretty much correct, although mine would have c.__getattribute != c.super().__getattribute__.

From __peter__ at web.de  Mon Mar 23 04:24:47 2020
From: __peter__ at web.de (Peter Otten)
Date: Mon, 23 Mar 2020 09:24:47 +0100
Subject: Like c enumeration in python3 [ERRATA]
References:  
Message-ID: 

Paulo da Silva wrote:

> ?s 02:18 de 23/03/20, Paulo da Silva escreveu:
>> Hi!
>> 
>> Suppose a class C.
>> I want something like this:
>> 
>> class C:
>> KA=0
>> KB=1
> KC=2
>> ...
>> Kn=n
>> 
>> def __init__ ...
>> ...
>> 
>> 
>> These constants come from an enum in a .h (header of C file).
>> They are many and may change from time to time.
>> Is there a way to somehow define them from inside __init__ giving for
>> example a list of names as strings?
>> There is an additional problem: C is not recognized inside __init__!
> Of course I'm talking about C class name, not C language.

Use enum:

>>> import enum
>>> C = enum.IntEnum("C", ["KA", "KB", "KC"], start=0)
>>> C.KB

>>> C.KB == 1
True

https://docs.python.org/3/library/enum.html#functional-api


From frank at chagford.com  Mon Mar 23 05:02:02 2020
From: frank at chagford.com (Frank Millman)
Date: Mon, 23 Mar 2020 11:02:02 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
Message-ID: 

On 2020-03-22 12:11 PM, Chris Angelico wrote:
> On Sun, Mar 22, 2020 at 8:30 PM Frank Millman  wrote:
>>
>> On 2020-03-22 10:45 AM, Chris Angelico wrote:
> 
> If you can recreate the problem with a single socket and multiple
> requests, that would be extremely helpful. I also think it's highly
> likely that this is the case.
> 

I am working on a stripped-down version, but I realise there are a few 
things I have not grasped.

Hope you don't mind, but can you scan through what follows and tell me 
if I am on the right lines?

Both the client and the server can send a header with 'Keep-alive', but 
what does it actually mean?

If the client sends it, does that mean that it wants the server to keep 
the connection open, and only close it when the client closes it from 
the other end?

Conversely, if the server sends it, does it mean that it wants the 
client to keep the connection open? If so, under what condition would 
the server close the connection (other than a timeout). Should the 
server only send 'Keep-alive' if it receives 'Keep-alive'?

In my program, when I send a file in response to a GET, I send a header 
with 'Keep-alive', then I send the file, then I close the connection. 
This now seems wrong. It could even be the cause of my bug, but then why 
has it only appeared now? Both Edge and Chrome send 'Keep-alive' headers.

If I am thinking along the right lines, then the exchange should go like 
this -

Client sends request, with 'Keep-alive' header.

Server sends response, but does not close the connection. The server 
should reply with a 'Keep-alive' header. If it does not, the client will 
close the connection, in which case the server will also close.

Assuming that they both send 'Keep-alive', the onus is on the client to 
close the connection when it has no more requests. The server should 
have a timeout in case the client goes away.

Assuming that the above is correct, the client will rely on 
'Content-length' to determine when it has received the entire request. 
If the client has more than one request, it will send the first, wait 
for the response, when fully received as per the 'Content-length' it 
will send the next one, until all requests have been sent and all 
responses received, at which point it will close the connection.

All this assumes only one connection. Alternatively the client could 
open multiple connections for the requests. In that case it would make 
sense to use 'Connection: Close', so that the server can close the 
connection straight away, making it available for reuse.

If this all makes sense, I should write two versions of the client 
program, one using a single connection, and one using a pool of connections.

All comments appreciated!

Frank


From frank at chagford.com  Mon Mar 23 05:02:02 2020
From: frank at chagford.com (Frank Millman)
Date: Mon, 23 Mar 2020 11:02:02 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
Message-ID: 

On 2020-03-22 12:11 PM, Chris Angelico wrote:
> On Sun, Mar 22, 2020 at 8:30 PM Frank Millman  wrote:
>>
>> On 2020-03-22 10:45 AM, Chris Angelico wrote:
> 
> If you can recreate the problem with a single socket and multiple
> requests, that would be extremely helpful. I also think it's highly
> likely that this is the case.
> 

I am working on a stripped-down version, but I realise there are a few 
things I have not grasped.

Hope you don't mind, but can you scan through what follows and tell me 
if I am on the right lines?

Both the client and the server can send a header with 'Keep-alive', but 
what does it actually mean?

If the client sends it, does that mean that it wants the server to keep 
the connection open, and only close it when the client closes it from 
the other end?

Conversely, if the server sends it, does it mean that it wants the 
client to keep the connection open? If so, under what condition would 
the server close the connection (other than a timeout). Should the 
server only send 'Keep-alive' if it receives 'Keep-alive'?

In my program, when I send a file in response to a GET, I send a header 
with 'Keep-alive', then I send the file, then I close the connection. 
This now seems wrong. It could even be the cause of my bug, but then why 
has it only appeared now? Both Edge and Chrome send 'Keep-alive' headers.

If I am thinking along the right lines, then the exchange should go like 
this -

Client sends request, with 'Keep-alive' header.

Server sends response, but does not close the connection. The server 
should reply with a 'Keep-alive' header. If it does not, the client will 
close the connection, in which case the server will also close.

Assuming that they both send 'Keep-alive', the onus is on the client to 
close the connection when it has no more requests. The server should 
have a timeout in case the client goes away.

Assuming that the above is correct, the client will rely on 
'Content-length' to determine when it has received the entire request. 
If the client has more than one request, it will send the first, wait 
for the response, when fully received as per the 'Content-length' it 
will send the next one, until all requests have been sent and all 
responses received, at which point it will close the connection.

All this assumes only one connection. Alternatively the client could 
open multiple connections for the requests. In that case it would make 
sense to use 'Connection: Close', so that the server can close the 
connection straight away, making it available for reuse.

If this all makes sense, I should write two versions of the client 
program, one using a single connection, and one using a pool of connections.

All comments appreciated!

Frank

From rosuav at gmail.com  Mon Mar 23 06:57:40 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Mon, 23 Mar 2020 21:57:40 +1100
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
Message-ID: 

On Mon, Mar 23, 2020 at 8:03 PM Frank Millman  wrote:
>
> On 2020-03-22 12:11 PM, Chris Angelico wrote:
> > On Sun, Mar 22, 2020 at 8:30 PM Frank Millman  wrote:
> >>
> >> On 2020-03-22 10:45 AM, Chris Angelico wrote:
> >
> > If you can recreate the problem with a single socket and multiple
> > requests, that would be extremely helpful. I also think it's highly
> > likely that this is the case.
> >
>
> I am working on a stripped-down version, but I realise there are a few
> things I have not grasped.
>
> Hope you don't mind, but can you scan through what follows and tell me
> if I am on the right lines?

No probs!

> Both the client and the server can send a header with 'Keep-alive', but
> what does it actually mean?
>
> If the client sends it, does that mean that it wants the server to keep
> the connection open, and only close it when the client closes it from
> the other end?
>
> Conversely, if the server sends it, does it mean that it wants the
> client to keep the connection open? If so, under what condition would
> the server close the connection (other than a timeout). Should the
> server only send 'Keep-alive' if it receives 'Keep-alive'?

I'm pretty sure the server should never say "keep-alive" if the client
said "close". (There's a bit of an oddity in that the default changed
between, I think, HTTP 1.0 and 1.1. But that's a minor discrepancy.)
Generally, you'll see one of these options:

1) Client says "Connection: close". This means "I'm only gonna be
doing this one request, then we're done". Good for non-browser usage,
automated scripts etc.

2) Client says "Keep-Alive", server says "Close". This means the
client would be okay with connection reuse, but the server's saying no
(maybe it doesn't support it, or maybe it's in a soft shutdown state
where it wants to end connections, or whatever). After the current
request, the connection will be closed.

3) Both ends say "Connection: Keep-Alive". After the request, the
socket isn't closed, and can be reused for some other request.

I'm not sure how a client would (or should) handle it if the server
says "Connection: Keep-Alive" after the client said "Connection:
Close". Probably the client would just close its end of the socket and
that'd be that.

> In my program, when I send a file in response to a GET, I send a header
> with 'Keep-alive', then I send the file, then I close the connection.
> This now seems wrong. It could even be the cause of my bug, but then why
> has it only appeared now? Both Edge and Chrome send 'Keep-alive' headers.
>

It mightn't be fundamentally WRONG (there needs to be *some* way to
signal that you're now done), but it would probably be suboptimal. If
you're always going to close the connection after one request, just
send Connection: Close.

> If I am thinking along the right lines, then the exchange should go like
> this -
>
> Client sends request, with 'Keep-alive' header.
>
> Server sends response, but does not close the connection. The server
> should reply with a 'Keep-alive' header. If it does not, the client will
> close the connection, in which case the server will also close.
>
> Assuming that they both send 'Keep-alive', the onus is on the client to
> close the connection when it has no more requests. The server should
> have a timeout in case the client goes away.

I think either end is allowed to close the connection.

> Assuming that the above is correct, the client will rely on
> 'Content-length' to determine when it has received the entire request.
> If the client has more than one request, it will send the first, wait
> for the response, when fully received as per the 'Content-length' it
> will send the next one, until all requests have been sent and all
> responses received, at which point it will close the connection.

Yep. Which makes things very interesting (for serene values of
"interesting", such as "we're all gonna die") when you want to use
connection pooling with something that fundamentally doesn't have a
length, such as a chunked transfer. Which you are doing. That may or
may not actually be significant.

> All this assumes only one connection. Alternatively the client could
> open multiple connections for the requests. In that case it would make
> sense to use 'Connection: Close', so that the server can close the
> connection straight away, making it available for reuse.

What you'll often see is that the client has some sort of connection
limit, and reuses those same connections. For instance, it might have
a maximum of four connections per server (where "server" has to
include the name as well as its IP and port, due to TLS SNI), so it
requests an HTML page on one connection (with keep-alive), parses
that, and then fires off one request on the reused connection and
three others on new connections. As those requests complete, it sends
new requests on the same sockets.

> If this all makes sense, I should write two versions of the client
> program, one using a single connection, and one using a pool of connections.
>

Possibly! I think you'll most likely see that one of those behaves
perfectly normally, and you only trigger the issue in the other. So
you could move forward with just one test program.

ChrisA

From skip.montanaro at gmail.com  Mon Mar 23 07:49:39 2020
From: skip.montanaro at gmail.com (Skip Montanaro)
Date: Mon, 23 Mar 2020 04:49:39 -0700
Subject: Like c enumeration in python3
In-Reply-To: 
References: 
Message-ID: 

Does the enum module help?

https://docs.python.org/3/library/enum.html

Note that within __init__ you can reference your enumerated constants
using (for example) self.KA.

Skip

From rhodri at kynesim.co.uk  Mon Mar 23 07:52:05 2020
From: rhodri at kynesim.co.uk (Rhodri James)
Date: Mon, 23 Mar 2020 11:52:05 +0000
Subject: Like c enumeration in python3
In-Reply-To: 
References: 
Message-ID: 

On 23/03/2020 02:18, Paulo da Silva wrote:
> Hi!
> 
> Suppose a class C.
> I want something like this:
> 
> class C:
> 	KA=0
> 	KB=1
> 	KC=1
> 	...
> 	Kn=n
> 
> 	def __init__ ...
> 		...
> 
> 
> These constants come from an enum in a .h (header of C file).
> They are many and may change from time to time.
> Is there a way to somehow define them from inside __init__ giving for
> example a list of names as strings?

It sounds like what you want is a separate script to process your .h 
file into a Python module containing an enum, then import that module 
into your program.

-- 
Rhodri James *-* Kynesim Ltd

From frank at chagford.com  Mon Mar 23 07:56:22 2020
From: frank at chagford.com (Frank Millman)
Date: Mon, 23 Mar 2020 13:56:22 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
Message-ID: <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>

On 2020-03-23 12:57 PM, Chris Angelico wrote:
> On Mon, Mar 23, 2020 at 8:03 PM Frank Millman  wrote:
>>
>> On 2020-03-22 12:11 PM, Chris Angelico wrote:
>>> On Sun, Mar 22, 2020 at 8:30 PM Frank Millman  wrote:
>>>>
>>>> On 2020-03-22 10:45 AM, Chris Angelico wrote:
>>>
>>> If you can recreate the problem with a single socket and multiple
>>> requests, that would be extremely helpful. I also think it's highly
>>> likely that this is the case.
>>>
>>
>> I am working on a stripped-down version, but I realise there are a few
>> things I have not grasped.
>>
>> Hope you don't mind, but can you scan through what follows and tell me
>> if I am on the right lines?
> 
> No probs!
> 

[...]

Really appreciate the one-on-one tuition. I am learning a lot!

> 
>> If this all makes sense, I should write two versions of the client
>> program, one using a single connection, and one using a pool of connections.
>>
> 
> Possibly! I think you'll most likely see that one of those behaves
> perfectly normally, and you only trigger the issue in the other. So
> you could move forward with just one test program.
> 

Well, I have got the first one working - single connection - and so far 
it has not gone wrong.

However, it is difficult to be sure that I am comparing apples with 
apples. I have written my test server to handle 'Keep-Alive' correctly, 
but as I mentioned earlier, my live program closes the connection after 
each transfer. So now I have to make my test server do the same, and 
change my test client to react to that and re-open the connection each 
time. I will make the changes and see how that behaves.

Of course now I am in the murky waters of trying to second-guess how 
Edge reacts to that. Presumably that is where Wireshark will be useful. 
I will keep you posted.

Frank


From frank at chagford.com  Mon Mar 23 07:56:22 2020
From: frank at chagford.com (Frank Millman)
Date: Mon, 23 Mar 2020 13:56:22 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
Message-ID: <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>

On 2020-03-23 12:57 PM, Chris Angelico wrote:
> On Mon, Mar 23, 2020 at 8:03 PM Frank Millman  wrote:
>>
>> On 2020-03-22 12:11 PM, Chris Angelico wrote:
>>> On Sun, Mar 22, 2020 at 8:30 PM Frank Millman  wrote:
>>>>
>>>> On 2020-03-22 10:45 AM, Chris Angelico wrote:
>>>
>>> If you can recreate the problem with a single socket and multiple
>>> requests, that would be extremely helpful. I also think it's highly
>>> likely that this is the case.
>>>
>>
>> I am working on a stripped-down version, but I realise there are a few
>> things I have not grasped.
>>
>> Hope you don't mind, but can you scan through what follows and tell me
>> if I am on the right lines?
> 
> No probs!
> 

[...]

Really appreciate the one-on-one tuition. I am learning a lot!

> 
>> If this all makes sense, I should write two versions of the client
>> program, one using a single connection, and one using a pool of connections.
>>
> 
> Possibly! I think you'll most likely see that one of those behaves
> perfectly normally, and you only trigger the issue in the other. So
> you could move forward with just one test program.
> 

Well, I have got the first one working - single connection - and so far 
it has not gone wrong.

However, it is difficult to be sure that I am comparing apples with 
apples. I have written my test server to handle 'Keep-Alive' correctly, 
but as I mentioned earlier, my live program closes the connection after 
each transfer. So now I have to make my test server do the same, and 
change my test client to react to that and re-open the connection each 
time. I will make the changes and see how that behaves.

Of course now I am in the murky waters of trying to second-guess how 
Edge reacts to that. Presumably that is where Wireshark will be useful. 
I will keep you posted.

Frank

From barry at barrys-emacs.org  Mon Mar 23 08:05:32 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Mon, 23 Mar 2020 12:05:32 +0000
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
Message-ID: <1189D143-545C-47D2-8233-19DF2E35A58C@barrys-emacs.org>



> On 23 Mar 2020, at 09:02, Frank Millman  wrote:
> 
> On 2020-03-22 12:11 PM, Chris Angelico wrote:
>> On Sun, Mar 22, 2020 at 8:30 PM Frank Millman  wrote:
>>> 
>>> On 2020-03-22 10:45 AM, Chris Angelico wrote:
>> If you can recreate the problem with a single socket and multiple
>> requests, that would be extremely helpful. I also think it's highly
>> likely that this is the case.
> 
> I am working on a stripped-down version, but I realise there are a few things I have not grasped.
> 
> Hope you don't mind, but can you scan through what follows and tell me if I am on the right lines?
> 
> Both the client and the server can send a header with 'Keep-alive', but what does it actually mean?
> 
> If the client sends it, does that mean that it wants the server to keep the connection open, and only close it when the client closes it from the other end?
> 
> Conversely, if the server sends it, does it mean that it wants the client to keep the connection open? If so, under what condition would the server close the connection (other than a timeout). Should the server only send 'Keep-alive' if it receives 'Keep-alive'?

See https://tools.ietf.org/html/rfc2616  secton 14.10 for the details.

When the browser sends "Connection: keep-alive" it mean that the browser wishes to have
a persistent connection. The server is free to choose.

If the server replies with "Connection: close" the connection is not persistent and will
be closed after the response.

If the server replies with "Connection: keep-aiive" then connect is persistent that means that
after this response the server will allow another transaction, GET, POST etc.

Note: You need to know if the client is using HTTP/1.0 or HTTP/1.1 protocol the rules are different in
each version.

> 
> In my program, when I send a file in response to a GET, I send a header with 'Keep-alive', then I send the file, then I close the connection. This now seems wrong. It could even be the cause of my bug, but then why has it only appeared now? Both Edge and Chrome send 'Keep-alive' headers.

Its a protocol violation. In your case you must send "Connection: close". Fix that and I think your code is likely to work.

If you care about performance add the extra code to handle persistent connections. Its speeds up the browsers
and should reduce the impact on the server as well.


> If I am thinking along the right lines, then the exchange should go like this -
> 
> Client sends request, with 'Keep-alive' header.
> 
> Server sends response, but does not close the connection. The server should reply with a 'Keep-alive' header. If it does not, the client will close the connection, in which case the server will also close.

You must include a "Connection:" head for HTTP/1.1 I believe.

> 
> Assuming that they both send 'Keep-alive', the onus is on the client to close the connection when it has no more requests.

Yes.

> The server should have a timeout in case the client goes away.

Yes to stop resources running out.

> 
> Assuming that the above is correct, the client will rely on 'Content-length' to determine when it has received the entire request. If the client has more than one request, it will send the first, wait for the response, when fully received as per the 'Content-length' it will send the next one, until all requests have been sent and all responses received, at which point it will close the connection.

You can use "Content-Length" header or chunked encoding.

> 
> All this assumes only one connection. Alternatively the client could open multiple connections for the requests. In that case it would make sense to use 'Connection: Close', so that the server can close the connection straight away, making it available for reuse.

Modern browsers open many persistent connection. I recall its 8/site in the case of chrome.


> 
> If this all makes sense, I should write two versions of the client program, one using a single connection, and one using a pool of connections.

Is this for a test program?

You can use curl for the single connection case.


> 
> All comments appreciated!
> 
> Frank

Barry

> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 


From barry at barrys-emacs.org  Mon Mar 23 08:12:33 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Mon, 23 Mar 2020 12:12:33 +0000
Subject: Like c enumeration in python3
In-Reply-To: 
References: 
 
Message-ID: 



> On 23 Mar 2020, at 11:52, Rhodri James  wrote:
> 
> On 23/03/2020 02:18, Paulo da Silva wrote:
>> Hi!
>> Suppose a class C.
>> I want something like this:
>> class C:
>> 	KA=0
>> 	KB=1
>> 	KC=1
>> 	...
>> 	Kn=n
>> 	def __init__ ...
>> 		...
>> These constants come from an enum in a .h (header of C file).
>> They are many and may change from time to time.
>> Is there a way to somehow define them from inside __init__ giving for
>> example a list of names as strings?
> 
> It sounds like what you want is a separate script to process your .h file into a Python module containing an enum, then import that module into your program.

web search for "python parse C header" yields some interesting results.

Barry


> 
> -- 
> Rhodri James *-* Kynesim Ltd
> -- 
> https://mail.python.org/mailman/listinfo/python-list 

From rosuav at gmail.com  Mon Mar 23 08:16:59 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Mon, 23 Mar 2020 23:16:59 +1100
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
 <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
Message-ID: 

On Mon, Mar 23, 2020 at 10:58 PM Frank Millman  wrote:
>
> On 2020-03-23 12:57 PM, Chris Angelico wrote:
> > On Mon, Mar 23, 2020 at 8:03 PM Frank Millman  wrote:
> >>
> >> On 2020-03-22 12:11 PM, Chris Angelico wrote:
> >>> On Sun, Mar 22, 2020 at 8:30 PM Frank Millman  wrote:
> >>>>
> >>>> On 2020-03-22 10:45 AM, Chris Angelico wrote:
> >>>
> >>> If you can recreate the problem with a single socket and multiple
> >>> requests, that would be extremely helpful. I also think it's highly
> >>> likely that this is the case.
> >>>
> >>
> >> I am working on a stripped-down version, but I realise there are a few
> >> things I have not grasped.
> >>
> >> Hope you don't mind, but can you scan through what follows and tell me
> >> if I am on the right lines?
> >
> > No probs!
> >
>
> [...]
>
> Really appreciate the one-on-one tuition. I am learning a lot!

Heh, I'm always happy to help people who are willing to learn. Also,
you've brought an interesting problem to the table. :)

> Of course now I am in the murky waters of trying to second-guess how
> Edge reacts to that. Presumably that is where Wireshark will be useful.
> I will keep you posted.
>

Yep, it's going to be a matter of monitoring the exact headers sent
each direction.

ChrisA

From tjreedy at udel.edu  Mon Mar 23 01:13:46 2020
From: tjreedy at udel.edu (Terry Reedy)
Date: Mon, 23 Mar 2020 01:13:46 -0400
Subject: Like c enumeration in python3 [ERRATA]
In-Reply-To: <0e9c471d-62c8-e07a-719b-6c22b0b76bf1@DancesWithMice.info>
References:  
 <0e9c471d-62c8-e07a-719b-6c22b0b76bf1@DancesWithMice.info>
Message-ID: 

On 3/22/2020 11:37 PM, DL Neil via Python-list wrote:
> On 23/03/20 3:32 PM, Paulo da Silva wrote:
>> ?s 02:18 de 23/03/20, Paulo da Silva escreveu:
>>> Hi!
> 
> Ol?,
> 
> 
>>> Suppose a class C.
>>> I want something like this:
>>>
>>> class C:
>>> ????KA=0
>>> ????KB=1
>> ????KC=2
>>> ????...
>>> ????Kn=n
>>>
>>> ????def __init__ ...
>>> ??????? ...
>>>
>>>
>>> These constants come from an enum in a .h (header of C file).
>>> They are many and may change from time to time.
>>> Is there a way to somehow define them from inside __init__ giving for
>>> example a list of names as strings?
>>> There is an additional problem: C is not recognized inside __init__!
> 
> 
> Please read the PSL docs carefully, because Python's enums seem to 
> differ from those in other languages - sometimes in significant ways, 
> and sometimes in a subtle manner!
> 
> 
> I have been asking similar questions recently - particularly wanting to 
> (also) use the "strings", because of the effort of upgrading many 
> modules of code at the same time (the manual, or was it the PEP(?) 
> refers to the need to upgrade the PSL to use enums, and to the effort 
> that might cost - I suggest there has been little/v.slow take-up, but 
> then keeping the PSL updated is a subject of a great many conversations, 
> elsewhere).
> 
> Python's enums cannot be changed. Once set, C.KA cannot be changed to 1 

I am not sure what you are saying.  The OP's class is not an enum in the 
enum module sense.  Class attributues are usually mutable.

 >>> class C:
	K = 0

	
 >>> C.K = 1
 >>> C.K
1


-- 
Terry Jan Reedy



From dieter at handshake.de  Mon Mar 23 13:35:56 2020
From: dieter at handshake.de (Dieter Maurer)
Date: Mon, 23 Mar 2020 18:35:56 +0100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
Message-ID: <24184.62332.590572.911198@ixdm.fritz.box>

Chris Angelico wrote at 2020-3-23 06:00 +1100:
>When using textwrap.fill() or friends, setting break_long_words=False
>without also setting break_on_hyphens=False has the very strange
>behaviour that a long hyphenated word will still be wrapped.

Having worked with `TeX`, I am familiar that hyphens indicate
word locations favorable to line breaks. Therefore, I understand
that one wants a way to control whether or not breaks are allowed
at hyphens, even if words should not be broken normally.

Apparently, "break_on_hyphens" adds hyphen as a word delimiter.
With this notion, the behavior can be understood.

From p_s_d_a_s_i_l_v_a_ns at netcabo.pt  Mon Mar 23 14:33:45 2020
From: p_s_d_a_s_i_l_v_a_ns at netcabo.pt (Paulo da Silva)
Date: Mon, 23 Mar 2020 18:33:45 +0000
Subject: Like c enumeration in python3
References: 
Message-ID: 

Thank you very much for all your responses!
Now I have too much ideas :-)
I'm saving your answers and I'll see what is more
appropriate/comfortable in my case.

Best regards.
Paulo

From countryone77 at gmail.com  Mon Mar 23 14:43:46 2020
From: countryone77 at gmail.com (Beverly Pope)
Date: Mon, 23 Mar 2020 13:43:46 -0500
Subject: How to copy paragraphs (with number formatting) and images from
 Words (.docx) and paste into Excel (.xlsx) using Python
In-Reply-To: <88ea4f75-ab5f-4f68-8425-19855b4f148e@googlegroups.com>
References: 
 <8B127F03-B6C2-4BE1-B068-5B89CF065F0E@gmail.com>
 
 <88ea4f75-ab5f-4f68-8425-19855b4f148e@googlegroups.com>
Message-ID: <2AA2D35A-8EE9-4273-86A3-C22AA017CFD5@gmail.com>

On Mar 22, 2020, at 11:12 PM, A S  wrote:
> 
> On Monday, 23 March 2020 01:58:38 UTC+8, Beverly Pope  wrote:
>>> On Mar 22, 2020, at 9:47 AM, A S > wrote:
>>> 
>>> I can't seem to paste pictures into this discussion so please see both my current and desired Excel output here:
>>> 
>>> https://stackoverflow.com/questions/60800494/how-to-copy-paragraphs-with-number-formatting-and-images-from-words-docx-an >
>> Did you try using the 2 part answer on the stackoverflow webpage?
>> 
>> Bev in TX
> 
> I'm able to get the paragraphs copied correctly now! But i'm trying to figure out if there's a way to copy and paste the images into the Excel, along with the paragraphs as well. Do you have an idea? :)

I?m glad to hear that solution worked for you.  With that said, I only went to stackoverflow out of curiosity and happened ro see the posted solution. I probably know less about using Python to copy data from Word to Excel than you do, given that yesterday was the first time that I had heard about it.  

I did read that MS docx files are zip files, which can be unzipped in Python.
https://gist.github.com/another-junior-dev/990a4e622868627cb93be3d8fa2eff04 
That could provide access to the pictures contained in the document, but it doesn?t explain how to determine where you want to place the pictures with relation to text in your Excel spreadsheet.  If you could determine that, then you could use XlsxWriter module?s worksheet.insert_image() to insert the image.  See n?the Worksheet Class? in the XlsxWriter docs:
https://xlsxwriter.readthedocs.io 
The rest is beyond the realm of my knowledge.

If it were me, I would go back to stackoveflow and open a new question, as this is different than your original post.

Bev in TX

From Marco.Sulla.Python at gmail.com  Mon Mar 23 14:25:28 2020
From: Marco.Sulla.Python at gmail.com (Marco Sulla)
Date: Mon, 23 Mar 2020 19:25:28 +0100
Subject: `async def` breaks encapsulation?
In-Reply-To: 
References: 
 
 
Message-ID: 

On Tue, 17 Mar 2020 at 08:36, Greg Ewing  wrote:
>
> On 4/03/20 12:52 pm, Marco Sulla wrote:
> > Why can't an asynchronous coroutine be simply a coroutine that has an
> > `async` or an `await` in its code, without `async` in the signature?
>
> That wouldn't help as much as you seem to think. You still need
> to use 'await' whenever you call a coroutine, so switching a
> function between coroutine and non-coroutine would still have
> just as much of a ripple effect on the rest of your code.

Good point. But what if you don't need `await`?
A coroutine call `mycoro()` could act as the actual `await mycoro()`.
If you really want `mycoro()` actual behavior, you could write `async
mycoro()`.

From greg.ewing at canterbury.ac.nz  Mon Mar 23 18:33:42 2020
From: greg.ewing at canterbury.ac.nz (Greg Ewing)
Date: Tue, 24 Mar 2020 11:33:42 +1300
Subject: `async def` breaks encapsulation?
In-Reply-To: 
References: 
 
 
 
Message-ID: <7ea9c1b7-4b10-274c-6266-ed9269edd31a@canterbury.ac.nz>

On 24/03/20 7:25 am, Marco Sulla wrote:
> But what if you don't need `await`?
> A coroutine call `mycoro()` could act as the actual `await mycoro()`.
> If you really want `mycoro()` actual behavior, you could write `async
> mycoro()`.

The way async/await is implemented, it's not feasible to wait
until runtime to decide whether a given call should be treated
as an await or not. Different bytecode is generated for it,
and the behaviour of the enclosing function is quite different
right from the start, before the await is even reached.

Other implementation strategies are possible that would
enable "async" and "await" to be eliminated. But there are
many people, including Guido, who regard the need for these
as a feature rather than a bug, because they mark the
places where suspensions can occur. So you would have to
convince those people that these keywords *should* be
eliminated, before thinking about how to achieve it.

-- 
Greg


From lukasz at langa.pl  Mon Mar 23 19:38:39 2020
From: lukasz at langa.pl (=?utf-8?Q?=C5=81ukasz_Langa?=)
Date: Tue, 24 Mar 2020 00:38:39 +0100
Subject: [RELEASE] Python 3.9.0a5 is now available for testing
Message-ID: <91D0C281-A7E8-42A3-A6D6-7301184A1F45@langa.pl>

On behalf of the entire Python development community, and the currently serving Python release team in particular, I?m pleased to announce the release of Python 3.9.0a5. Get it here:

https://www.python.org/downloads/release/python-390a5/ 

This is an early developer preview of Python 3.9

Python 3.9 is still in development. This releasee, 3.9.0a5 is the fifth of six planned alpha releases. Alpha releases are intended to make it easier to test the current state of new features and bug fixes and to test the release process. During the alpha phase, features may be added up until the start of the beta phase (2020-05-18) and, if necessary, may be modified or deleted up until the release candidate phase (2020-08-10). 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.9 series, compared to 3.8

Many new features for Python 3.9 are still being planned and written. Among the new major new features and changes so far:

PEP 584 , Union Operators in dict
PEP 593 , Flexible function and variable annotations
PEP 602 , Python adopts a stable annual release cadence
BPO 38379 , garbage collection does not block on resurrected objects;
BPO 38692 , os.pidfd_open added that allows process management without races and signals;
BPO 39926 , Unicode support updated to version 13.0.0
BPO 1635741 , when Python is initialized multiple times in the same process, it does not leak memory anymore
A number of Python builtins (range, tuple, set, frozenset, list) are now sped up using PEP 570  vectorcall
A number of standard library modules (audioop, ast, grp, _hashlib, pwd, _posixsubprocess, random, select, struct, termios, zlib) are now using the stable ABI defined by PEP 384 .
(Hey, fellow core developer, if a feature you find important is missing from this list, let ?ukasz know .)
The next pre-release, the last alpha release of Python 3.9, will be 3.9.0a6. It is currently scheduled for 2020-04-22. Until then, stay safe!

Your friendly release team,
Ned Deily @nad 
Steve Dower @steve.dower 
?ukasz Langa @ambv 

From rosuav at gmail.com  Tue Mar 24 05:08:31 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 24 Mar 2020 20:08:31 +1100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: <24184.62332.590572.911198@ixdm.fritz.box>
References: 
 <24184.62332.590572.911198@ixdm.fritz.box>
Message-ID: 

On Tue, Mar 24, 2020 at 4:36 AM Dieter Maurer  wrote:
>
> Chris Angelico wrote at 2020-3-23 06:00 +1100:
> >When using textwrap.fill() or friends, setting break_long_words=False
> >without also setting break_on_hyphens=False has the very strange
> >behaviour that a long hyphenated word will still be wrapped.
>
> Having worked with `TeX`, I am familiar that hyphens indicate
> word locations favorable to line breaks. Therefore, I understand
> that one wants a way to control whether or not breaks are allowed
> at hyphens, even if words should not be broken normally.
>
> Apparently, "break_on_hyphens" adds hyphen as a word delimiter.
> With this notion, the behavior can be understood.

Well um... yes. I think we know that hyphens do indicate word-split
points. That's not really in question. But if I say "don't break long
words", and then long words get broken at hyphens, that's surprising.

ChrisA

From Karsten.Hilbert at gmx.net  Tue Mar 24 05:17:34 2020
From: Karsten.Hilbert at gmx.net (Karsten Hilbert)
Date: Tue, 24 Mar 2020 10:17:34 +0100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 <24184.62332.590572.911198@ixdm.fritz.box>
 
Message-ID: <20200324091734.GG2543@hermes.hilbert.loc>

On Tue, Mar 24, 2020 at 08:08:31PM +1100, Chris Angelico wrote:

> Well um... yes. I think we know that hyphens do indicate word-split
> points. That's not really in question.

I know you don't mean it like that, but it sounds equally
future-proof like "all text is ASCII".

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B

From rosuav at gmail.com  Tue Mar 24 05:20:32 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 24 Mar 2020 20:20:32 +1100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: <20200324091734.GG2543@hermes.hilbert.loc>
References: 
 <24184.62332.590572.911198@ixdm.fritz.box>
 
 <20200324091734.GG2543@hermes.hilbert.loc>
Message-ID: 

On Tue, Mar 24, 2020 at 8:19 PM Karsten Hilbert  wrote:
>
> On Tue, Mar 24, 2020 at 08:08:31PM +1100, Chris Angelico wrote:
>
> > Well um... yes. I think we know that hyphens do indicate word-split
> > points. That's not really in question.
>
> I know you don't mean it like that, but it sounds equally
> future-proof like "all text is ASCII".
>

Sure, but I'm not really disputing that part. You can disable it anyway.

I'm trying to figure out a way to handle URLs, and that's something
that has its own governing standard, so the meanings of characters
like hyphens is well defined.

ChrisA

From Karsten.Hilbert at gmx.net  Tue Mar 24 05:34:36 2020
From: Karsten.Hilbert at gmx.net (Karsten Hilbert)
Date: Tue, 24 Mar 2020 10:34:36 +0100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 <24184.62332.590572.911198@ixdm.fritz.box>
 
 <20200324091734.GG2543@hermes.hilbert.loc>
 
Message-ID: <20200324093436.GH2543@hermes.hilbert.loc>

On Tue, Mar 24, 2020 at 08:20:32PM +1100, Chris Angelico wrote:

> > > Well um... yes. I think we know that hyphens do indicate word-split
> > > points. That's not really in question.
> >
> > I know you don't mean it like that, but it sounds equally
> > future-proof like "all text is ASCII".
>
> Sure, but I'm not really disputing that part. You can disable it anyway.
>
> I'm trying to figure out a way to handle URLs, and that's something
> that has its own governing standard, so the meanings of characters
> like hyphens is well defined.

Agreed.

More to the point, if anyone knows how to typographically
properly handle this it's the TeX community. Here's a thread:

	https://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-url

URL shorteners work but suffer from link rot.

Ellipsised URLs plus footnote would work but don't lend
themselves to textwrap() very well (but perhaps to each
individual application of textwrap()).

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B

From farayao.ds at gmail.com  Tue Mar 24 07:11:26 2020
From: farayao.ds at gmail.com (farayao.ds at gmail.com)
Date: Tue, 24 Mar 2020 04:11:26 -0700 (PDT)
Subject: How to create an Excel app that runs Python?
Message-ID: 

I have the following scenario:

I have created lots of python files that I use to calculate a Cashflow model, when I run these files I get a beautiful pandas DataFrame that contains my final model. My mission is to show this table to the rest of the company in a friendly format ("Excel") and they need to be able to generate this table themselves from Excel, using the Python script I created ("the idea is that they open an excel file that has some type of dashboard and a form that they need to fill in, once they fill it in and press "Go" or "Run" or something like that, these parameters will be sent to the Python script to generate this final pandas DataFrame. Finally this DataFrame needs to be displayed/pasted in the Excel sheet that they initially opened)


The problems:

The company needs to be able to run this model, but the users, apart from me, use Excel and they can't open up a Jupyter notebook or VSC to run the code. They can't even install Python on their machines (or at least that is not ideal)


My Attempts:

I am currently using "xlwings" to run Python within Excel, although it requires that the user has Python and xlwings installed and has added the xlwings "Addin", which is not an ideal solution at all.

I am thinking about using Dash, I don't know if it is what I need since I haven't looked into it that much yet (I have been trying to make it work on xlwings first)



If you have any suggestions on how to do this, I would really appreciate that.

Thank you

From frank at chagford.com  Tue Mar 24 07:54:12 2020
From: frank at chagford.com (Frank Millman)
Date: Tue, 24 Mar 2020 13:54:12 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
 <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
Message-ID: <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>

On 2020-03-23 1:56 PM, Frank Millman wrote:
> On 2020-03-23 12:57 PM, Chris Angelico wrote:
>> On Mon, Mar 23, 2020 at 8:03 PM Frank Millman  wrote:
>>>
>>> On 2020-03-22 12:11 PM, Chris Angelico wrote:
>>>> On Sun, Mar 22, 2020 at 8:30 PM Frank Millman  
>>>> wrote:
>>>>>
>>>>> On 2020-03-22 10:45 AM, Chris Angelico wrote:
>>>>
>>>> If you can recreate the problem with a single socket and multiple
>>>> requests, that would be extremely helpful. I also think it's highly
>>>> likely that this is the case.
>>>>
>>>
>>> I am working on a stripped-down version, but I realise there are a few
>>> things I have not grasped.
>>>
>>> Hope you don't mind, but can you scan through what follows and tell me
>>> if I am on the right lines?
>>
>> No probs!
>>
> 
> [...]
> 
> Really appreciate the one-on-one tuition. I am learning a lot!
> 
>>
>>> If this all makes sense, I should write two versions of the client
>>> program, one using a single connection, and one using a pool of 
>>> connections.
>>>
>>
>> Possibly! I think you'll most likely see that one of those behaves
>> perfectly normally, and you only trigger the issue in the other. So
>> you could move forward with just one test program.
>>
> 
> Well, I have got the first one working - single connection - and so far 
> it has not gone wrong.
> 
> However, it is difficult to be sure that I am comparing apples with 
> apples. I have written my test server to handle 'Keep-Alive' correctly, 
> but as I mentioned earlier, my live program closes the connection after 
> each transfer. So now I have to make my test server do the same, and 
> change my test client to react to that and re-open the connection each 
> time. I will make the changes and see how that behaves.
> 
> Of course now I am in the murky waters of trying to second-guess how 
> Edge reacts to that. Presumably that is where Wireshark will be useful. 
> I will keep you posted.

Here is a progress report.

I decided to concentrate on using Wireshark to detect the difference 
between a Python3.7 session and a Python3.8 session. Already I can see 
some differences.

There is only one version of my program. I am simply running it with 
either 'py -3.7 ' or 'py -3.8'. And I am ignoring Chrome at this stage, 
as it is only that Edge shows the problem.

First point - Python3.7 also shows a lot of [RST, ACK] lines. My guess 
is that this is caused by my 'protocol violation' of sending a 
'Keep-Alive' header and then closing the connection. Python3.7 does not 
suffer from dropping files, so I now think this is a sidetrack. I will 
fix my program when this is all over, but for now I don't want to touch it.

When I send the response to the initial connection, I write a status 
line, then multiple header lines, then an html file. I then close the 
connection. Python3.7 sends a packet with the status, then a separate 
packet for each header, then a packet with the file. Python3.8 sends a 
packet with the status, then merges everything else into a single packet 
and sends it in one go. I just mention this as an indication that quite 
a lot has changed between my two versions of Python.

I have one frustration with Wireshark. I will mention it in case anyone 
has a solution.

I can see that Edge opens multiple connections. I am trying to track the 
activity on each connection separately. I can export the data to csv, 
which makes it easier to work on. But while the TCP lines include the 
source and destination ports, the HTTP lines do not, so I don't know 
which connection they belong to. If I view the data in Wireshark's gui 
it does show the ports, so the data is there somewhere. Does anyone know 
how to include it in the csv output?

That's all for now. I will keep you posted.

Frank


From frank at chagford.com  Tue Mar 24 07:54:12 2020
From: frank at chagford.com (Frank Millman)
Date: Tue, 24 Mar 2020 13:54:12 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
 <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
Message-ID: <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>

On 2020-03-23 1:56 PM, Frank Millman wrote:
> On 2020-03-23 12:57 PM, Chris Angelico wrote:
>> On Mon, Mar 23, 2020 at 8:03 PM Frank Millman  wrote:
>>>
>>> On 2020-03-22 12:11 PM, Chris Angelico wrote:
>>>> On Sun, Mar 22, 2020 at 8:30 PM Frank Millman  
>>>> wrote:
>>>>>
>>>>> On 2020-03-22 10:45 AM, Chris Angelico wrote:
>>>>
>>>> If you can recreate the problem with a single socket and multiple
>>>> requests, that would be extremely helpful. I also think it's highly
>>>> likely that this is the case.
>>>>
>>>
>>> I am working on a stripped-down version, but I realise there are a few
>>> things I have not grasped.
>>>
>>> Hope you don't mind, but can you scan through what follows and tell me
>>> if I am on the right lines?
>>
>> No probs!
>>
> 
> [...]
> 
> Really appreciate the one-on-one tuition. I am learning a lot!
> 
>>
>>> If this all makes sense, I should write two versions of the client
>>> program, one using a single connection, and one using a pool of 
>>> connections.
>>>
>>
>> Possibly! I think you'll most likely see that one of those behaves
>> perfectly normally, and you only trigger the issue in the other. So
>> you could move forward with just one test program.
>>
> 
> Well, I have got the first one working - single connection - and so far 
> it has not gone wrong.
> 
> However, it is difficult to be sure that I am comparing apples with 
> apples. I have written my test server to handle 'Keep-Alive' correctly, 
> but as I mentioned earlier, my live program closes the connection after 
> each transfer. So now I have to make my test server do the same, and 
> change my test client to react to that and re-open the connection each 
> time. I will make the changes and see how that behaves.
> 
> Of course now I am in the murky waters of trying to second-guess how 
> Edge reacts to that. Presumably that is where Wireshark will be useful. 
> I will keep you posted.

Here is a progress report.

I decided to concentrate on using Wireshark to detect the difference 
between a Python3.7 session and a Python3.8 session. Already I can see 
some differences.

There is only one version of my program. I am simply running it with 
either 'py -3.7 ' or 'py -3.8'. And I am ignoring Chrome at this stage, 
as it is only that Edge shows the problem.

First point - Python3.7 also shows a lot of [RST, ACK] lines. My guess 
is that this is caused by my 'protocol violation' of sending a 
'Keep-Alive' header and then closing the connection. Python3.7 does not 
suffer from dropping files, so I now think this is a sidetrack. I will 
fix my program when this is all over, but for now I don't want to touch it.

When I send the response to the initial connection, I write a status 
line, then multiple header lines, then an html file. I then close the 
connection. Python3.7 sends a packet with the status, then a separate 
packet for each header, then a packet with the file. Python3.8 sends a 
packet with the status, then merges everything else into a single packet 
and sends it in one go. I just mention this as an indication that quite 
a lot has changed between my two versions of Python.

I have one frustration with Wireshark. I will mention it in case anyone 
has a solution.

I can see that Edge opens multiple connections. I am trying to track the 
activity on each connection separately. I can export the data to csv, 
which makes it easier to work on. But while the TCP lines include the 
source and destination ports, the HTTP lines do not, so I don't know 
which connection they belong to. If I view the data in Wireshark's gui 
it does show the ports, so the data is there somewhere. Does anyone know 
how to include it in the csv output?

That's all for now. I will keep you posted.

Frank

From frank at chagford.com  Tue Mar 24 09:58:51 2020
From: frank at chagford.com (Frank Millman)
Date: Tue, 24 Mar 2020 15:58:51 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
 <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
 <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>
Message-ID: <3f1594ee-ddee-d415-82ee-91a2b5e1afe4@chagford.com>

On 2020-03-24 1:54 PM, Frank Millman wrote:
> On 2020-03-23 1:56 PM, Frank Millman wrote:
> 
> I have one frustration with Wireshark. I will mention it in case anyone 
> has a solution.
> 
> I can see that Edge opens multiple connections. I am trying to track the 
> activity on each connection separately. I can export the data to csv, 
> which makes it easier to work on. But while the TCP lines include the 
> source and destination ports, the HTTP lines do not, so I don't know 
> which connection they belong to. If I view the data in Wireshark's gui 
> it does show the ports, so the data is there somewhere. Does anyone know 
> how to include it in the csv output?
> 

I solved my Wireshark problem by exporting the data as text. A much more 
wordy format, and fiddly to parse, but the info I am looking for is there.

I am getting some interesting results now, such as a second GET 
interrupting an existing session. However, my brain is now frazzled, so 
I will continue tomorrow.

Frank


From frank at chagford.com  Tue Mar 24 09:58:51 2020
From: frank at chagford.com (Frank Millman)
Date: Tue, 24 Mar 2020 15:58:51 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
 <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
 <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>
Message-ID: <3f1594ee-ddee-d415-82ee-91a2b5e1afe4@chagford.com>

On 2020-03-24 1:54 PM, Frank Millman wrote:
> On 2020-03-23 1:56 PM, Frank Millman wrote:
> 
> I have one frustration with Wireshark. I will mention it in case anyone 
> has a solution.
> 
> I can see that Edge opens multiple connections. I am trying to track the 
> activity on each connection separately. I can export the data to csv, 
> which makes it easier to work on. But while the TCP lines include the 
> source and destination ports, the HTTP lines do not, so I don't know 
> which connection they belong to. If I view the data in Wireshark's gui 
> it does show the ports, so the data is there somewhere. Does anyone know 
> how to include it in the csv output?
> 

I solved my Wireshark problem by exporting the data as text. A much more 
wordy format, and fiddly to parse, but the info I am looking for is there.

I am getting some interesting results now, such as a second GET 
interrupting an existing session. However, my brain is now frazzled, so 
I will continue tomorrow.

Frank

From souvik.viksou at gmail.com  Tue Mar 24 12:11:29 2020
From: souvik.viksou at gmail.com (Souvik Dutta)
Date: Tue, 24 Mar 2020 21:41:29 +0530
Subject: How to create an Excel app that runs Python?
In-Reply-To: 
References: 
Message-ID: 

You might try pyqt5 if you want to make a custom GUI and also if you have
tha time to do so.

On Tue, Mar 24, 2020, 4:45 PM  wrote:

> I have the following scenario:
>
> I have created lots of python files that I use to calculate a Cashflow
> model, when I run these files I get a beautiful pandas DataFrame that
> contains my final model. My mission is to show this table to the rest of
> the company in a friendly format ("Excel") and they need to be able to
> generate this table themselves from Excel, using the Python script I
> created ("the idea is that they open an excel file that has some type of
> dashboard and a form that they need to fill in, once they fill it in and
> press "Go" or "Run" or something like that, these parameters will be sent
> to the Python script to generate this final pandas DataFrame. Finally this
> DataFrame needs to be displayed/pasted in the Excel sheet that they
> initially opened)
>
>
> The problems:
>
> The company needs to be able to run this model, but the users, apart from
> me, use Excel and they can't open up a Jupyter notebook or VSC to run the
> code. They can't even install Python on their machines (or at least that is
> not ideal)
>
>
> My Attempts:
>
> I am currently using "xlwings" to run Python within Excel, although it
> requires that the user has Python and xlwings installed and has added the
> xlwings "Addin", which is not an ideal solution at all.
>
> I am thinking about using Dash, I don't know if it is what I need since I
> haven't looked into it that much yet (I have been trying to make it work on
> xlwings first)
>
>
>
> If you have any suggestions on how to do this, I would really appreciate
> that.
>
> Thank you
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From oliver.schoenborn at gmail.com  Tue Mar 24 12:25:59 2020
From: oliver.schoenborn at gmail.com (oliver)
Date: Tue, 24 Mar 2020 12:25:59 -0400
Subject: How to create an Excel app that runs Python?
In-Reply-To: 
References: 
Message-ID: 

Use the win32com library to interact with Excel via COM. Although the
learning curve is a little steeper it's not too bad and works great. I used
this technique to control ARENA with Python through its COM API to run a
whack of simulations (1000-10000), then used python to gather the results,
and used win32com from python to finally inject the data into Excel and get
it to generate charts and tables that could be used by stakeholders without
access to python.

Oliver Schoenborn
  || Cloud Application Engineer, Owner || Sentian Cloud Computing Inc.
  || Ottawa, ON, Canada || +1-613-552-4466 (mobile)
  || oliver at sentianSE.com




On Tue, Mar 24, 2020 at 7:16 AM  wrote:

> I have the following scenario:
>
> I have created lots of python files that I use to calculate a Cashflow
> model, when I run these files I get a beautiful pandas DataFrame that
> contains my final model. My mission is to show this table to the rest of
> the company in a friendly format ("Excel") and they need to be able to
> generate this table themselves from Excel, using the Python script I
> created ("the idea is that they open an excel file that has some type of
> dashboard and a form that they need to fill in, once they fill it in and
> press "Go" or "Run" or something like that, these parameters will be sent
> to the Python script to generate this final pandas DataFrame. Finally this
> DataFrame needs to be displayed/pasted in the Excel sheet that they
> initially opened)
>
>
> The problems:
>
> The company needs to be able to run this model, but the users, apart from
> me, use Excel and they can't open up a Jupyter notebook or VSC to run the
> code. They can't even install Python on their machines (or at least that is
> not ideal)
>
>
> My Attempts:
>
> I am currently using "xlwings" to run Python within Excel, although it
> requires that the user has Python and xlwings installed and has added the
> xlwings "Addin", which is not an ideal solution at all.
>
> I am thinking about using Dash, I don't know if it is what I need since I
> haven't looked into it that much yet (I have been trying to make it work on
> xlwings first)
>
>
>
> If you have any suggestions on how to do this, I would really appreciate
> that.
>
> Thank you
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From dieter at handshake.de  Tue Mar 24 13:21:01 2020
From: dieter at handshake.de (Dieter Maurer)
Date: Tue, 24 Mar 2020 18:21:01 +0100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: <20200324093436.GH2543@hermes.hilbert.loc>
References: 
 <24184.62332.590572.911198@ixdm.fritz.box>
 
 <20200324091734.GG2543@hermes.hilbert.loc>
 
 <20200324093436.GH2543@hermes.hilbert.loc>
Message-ID: <24186.16765.719460.573876@ixdm.fritz.box>

Karsten Hilbert wrote at 2020-3-24 10:34 +0100:
>On Tue, Mar 24, 2020 at 08:20:32PM +1100, Chris Angelico wrote:
> ...
>> I'm trying to figure out a way to handle URLs, and that's something
>> that has its own governing standard, so the meanings of characters
>> like hyphens is well defined.
>
>Agreed.
>
>More to the point, if anyone knows how to typographically
>properly handle this it's the TeX community. Here's a thread:
>
>	https://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-url

Page based output devices are more difficult: they have a fixed width.

When the result targets a screen, horizontal scrolling is possible
(even if it is not very convenient). There, preventing urls from being
split may be an option.

From paolo.cantore at t-online.de  Tue Mar 24 13:37:55 2020
From: paolo.cantore at t-online.de (Paolo G. Cantore)
Date: Tue, 24 Mar 2020 18:37:55 +0100
Subject: How to create an Excel app that runs Python?
In-Reply-To: 
References: 
 
 
Message-ID: 


On Tue, Mar 24, 2020, 4:45 PM  wrote:

> I have the following scenario:
>
> I have created lots of python files that I use to calculate a Cashflow
> model, when I run these files I get a beautiful pandas DataFrame that
> contains my final model. My mission is to show this table to the rest of
> the company in a friendly format ("Excel") and they need to be able to
> generate this table themselves from Excel, using the Python script I
> created ("the idea is that they open an excel file that has some type of
> dashboard and a form that they need to fill in, once they fill it in and
> press "Go" or "Run" or something like that, these parameters will be sent
> to the Python script to generate this final pandas DataFrame. Finally this
> DataFrame needs to be displayed/pasted in the Excel sheet that they
> initially opened)
>
>
> The problems:
>
> The company needs to be able to run this model, but the users, apart from
> me, use Excel and they can't open up a Jupyter notebook or VSC to run the
> code. They can't even install Python on their machines (or at least that is
> not ideal)
>
>
> My Attempts:
>
> I am currently using "xlwings" to run Python within Excel, although it
> requires that the user has Python and xlwings installed and has added the
> xlwings "Addin", which is not an ideal solution at all.
>
> I am thinking about using Dash, I don't know if it is what I need since I
> haven't looked into it that much yet (I have been trying to make it work on
> xlwings first)
>
>
>
> If you have any suggestions on how to do this, I would really appreciate
> that.
>
> Thank you
> --
> https://mail.python.org/mailman/listinfo/python-list
>
The scenario you describe should be fulfilled by a web application.

I'm sure your users are also able to use a browser, not only Excel.

The HTML forms management offers the GUI capabilities to enter the 
parameters. The processing steps could be as follows:

1. Enter the url for the application in question and display the form.
2. Enter the needed data in the form.
3. Process the data (with lots of your python scripts) and show the 
result in the browser.
4. If all is ok, download the data sheet in Excel format (using 
DataFrame.to_excel)


From barry at barrys-emacs.org  Tue Mar 24 14:39:50 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Tue, 24 Mar 2020 18:39:50 +0000
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
 <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
 <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>
Message-ID: 



> On 24 Mar 2020, at 11:54, Frank Millman  wrote:
> 
> On 2020-03-23 1:56 PM, Frank Millman wrote:
>> On 2020-03-23 12:57 PM, Chris Angelico wrote:
>>> On Mon, Mar 23, 2020 at 8:03 PM Frank Millman  wrote:
>>>> 
>>>> On 2020-03-22 12:11 PM, Chris Angelico wrote:
>>>>> On Sun, Mar 22, 2020 at 8:30 PM Frank Millman  wrote:
>>>>>> 
>>>>>> On 2020-03-22 10:45 AM, Chris Angelico wrote:
>>>>> 
>>>>> If you can recreate the problem with a single socket and multiple
>>>>> requests, that would be extremely helpful. I also think it's highly
>>>>> likely that this is the case.
>>>>> 
>>>> 
>>>> I am working on a stripped-down version, but I realise there are a few
>>>> things I have not grasped.
>>>> 
>>>> Hope you don't mind, but can you scan through what follows and tell me
>>>> if I am on the right lines?
>>> 
>>> No probs!
>>> 
>> [...]
>> Really appreciate the one-on-one tuition. I am learning a lot!
>>> 
>>>> If this all makes sense, I should write two versions of the client
>>>> program, one using a single connection, and one using a pool of connections.
>>>> 
>>> 
>>> Possibly! I think you'll most likely see that one of those behaves
>>> perfectly normally, and you only trigger the issue in the other. So
>>> you could move forward with just one test program.
>>> 
>> Well, I have got the first one working - single connection - and so far it has not gone wrong.
>> However, it is difficult to be sure that I am comparing apples with apples. I have written my test server to handle 'Keep-Alive' correctly, but as I mentioned earlier, my live program closes the connection after each transfer. So now I have to make my test server do the same, and change my test client to react to that and re-open the connection each time. I will make the changes and see how that behaves.
>> Of course now I am in the murky waters of trying to second-guess how Edge reacts to that. Presumably that is where Wireshark will be useful. I will keep you posted.
> 
> Here is a progress report.
> 
> I decided to concentrate on using Wireshark to detect the difference between a Python3.7 session and a Python3.8 session. Already I can see some differences.
> 
> There is only one version of my program. I am simply running it with either 'py -3.7 ' or 'py -3.8'. And I am ignoring Chrome at this stage, as it is only that Edge shows the problem.
> 
> First point - Python3.7 also shows a lot of [RST, ACK] lines. My guess is that this is caused by my 'protocol violation' of sending a 'Keep-Alive' header and then closing the connection. Python3.7 does not suffer from dropping files, so I now think this is a sidetrack. I will fix my program when this is all over, but for now I don't want to touch it.

Yes your protocol violation is why you see [RST, ACK].

I'm confused you know that the code has a critical bug in it and you have not fixed it?
Just send "Connection: close" and I'd assume all will work.

If my last message was not clear let me know what is unclear.

It not interesting that you get away with it in 3.7 and not 3.8 because the code is wrong.

> When I send the response to the initial connection, I write a status line, then multiple header lines, then an html file. I then close the connection. Python3.7 sends a packet with the status, then a separate packet for each header, then a packet with the file. Python3.8 sends a packet with the status, then merges everything else into a single packet and sends it in one go. I just mention this as an indication that quite a lot has changed between my two versions of Python.
> 
> I have one frustration with Wireshark. I will mention it in case anyone has a solution.
> 
> I can see that Edge opens multiple connections. I am trying to track the activity on each connection separately. I can export the data to csv, which makes it easier to work on. But while the TCP lines include the source and destination ports, the HTTP lines do not, so I don't know which connection they belong to. If I view the data in Wireshark's gui it does show the ports, so the data is there somewhere. Does anyone know how to include it in the csv output?

There is a option to follow a single TCP or HTTP connection in Wireshark.
Right click on one pf the packets then choose Follow/HTTP stream.

The way to share the data is as a PCAP file that allows someone else to look at the capture
with tools like wireshark and others.

> 
> That's all for now. I will keep you posted.

Barry

> 
> Frank
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list 

From PythonList at DancesWithMice.info  Tue Mar 24 17:02:50 2020
From: PythonList at DancesWithMice.info (DL Neil)
Date: Wed, 25 Mar 2020 10:02:50 +1300
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
Message-ID: <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>

On 23/03/20 8:00 AM, Chris Angelico wrote:
> When using textwrap.fill() or friends, setting break_long_words=False
> without also setting break_on_hyphens=False has the very strange
> behaviour that a long hyphenated word will still be wrapped. I
> discovered this as a very surprising result when trying to wrap a
> paragraph that contained a URL, and wanting the URL to be kept
> unchanged:

I dropped textwrap years ago. Which policy likely shows my/my 
applications' bias.

Today it feels like an anachronism because it is comes from the era of 
fixed-width fonts and line-lengths denominated in characters*. The issue 
is that it was designed to re-define 'white space' and to enable the 
conversion of text 'wrapped' in one (fixed) format, to suit another. 
With the arrival?predominance of proportional-width fonts, the skills of 
hyphenation have started to go the way of cursive hand-writing 
[substitute any number of grumpy, old man regrets/favorite complaints, 
here].


Beyond such syntactic concerns, textwrap applies no semantic meaning to 
its text-content. For that we have to move to markup languages (HTML is 
my bias - but (largely) presumes screen presentation). Python seems to 
prefer reST (eg Sphinx). See also, markdown.


However, it's annoying if one is 'stuck' within a spec and some list 
smart-alec comes along saying 'change the tool'...

Your idea of sub-classing (as I'm sure YOU know, textwrap is but a 
convenience-function) struck me as clever-thinking! Could textwrap's 
'final format' be caught just before 'return', enabling a post-process 
to undo anything textwrap has done, and (re-)format the URLs to spec, or 
to treat textwrap's output as a template and 'inject' the URL 
appropriately? If not a sub-class, a decorator?

My idea (being more simple-minded than you!), would be to partition the 
text (yes, am alluding to the Python str.method):
- textwrap the 'early text',
- treat the URL as a string using the required convention,
- textwrap the 'later text', and
- str.join() the three components/partitions afterwards.

Both likely 'force' the URL to occupy a line of its own, and thus create 
some odd-looking results!


* that said, my terminal windows and SublimeText are all configured to 
use fixed-width fonts - seems easier on the eyes! Similarly, the 
mainframe legacy of punched-card input is alive-and-well in Python 
'standards', which talk of a 79- or 80-character line-width. Please 
don't take me by the ear and wash-out my mouth with soap and water!
-- 
Regards =dn

From rosuav at gmail.com  Tue Mar 24 17:30:07 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Wed, 25 Mar 2020 08:30:07 +1100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
Message-ID: 

On Wed, Mar 25, 2020 at 8:04 AM DL Neil via Python-list
 wrote:
>
> On 23/03/20 8:00 AM, Chris Angelico wrote:
> > When using textwrap.fill() or friends, setting break_long_words=False
> > without also setting break_on_hyphens=False has the very strange
> > behaviour that a long hyphenated word will still be wrapped. I
> > discovered this as a very surprising result when trying to wrap a
> > paragraph that contained a URL, and wanting the URL to be kept
> > unchanged:
>
> I dropped textwrap years ago. Which policy likely shows my/my
> applications' bias.
>
> Today it feels like an anachronism because it is comes from the era of
> fixed-width fonts and line-lengths denominated in characters*. The issue
> is that it was designed to re-define 'white space' and to enable the
> conversion of text 'wrapped' in one (fixed) format, to suit another.
> With the arrival?predominance of proportional-width fonts, the skills of
> hyphenation have started to go the way of cursive hand-writing
> [substitute any number of grumpy, old man regrets/favorite complaints,
> here].

Terminals still use somewhat-fixed-width fonts, so it's still
reasonably appropriate - until there's some sort of indentation level
escape code.

> Your idea of sub-classing (as I'm sure YOU know, textwrap is but a
> convenience-function) struck me as clever-thinking! Could textwrap's
> 'final format' be caught just before 'return', enabling a post-process
> to undo anything textwrap has done, and (re-)format the URLs to spec, or
> to treat textwrap's output as a template and 'inject' the URL
> appropriately? If not a sub-class, a decorator?

Hmmmmmm. Very VERY interesting idea, and one I hadn't thought of. Thank you.

> My idea (being more simple-minded than you!), would be to partition the
> text (yes, am alluding to the Python str.method):
> - textwrap the 'early text',
> - treat the URL as a string using the required convention,
> - textwrap the 'later text', and
> - str.join() the three components/partitions afterwards.
>
> Both likely 'force' the URL to occupy a line of its own, and thus create
> some odd-looking results!

The use-case here is a Twitter client I'm building. It works in the
terminal. I would very much like NOT to build any sort of GUI for it.
Since tweets often contain URLs, it's important to render them
correctly. The display style is to have "@Username: " at the start of
the first line, and the same number of spaces on subsequent lines,
which creates a very readable display. (Also, quoting retweets show
the original tweet indented underneath, giving a bit more
indentation.) Unfortunately, forcing every URL onto its own line would
make the display a bit too vertical for my liking; often there's a
very short URL (eg someone's Twitch link) that doesn't want to be
split across.

Actually the ultimate solution would be the not-yet-standardized
protocol for effectively showing hypertext on the console, where the
abbreviated text could actually be made clickable as the full text.
But that requires more help from the terminal emulator, unless I'm
just misreading the examples (it's supposed to work in gnome-terminal
but I couldn't get it to behave). Or alternatively, as mentioned, a
way to say to the terminal emulator, "please indent this text by at
least this amount" (where the amount would most likely be specified as
a number of characters, but in theory could be millimeters instead).

For now, though, all I can do is rewrap URLs. And at the moment, what
I've done is just block all long words from being wrapped AND block
words from being wrapped at hyphens, when really what I actually want
is to say "https://......." becomes unbreakable, and leave all the
rest unchanged. Hence the question about the regex.

Currently, the regex splits a long line of text into a series of
words, including hyphen points. What I want is to assert "this ain't a
word split point, because the word starts [a-z]+:// and is thus a
URL". But that might be beyond the flexibility of REs.

ChrisA

From grant.b.edwards at gmail.com  Tue Mar 24 15:52:09 2020
From: grant.b.edwards at gmail.com (Grant Edwards)
Date: Tue, 24 Mar 2020 19:52:09 -0000 (UTC)
Subject: How to create an Excel app that runs Python?
References: 
 
Message-ID: 

On 2020-03-24, oliver  wrote:

> Use the win32com library to interact with Excel via COM.

Huh?  I thought that the users have no way of running a local Python
app.

--
Grant



From PythonList at DancesWithMice.info  Tue Mar 24 18:36:17 2020
From: PythonList at DancesWithMice.info (DL Neil)
Date: Wed, 25 Mar 2020 11:36:17 +1300
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 
Message-ID: 

On 25/03/20 10:30 AM, Chris Angelico wrote:
> On Wed, Mar 25, 2020 at 8:04 AM DL Neil via Python-list
>  wrote:
>>
>> On 23/03/20 8:00 AM, Chris Angelico wrote:
>>> When using textwrap.fill() or friends, setting break_long_words=False
>>> without also setting break_on_hyphens=False has the very strange
>>> behaviour that a long hyphenated word will still be wrapped. I
>>> discovered this as a very surprising result when trying to wrap a
>>> paragraph that contained a URL, and wanting the URL to be kept
>>> unchanged:

>> Your idea of sub-classing (as I'm sure YOU know, textwrap is but a
>> convenience-function) struck me as clever-thinking! Could textwrap's
>> 'final format' be caught just before 'return', enabling a post-process
>> to undo anything textwrap has done, and (re-)format the URLs to spec, or
>> to treat textwrap's output as a template and 'inject' the URL
>> appropriately? If not a sub-class, a decorator?
> 
> Hmmmmmm. Very VERY interesting idea, and one I hadn't thought of. Thank you.

A pleasure to be able to offer even such a small 'something', by way of 
return!


>> My idea (being more simple-minded than you!), would be to partition the
>> text (yes, am alluding to the Python str.method):
>> - textwrap the 'early text',
>> - treat the URL as a string using the required convention,
>> - textwrap the 'later text', and
>> - str.join() the three components/partitions afterwards.
>>
>> Both likely 'force' the URL to occupy a line of its own, and thus create
>> some odd-looking results!
> 
> The use-case here is a Twitter client I'm building. It works in the
> terminal. I would very much like NOT to build any sort of GUI for it.

+1


> Since tweets often contain URLs, it's important to render them
> correctly. The display style is to have "@Username: " at the start of
> the first line, and the same number of spaces on subsequent lines,
> which creates a very readable display. (Also, quoting retweets show
> the original tweet indented underneath, giving a bit more
> indentation.) Unfortunately, forcing every URL onto its own line would
> make the display a bit too vertical for my liking; often there's a
> very short URL (eg someone's Twitch link) that doesn't want to be
> split across.
> 
> Actually the ultimate solution would be the not-yet-standardized
> protocol for effectively showing hypertext on the console, where the
> abbreviated text could actually be made clickable as the full text.
> But that requires more help from the terminal emulator, unless I'm
> just misreading the examples (it's supposed to work in gnome-terminal
> but I couldn't get it to behave). Or alternatively, as mentioned, a
> way to say to the terminal emulator, "please indent this text by at
> least this amount" (where the amount would most likely be specified as
> a number of characters, but in theory could be millimeters instead).
> 
> For now, though, all I can do is rewrap URLs. And at the moment, what
> I've done is just block all long words from being wrapped AND block
> words from being wrapped at hyphens, when really what I actually want
> is to say "https://......." becomes unbreakable, and leave all the
> rest unchanged. Hence the question about the regex.
> 
> Currently, the regex splits a long line of text into a series of
> words, including hyphen points. What I want is to assert "this ain't a
> word split point, because the word starts [a-z]+:// and is thus a
> URL". But that might be beyond the flexibility of REs.


As you observe, the problem with terminal emulators is the extent of 
their emulation and the degree of adoption of their 'extended features'!

My concern grows because of the need (I assume) for the URL to be 
'clickable', not merely 'complete' and 'unadorned' (no added hyphen 
rendering it useless).

Despite the almost-irresistible urge to prove that I'm a class-y guy 
[albeit with a warped sense of humor], I'm warming to the 'partition' 
suggestion:
- the output from textwrap.wrap() is a list of strings,
- we are talking about fixed-length lines denominated in characters,
- locating a[ll] URI (from a sub-set of schemes, eg "http", "https", 
...) is a well-worn path.

Thus (simplified to assume the presence of exactly one URI!!!):
- textwrap the first partition
- len( URI )
- it becomes trivial to ascertain if the URL might append the last line 
(of the first 'wrapped' partition)
- failing that, the URI must start a new line (by defn)
- if it is 'too long', ie would be wrapped by textwrap, treat it separately,
- conversely, prepend the URI to the third partition,
- text-wrap the third partition,
- assemble the tweet-display.

Opinion to the contrary, I am not a twit. I fear missing something in 
those subtleties...
-- 
Regards =dn

From rosuav at gmail.com  Tue Mar 24 18:57:55 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Wed, 25 Mar 2020 09:57:55 +1100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 
 
Message-ID: 

On Wed, Mar 25, 2020 at 9:37 AM DL Neil via Python-list
 wrote:
>
> As you observe, the problem with terminal emulators is the extent of
> their emulation and the degree of adoption of their 'extended features'!
>
> My concern grows because of the need (I assume) for the URL to be
> 'clickable', not merely 'complete' and 'unadorned' (no added hyphen
> rendering it useless).

A complete URL is clickable. If I print out the string
"https://example.com/" then it can be right-clicked and copied, or
sent to a browser, or whatever. (Technically I don't need it to be
"clickable", but the terminal emulator has to recognize it as a link.)
FTR I'm using XFCE and xfce4-terminal, although I think everything
applies to most of the popular terminal emulators.

The problem is that a long URL will wrap. So my options are:

1) Let it wrap, violating the indentation
2) Break it, which stops it from being clickable
3) Get help from the terminal emulator

> Despite the almost-irresistible urge to prove that I'm a class-y guy
> [albeit with a warped sense of humor], I'm warming to the 'partition'
> suggestion:
> - the output from textwrap.wrap() is a list of strings,
> - we are talking about fixed-length lines denominated in characters,
> - locating a[ll] URI (from a sub-set of schemes, eg "http", "https",
> ...) is a well-worn path.

I'm not bothered too much by specific schemes. If a word matches the
regex ^[a-z]+:// then I'll call it a URL.

> Thus (simplified to assume the presence of exactly one URI!!!):
> - textwrap the first partition
> - len( URI )
> - it becomes trivial to ascertain if the URL might append the last line
> (of the first 'wrapped' partition)
> - failing that, the URI must start a new line (by defn)
> - if it is 'too long', ie would be wrapped by textwrap, treat it separately,
> - conversely, prepend the URI to the third partition,
> - text-wrap the third partition,
> - assemble the tweet-display.
>

Hmm. So, basically, manual reimplementation of parts of textwrap. I'll
hold that thought for later... if it's possible to just change the
regex and keep the code unchanged, I'll prefer that, but this is a
possibility. Thanks.

ChrisA

From drsalists at gmail.com  Tue Mar 24 19:06:35 2020
From: drsalists at gmail.com (Dan Stromberg)
Date: Tue, 24 Mar 2020 16:06:35 -0700
Subject: yield from
Message-ID: 

Some time ago, when I first heard about yield from, it wasn't faster than a
for loop yielding.

Has that improved?

From rosuav at gmail.com  Tue Mar 24 19:11:53 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Wed, 25 Mar 2020 10:11:53 +1100
Subject: yield from
In-Reply-To: 
References: 
Message-ID: 

On Wed, Mar 25, 2020 at 10:08 AM Dan Stromberg  wrote:
>
> Some time ago, when I first heard about yield from, it wasn't faster than a
> for loop yielding.
>
> Has that improved?

It's not about speed. It's about correctness, and the way it delegates
everything, not just "for x in iter: yield x". Here's what it's
actually equivalent to:

https://www.python.org/dev/peps/pep-0380/#formal-semantics

It'll be a LOT more efficient than writing all that out manually. For
the simple case where you really can just loop and yield, sure, though
IMO it's still clearer to yield-from than to loop-yield.

ChrisA

From greg.ewing at canterbury.ac.nz  Wed Mar 25 01:22:36 2020
From: greg.ewing at canterbury.ac.nz (Greg Ewing)
Date: Wed, 25 Mar 2020 18:22:36 +1300
Subject: How does the super type present itself and do lookups?
In-Reply-To: <367c16f0-eea4-42a1-b869-164b40a64c0d@googlegroups.com>
References: <06159e03-fa8d-4022-a074-4075eb097c16@googlegroups.com>
 
 
 
 
 <367c16f0-eea4-42a1-b869-164b40a64c0d@googlegroups.com>
Message-ID: 

On 23/03/20 7:40 pm, Adam Preble wrote:
> I don't doubt what you got from the source, but I am trying to figure
> out how I could have inferred that from the code I was trying. It
> looks like child_instance.__getattribute__ ==
> child_instance.super().__getattribute__.

Don't feel too bad, it took me a while to figure out what was
happening here myself!

I think the problem is that the act of looking up __getattribute__
on the super object invokes the super object's magic lookup
machinery, and ends up giving a misleading result.

It's clearer if you look for __getattribute__ directly on the
*class* of the super object. I tried this experiment:

class C:

     a = "a in C"

class D(C):

     a = "a in D"

     def getsuper(self):
         return super()

d = D()
s = d.getsuper()
print("type(d).__getattribute__ =", type(d).__getattribute__)
print("type(s).__getattribute__ =", type(s).__getattribute__)

Result:

type(d).__getattribute__ = 
type(s).__getattribute__ = 

If you try this with __getattr__ you find that super objects
don't even have one:

print("type(s).__getattr__ =", type(s).__getattr__)

gives

AttributeError: type object 'super' has no attribute '__getattr__'

Another way to see this is to look at the class dict of the super
object:

print(list(type(s).__dict__.keys()))

gives

['__repr__', '__getattribute__', '__get__', '__init__', '__new__', 
'__thisclass__', '__self__', '__self_class__', '__doc__']

from which it's clear that the super object overrides __getattribute__
but not __getattr__.

-- 
Greg

From frank at chagford.com  Wed Mar 25 02:12:45 2020
From: frank at chagford.com (Frank Millman)
Date: Wed, 25 Mar 2020 08:12:45 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
 <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
 <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>
 
Message-ID: <2470174a-ed7a-76eb-70d7-64c57ead6bfc@chagford.com>

On 2020-03-24 8:39 PM, Barry Scott wrote:
> 
> 
>> On 24 Mar 2020, at 11:54, Frank Millman  wrote:
>>
>>
>> I decided to concentrate on using Wireshark to detect the difference between a Python3.7 session and a Python3.8 session. Already I can see some differences.
>>
>> There is only one version of my program. I am simply running it with either 'py -3.7 ' or 'py -3.8'. And I am ignoring Chrome at this stage, as it is only that Edge shows the problem.
>>
>> First point - Python3.7 also shows a lot of [RST, ACK] lines. My guess is that this is caused by my 'protocol violation' of sending a 'Keep-Alive' header and then closing the connection. Python3.7 does not suffer from dropping files, so I now think this is a sidetrack. I will fix my program when this is all over, but for now I don't want to touch it.
> 
> Yes your protocol violation is why you see [RST, ACK].
> 
> I'm confused you know that the code has a critical bug in it and you have not fixed it?
> Just send "Connection: close" and I'd assume all will work.
> 

Well, the reason is simply that I wanted to understand why my code that 
worked all the way from 3.4 through 3.7 stopped working in 3.8. I 
realise that my code is faulty, but I still wanted to know what the 
trigger was that caused the bug to appear.

 From my testing with Wireshark, I can see that both Edge and Chrome 
create 20 connections to GET 20 files. The difference seems to be that 
Chrome does not attempt to re-use a connection, even though both client 
and server have sent Keep-Alive headers. Edge does attempt to re-use the 
connection.

The difference between 3.7 and 3.8 is that 3.7 sends the data in 
separate packets for the status, each header, and then each chunk, 
whereas 3.8 sends the whole lot in a single packet.

My guess is that 3.7 is slower to send the files, so Edge starts up all 
20 connections before it has finished receiving the first one, whereas 
with 3.8, by the time it has opened a few connections the first file has 
been received, so it tries to re-use the same connection to receive the 
next one. By then I have closed the connection. If I am right, it is 
surprising that my program worked *some* of the time.

The same reasoning would explain why it worked when connecting from a 
remote host. There would be enough delay to force it into the same 
behaviour as 3.7.

It has been an interesting ride, and I have learned a lot. I will now 
look into fixing my program. The easy fix is to just send 'Connection: 
Close', but I will do it properly and implement 'Keep-Alive'.

Thanks all

Frank


From frank at chagford.com  Wed Mar 25 02:12:45 2020
From: frank at chagford.com (Frank Millman)
Date: Wed, 25 Mar 2020 08:12:45 +0200
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: 
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
 <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
 <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>
 
Message-ID: <2470174a-ed7a-76eb-70d7-64c57ead6bfc@chagford.com>

On 2020-03-24 8:39 PM, Barry Scott wrote:
> 
> 
>> On 24 Mar 2020, at 11:54, Frank Millman  wrote:
>>
>>
>> I decided to concentrate on using Wireshark to detect the difference between a Python3.7 session and a Python3.8 session. Already I can see some differences.
>>
>> There is only one version of my program. I am simply running it with either 'py -3.7 ' or 'py -3.8'. And I am ignoring Chrome at this stage, as it is only that Edge shows the problem.
>>
>> First point - Python3.7 also shows a lot of [RST, ACK] lines. My guess is that this is caused by my 'protocol violation' of sending a 'Keep-Alive' header and then closing the connection. Python3.7 does not suffer from dropping files, so I now think this is a sidetrack. I will fix my program when this is all over, but for now I don't want to touch it.
> 
> Yes your protocol violation is why you see [RST, ACK].
> 
> I'm confused you know that the code has a critical bug in it and you have not fixed it?
> Just send "Connection: close" and I'd assume all will work.
> 

Well, the reason is simply that I wanted to understand why my code that 
worked all the way from 3.4 through 3.7 stopped working in 3.8. I 
realise that my code is faulty, but I still wanted to know what the 
trigger was that caused the bug to appear.

 From my testing with Wireshark, I can see that both Edge and Chrome 
create 20 connections to GET 20 files. The difference seems to be that 
Chrome does not attempt to re-use a connection, even though both client 
and server have sent Keep-Alive headers. Edge does attempt to re-use the 
connection.

The difference between 3.7 and 3.8 is that 3.7 sends the data in 
separate packets for the status, each header, and then each chunk, 
whereas 3.8 sends the whole lot in a single packet.

My guess is that 3.7 is slower to send the files, so Edge starts up all 
20 connections before it has finished receiving the first one, whereas 
with 3.8, by the time it has opened a few connections the first file has 
been received, so it tries to re-use the same connection to receive the 
next one. By then I have closed the connection. If I am right, it is 
surprising that my program worked *some* of the time.

The same reasoning would explain why it worked when connecting from a 
remote host. There would be enough delay to force it into the same 
behaviour as 3.7.

It has been an interesting ride, and I have learned a lot. I will now 
look into fixing my program. The easy fix is to just send 'Connection: 
Close', but I will do it properly and implement 'Keep-Alive'.

Thanks all

Frank

From rosuav at gmail.com  Wed Mar 25 02:24:52 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Wed, 25 Mar 2020 17:24:52 +1100
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <2470174a-ed7a-76eb-70d7-64c57ead6bfc@chagford.com>
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
 <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
 <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>
 
 <2470174a-ed7a-76eb-70d7-64c57ead6bfc@chagford.com>
Message-ID: 

On Wed, Mar 25, 2020 at 5:14 PM Frank Millman  wrote:
> My guess is that 3.7 is slower to send the files, so Edge starts up all
> 20 connections before it has finished receiving the first one, whereas
> with 3.8, by the time it has opened a few connections the first file has
> been received, so it tries to re-use the same connection to receive the
> next one. By then I have closed the connection. If I am right, it is
> surprising that my program worked *some* of the time.

That is definitely plausible. It would also mean that, depending on
exact browser settings, you might see the same problem crop up in
other situations. Definitely worth the time to investigate this one,
since you now know the ACTUAL reason and can solve the ACTUAL bug.

> It has been an interesting ride, and I have learned a lot. I will now
> look into fixing my program. The easy fix is to just send 'Connection:
> Close', but I will do it properly and implement 'Keep-Alive'.

Yep, and honestly, popping a quick "Connection: Close" isn't a
terrible solution. I have one app where I had a similar weird problem
with keep-alive, and made the opposite decision to you: rather than
sink in the hours to figure out the actual cause, I just slapped in a
"Connection: Close" and moved on. Part of the problem is that my issue
only shows up on HTTPS connections and not on plain HTTP ones, which
makes it extremely fiddly to wireshark (since all the traffic I care
about is encrypted, unless through some miracle the bug is visible
when it has no symptoms). But hey, that's what TODO files are for....

Thank you for including us on your debugging journey. To anyone else
out there with a bizarre problem, I recommend reading over this thread
to get an idea of how to get help - Frank demonstrated a willingness
to sink his own time into this, a comprehensive writeup of all useful
symptoms, and a truly interesting problem report.

ChrisA

From PythonList at DancesWithMice.info  Wed Mar 25 05:29:35 2020
From: PythonList at DancesWithMice.info (DL Neil)
Date: Wed, 25 Mar 2020 22:29:35 +1300
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 
 
 
Message-ID: 

On 25/03/20 11:57 AM, Chris Angelico wrote:
> On Wed, Mar 25, 2020 at 9:37 AM DL Neil via Python-list
>  wrote:
>>
>> As you observe, the problem with terminal emulators is the extent of
>> their emulation and the degree of adoption of their 'extended features'!
>>
>> My concern grows because of the need (I assume) for the URL to be
>> 'clickable', not merely 'complete' and 'unadorned' (no added hyphen
>> rendering it useless).
> 
> A complete URL is clickable. If I print out the string
> "https://example.com/" then it can be right-clicked and copied, or
> sent to a browser, or whatever. (Technically I don't need it to be
> "clickable", but the terminal emulator has to recognize it as a link.)
> FTR I'm using XFCE and xfce4-terminal, although I think everything
> applies to most of the popular terminal emulators.
> 
> The problem is that a long URL will wrap. So my options are:
> 
> 1) Let it wrap, violating the indentation
> 2) Break it, which stops it from being clickable
> 3) Get help from the terminal emulator
> 
>> Despite the almost-irresistible urge to prove that I'm a class-y guy
>> [albeit with a warped sense of humor], I'm warming to the 'partition'
>> suggestion:
>> - the output from textwrap.wrap() is a list of strings,
>> - we are talking about fixed-length lines denominated in characters,
>> - locating a[ll] URI (from a sub-set of schemes, eg "http", "https",
>> ...) is a well-worn path.
> 
> I'm not bothered too much by specific schemes. If a word matches the
> regex ^[a-z]+:// then I'll call it a URL.
> 
>> Thus (simplified to assume the presence of exactly one URI!!!):
>> - textwrap the first partition
>> - len( URI )
>> - it becomes trivial to ascertain if the URL might append the last line
>> (of the first 'wrapped' partition)
>> - failing that, the URI must start a new line (by defn)
>> - if it is 'too long', ie would be wrapped by textwrap, treat it separately,
>> - conversely, prepend the URI to the third partition,
>> - text-wrap the third partition,
>> - assemble the tweet-display.
>>
> 
> Hmm. So, basically, manual reimplementation of parts of textwrap. I'll
> hold that thought for later... if it's possible to just change the
> regex and keep the code unchanged, I'll prefer that, but this is a
> possibility. Thanks.


Thought I'd better buy-in some groceries before the country goes into 
lock-down at midnight, but this problem was amusing me whilst awaiting 
my turn to get into the store, to the check-out,...


1 what features does the terminal offer when a user 'clicks'?
Is it only applicable to URLs and linked to the web-browser within 
"Preferred Applications"? Are you able to 'grab' that click from the 
app? eg MOUSEDOWN*.

2 ultimately, you're on-a-hiding-to-nothing (apologies to 
non-English-English speakers: means 'no hope'!) given that URLs are 
defined by, but not length-limited by, RFC. Any 'limits' are applied by 
implementation/web-browser publishers. Currently in-use editions may 
vary widely, ie from 2K~64K. Any and all of which would blow terminal 
line-lengths right out-of-the-water.
(that was the thought nagging at the back of my mind earlier - but we've 
been talking about 'the terminal', ie outside of the limitations of a 
web-browser environment, so it was insufficiently assertive)


The usual work-around (which I thought was initially/largely motivated 
by the Tweet's 140-character limit) was to use a URL-shortener - gaining 
brevity at the expense of double-handling. In reality, as time has 
gone-by, various ones expressed concerns about (institutionalised) 
bit-rot and raise security issues ('what am I actually clicking on?').

There was actually a W3C "Working Group Note" that has been released 
into the public domain (a small surprise to me), detailing "Curie"-s. 
Sadly, as-yet I don't think any (major) web-browser offers an 
implementation. (mea culpa?) I seriously doubt that Gnome Terminal has 
implemented same/similar!


However, may we return to my earlier question: could the app trap a 
'click'? In which case, the app could store the actual-URI and provide 
its own Curie-like URL-shortening service, by substituting some 
(shorter!) 'click-here' text into the presentation. On the 
return-journey, in capturing the click, the app could substitute 
back-again before passing the full-length URI to the web-browser.

QED?
(smirk - Murphy meets "The best laid plans of mice and men...")


(apologies, I don't use Gnome - it didn't/doesn't offer the 
multi-display control/flexibility I require)


* I've been looking at edX's "Creative Coding" online course. It is 
aimed at artists and animators learning to code, and thus aims to make 
the computer draw (instead of counting dollars-and-cents, per the usual 
course-format). Sadly it is JavaScript-based (the p5.js library). Why do 
things the easy way? Nah! Instead, I've been investigating a 'corner' of 
Python with which I have had no contact to date. The Pygame library 
offers a drawing "canvas", hence it gaining my attention. Plus, without 
the complication of a full-fat GUI, (I think) it will present text AND 
allow keyboard and mouse-key trapping - all from the comfort and glory 
of a terminal-based Python program...

Have you ever poked into this dark corner of the pip-y-verse?
Would you like a PoC (I'll call it 'coursework')? (tomorrow)


Web.Refs:
https://www.w3.org/TR/2010/NOTE-curie-20101216/
https://www.pygame.org/docs (site under maintenance at this moment)
https://www.edx.org/course/creative-coding
-- 
Regards =dn

From arj.python at gmail.com  Wed Mar 25 05:54:05 2020
From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer)
Date: Wed, 25 Mar 2020 13:54:05 +0400
Subject: Open Source Maintainer Needed For Our Online Meetup
Message-ID: 

Greetings list,

The Python Mauritius User Group is having it's March meetup online.
https://www.meetup.com/MauritiusSoftwareCraftsmanshipCommunity/events/269598174/

We want to have two or more open source maintainers presenting their
projects (core comitters of any python package that's somewhat popular, in
fact we want a walkthrough of either the code base or use of the package it
matters not, no slides needed). Our meetup will be 3/4 hours long with
breaks in between as everybody is fidgeting at home. So, time is not a
problem.

We want to extend the presenters' invitation worldwide to cheer us up
during a period of double/complete lockdown in our country ^^_

Just reply, await your responses!

Else, at the said time on the link in the above meetup event anybody can
join, capacity is 250 presenters and 10k viewers

(info: since last night meetup.com added online location as an option)

Kind Regards,

Abdur-Rahmaan Janhangeer
compileralchemy.com  | github

Mauritius

From rosuav at gmail.com  Wed Mar 25 07:44:54 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Wed, 25 Mar 2020 22:44:54 +1100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 
 
 
 
Message-ID: 

On Wed, Mar 25, 2020 at 8:31 PM DL Neil via Python-list
 wrote:
> 1 what features does the terminal offer when a user 'clicks'?
> Is it only applicable to URLs and linked to the web-browser within
> "Preferred Applications"? Are you able to 'grab' that click from the
> app? eg MOUSEDOWN*.

In most terminal emulators, and certainly in xfce4-terminal, a URL can
be highlighted and right-clicked on.

Grabbing clicks IS possible, but that has other consequences, and is a
subject for a separate thread (which I may end up raising).

> 2 ultimately, you're on-a-hiding-to-nothing (apologies to
> non-English-English speakers: means 'no hope'!) given that URLs are
> defined by, but not length-limited by, RFC. Any 'limits' are applied by
> implementation/web-browser publishers. Currently in-use editions may
> vary widely, ie from 2K~64K. Any and all of which would blow terminal
> line-lengths right out-of-the-water.

Yeah, that part isn't too bad - what ends up happening is that the URL
doesn't get wrapped. It's not pretty but it's functional.

> However, may we return to my earlier question: could the app trap a
> 'click'? In which case, the app could store the actual-URI and provide
> its own Curie-like URL-shortening service, by substituting some
> (shorter!) 'click-here' text into the presentation. On the
> return-journey, in capturing the click, the app could substitute
> back-again before passing the full-length URI to the web-browser.

Yes, there are two ways that could be done: the hyperlink protocol,
which isn't supported in most terminal applications; or manually
handling all clicks, which quite possibly will end up being what
happens.

> * I've been looking at edX's "Creative Coding" online course. It is
> aimed at artists and animators learning to code, and thus aims to make
> the computer draw (instead of counting dollars-and-cents, per the usual
> course-format). Sadly it is JavaScript-based (the p5.js library). Why do
> things the easy way? Nah! Instead, I've been investigating a 'corner' of
> Python with which I have had no contact to date. The Pygame library
> offers a drawing "canvas", hence it gaining my attention. Plus, without
> the complication of a full-fat GUI, (I think) it will present text AND
> allow keyboard and mouse-key trapping - all from the comfort and glory
> of a terminal-based Python program...
>
> Have you ever poked into this dark corner of the pip-y-verse?
> Would you like a PoC (I'll call it 'coursework')? (tomorrow)
>

Never looked into that. I'm not really into art, sorry. (I once did a
ten-minute art jam on a topic of "video game characters", and my
chosen medium was... matplotlib. I'll let you guess at the details.)
Drawing's never been something I'm any good at.

ChrisA

From gisle.vanem at gmail.com  Wed Mar 25 08:13:42 2020
From: gisle.vanem at gmail.com (Gisle Vanem)
Date: Wed, 25 Mar 2020 13:13:42 +0100
Subject: How to create an Excel app that runs Python?
In-Reply-To: 
References: 
 
 
Message-ID: <1136859e-e558-86d6-e005-78b5a11adb0f@gmail.com>

Grant Edwards wrote:

> On 2020-03-24, oliver  wrote:
> 
>> Use the win32com library to interact with Excel via COM.
> 
> Huh?  I thought that the users have no way of running a local Python
> app.

Maybe creating a self-contained .exe using PyInstaller?
For me, this:
   pyinstaller.exe --noconfirm --console --onefile file.py

creates a 'dist/file.exe' that depend on nothing but
system libraries. But it's 5 MByte though.


-- 
--gv

From farayao.ds at gmail.com  Wed Mar 25 10:21:56 2020
From: farayao.ds at gmail.com (farayao.ds at gmail.com)
Date: Wed, 25 Mar 2020 07:21:56 -0700 (PDT)
Subject: How to create an Excel app that runs Python?
In-Reply-To: 
References: 
 
 
 
Message-ID: 

On Tuesday, 24 March 2020 17:38:11 UTC, Paolo G. Cantore  wrote:
> On Tue, Mar 24, 2020, 4:45 PM  wrote:
> 
> > I have the following scenario:
> >
> > I have created lots of python files that I use to calculate a Cashflow
> > model, when I run these files I get a beautiful pandas DataFrame that
> > contains my final model. My mission is to show this table to the rest of
> > the company in a friendly format ("Excel") and they need to be able to
> > generate this table themselves from Excel, using the Python script I
> > created ("the idea is that they open an excel file that has some type of
> > dashboard and a form that they need to fill in, once they fill it in and
> > press "Go" or "Run" or something like that, these parameters will be sent
> > to the Python script to generate this final pandas DataFrame. Finally this
> > DataFrame needs to be displayed/pasted in the Excel sheet that they
> > initially opened)
> >
> >
> > The problems:
> >
> > The company needs to be able to run this model, but the users, apart from
> > me, use Excel and they can't open up a Jupyter notebook or VSC to run the
> > code. They can't even install Python on their machines (or at least that is
> > not ideal)
> >
> >
> > My Attempts:
> >
> > I am currently using "xlwings" to run Python within Excel, although it
> > requires that the user has Python and xlwings installed and has added the
> > xlwings "Addin", which is not an ideal solution at all.
> >
> > I am thinking about using Dash, I don't know if it is what I need since I
> > haven't looked into it that much yet (I have been trying to make it work on
> > xlwings first)
> >
> >
> >
> > If you have any suggestions on how to do this, I would really appreciate
> > that.
> >
> > Thank you
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> The scenario you describe should be fulfilled by a web application.
> 
> I'm sure your users are also able to use a browser, not only Excel.
> 
> The HTML forms management offers the GUI capabilities to enter the 
> parameters. The processing steps could be as follows:
> 
> 1. Enter the url for the application in question and display the form.
> 2. Enter the needed data in the form.
> 3. Process the data (with lots of your python scripts) and show the 
> result in the browser.
> 4. If all is ok, download the data sheet in Excel format (using 
> DataFrame.to_excel)

Hello Paolo,

Thanks for your reply, indeed now I'm thinking on building a web app, do you have any suggestions for this? I am thinking of using Tkinter, the method that you describe using HTML is also using Javascript?

Kind Regards
Felipe

From farayao.ds at gmail.com  Wed Mar 25 10:22:45 2020
From: farayao.ds at gmail.com (farayao.ds at gmail.com)
Date: Wed, 25 Mar 2020 07:22:45 -0700 (PDT)
Subject: How to create an Excel app that runs Python?
In-Reply-To: 
References: 
 
 
Message-ID: 

On Tuesday, 24 March 2020 16:12:00 UTC, Souvik Dutta  wrote:
> You might try pyqt5 if you want to make a custom GUI and also if you have
> tha time to do so.
> 
> On Tue, Mar 24, 2020, 4:45 PM  wrote:
> 
> > I have the following scenario:
> >
> > I have created lots of python files that I use to calculate a Cashflow
> > model, when I run these files I get a beautiful pandas DataFrame that
> > contains my final model. My mission is to show this table to the rest of
> > the company in a friendly format ("Excel") and they need to be able to
> > generate this table themselves from Excel, using the Python script I
> > created ("the idea is that they open an excel file that has some type of
> > dashboard and a form that they need to fill in, once they fill it in and
> > press "Go" or "Run" or something like that, these parameters will be sent
> > to the Python script to generate this final pandas DataFrame. Finally this
> > DataFrame needs to be displayed/pasted in the Excel sheet that they
> > initially opened)
> >
> >
> > The problems:
> >
> > The company needs to be able to run this model, but the users, apart from
> > me, use Excel and they can't open up a Jupyter notebook or VSC to run the
> > code. They can't even install Python on their machines (or at least that is
> > not ideal)
> >
> >
> > My Attempts:
> >
> > I am currently using "xlwings" to run Python within Excel, although it
> > requires that the user has Python and xlwings installed and has added the
> > xlwings "Addin", which is not an ideal solution at all.
> >
> > I am thinking about using Dash, I don't know if it is what I need since I
> > haven't looked into it that much yet (I have been trying to make it work on
> > xlwings first)
> >
> >
> >
> > If you have any suggestions on how to do this, I would really appreciate
> > that.
> >
> > Thank you
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >

Thank Souvik,

I will check that library out, anything special about that library in particular?


From farayao.ds at gmail.com  Wed Mar 25 10:24:22 2020
From: farayao.ds at gmail.com (farayao.ds at gmail.com)
Date: Wed, 25 Mar 2020 07:24:22 -0700 (PDT)
Subject: How to create an Excel app that runs Python?
In-Reply-To: 
References: 
 
 
Message-ID: <0863cfa3-0b8a-44c3-893e-4275aa02a8b3@googlegroups.com>

On Tuesday, 24 March 2020 16:26:53 UTC, oliver  wrote:
> Use the win32com library to interact with Excel via COM. Although the
> learning curve is a little steeper it's not too bad and works great. I used
> this technique to control ARENA with Python through its COM API to run a
> whack of simulations (1000-10000), then used python to gather the results,
> and used win32com from python to finally inject the data into Excel and get
> it to generate charts and tables that could be used by stakeholders without
> access to python.
> 
> Oliver Schoenborn
>   || Cloud Application Engineer, Owner || Sentian Cloud Computing Inc.
>   || Ottawa, ON, Canada || +1-613-552-4466 (mobile)
>   || oliver at sentianSE.com
> 
> 
> 
> 
> On Tue, Mar 24, 2020 at 7:16 AM  wrote:
> 
> > I have the following scenario:
> >
> > I have created lots of python files that I use to calculate a Cashflow
> > model, when I run these files I get a beautiful pandas DataFrame that
> > contains my final model. My mission is to show this table to the rest of
> > the company in a friendly format ("Excel") and they need to be able to
> > generate this table themselves from Excel, using the Python script I
> > created ("the idea is that they open an excel file that has some type of
> > dashboard and a form that they need to fill in, once they fill it in and
> > press "Go" or "Run" or something like that, these parameters will be sent
> > to the Python script to generate this final pandas DataFrame. Finally this
> > DataFrame needs to be displayed/pasted in the Excel sheet that they
> > initially opened)
> >
> >
> > The problems:
> >
> > The company needs to be able to run this model, but the users, apart from
> > me, use Excel and they can't open up a Jupyter notebook or VSC to run the
> > code. They can't even install Python on their machines (or at least that is
> > not ideal)
> >
> >
> > My Attempts:
> >
> > I am currently using "xlwings" to run Python within Excel, although it
> > requires that the user has Python and xlwings installed and has added the
> > xlwings "Addin", which is not an ideal solution at all.
> >
> > I am thinking about using Dash, I don't know if it is what I need since I
> > haven't looked into it that much yet (I have been trying to make it work on
> > xlwings first)
> >
> >
> >
> > If you have any suggestions on how to do this, I would really appreciate
> > that.
> >
> > Thank you
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >

Hello Oliver,

Thank for your answer, it sounds like a very sophisticated method, which is good, although I don't know what you mean when you refer to COM. What is good about the win32com library in particular?

Thanks!

From farayao.ds at gmail.com  Wed Mar 25 10:25:53 2020
From: farayao.ds at gmail.com (farayao.ds at gmail.com)
Date: Wed, 25 Mar 2020 07:25:53 -0700 (PDT)
Subject: How to create an Excel app that runs Python?
In-Reply-To: 
References: 
 
  <1136859e-e558-86d6-e005-78b5a11adb0f@gmail.com>
 
Message-ID: <1c403863-6b79-4184-a3fa-9fabef397b5b@googlegroups.com>

On Wednesday, 25 March 2020 12:13:58 UTC, Gisle Vanem  wrote:
> Grant Edwards wrote:
> 
> > On 2020-03-24, oliver  wrote:
> > 
> >> Use the win32com library to interact with Excel via COM.
> > 
> > Huh?  I thought that the users have no way of running a local Python
> > app.
> 
> Maybe creating a self-contained .exe using PyInstaller?
> For me, this:
>    pyinstaller.exe --noconfirm --console --onefile file.py
> 
> creates a 'dist/file.exe' that depend on nothing but
> system libraries. But it's 5 MByte though.
> 
> 
> -- 
> --gv

Hello Gisle,

Thanks for your answer. To do this I assume that first I need to create an app with Tkinter or can I just do this .exe simply with the multiple files I already have?

Thanks!

From barry at barrys-emacs.org  Wed Mar 25 10:31:13 2020
From: barry at barrys-emacs.org (Barry Scott)
Date: Wed, 25 Mar 2020 14:31:13 +0000
Subject: Intermittent bug with asyncio and MS Edge
In-Reply-To: <2470174a-ed7a-76eb-70d7-64c57ead6bfc@chagford.com>
References: 
 <48354CBF-D4CD-4120-B332-77D45CCF1297@barrys-emacs.org>
 
 
 <2abb19db-bb30-f622-bba7-9a24f72895a1@chagford.com>
 
 
 
 <1b103594-11b4-4e51-9cce-eee0bf9dc958@chagford.com>
 <2ef80495-ae46-dad6-b935-daba82d957c4@chagford.com>
 
 <2470174a-ed7a-76eb-70d7-64c57ead6bfc@chagford.com>
Message-ID: <281FC6FE-78CC-4CFF-8CD0-657CB236CC4F@barrys-emacs.org>



> On 25 Mar 2020, at 06:12, Frank Millman  wrote:
> 
> On 2020-03-24 8:39 PM, Barry Scott wrote:
>>> On 24 Mar 2020, at 11:54, Frank Millman  wrote:
>>> 
>>> 
>>> I decided to concentrate on using Wireshark to detect the difference between a Python3.7 session and a Python3.8 session. Already I can see some differences.
>>> 
>>> There is only one version of my program. I am simply running it with either 'py -3.7 ' or 'py -3.8'. And I am ignoring Chrome at this stage, as it is only that Edge shows the problem.
>>> 
>>> First point - Python3.7 also shows a lot of [RST, ACK] lines. My guess is that this is caused by my 'protocol violation' of sending a 'Keep-Alive' header and then closing the connection. Python3.7 does not suffer from dropping files, so I now think this is a sidetrack. I will fix my program when this is all over, but for now I don't want to touch it.
>> Yes your protocol violation is why you see [RST, ACK].
>> I'm confused you know that the code has a critical bug in it and you have not fixed it?
>> Just send "Connection: close" and I'd assume all will work.
> 
> Well, the reason is simply that I wanted to understand why my code that worked all the way from 3.4 through 3.7 stopped working in 3.8. I realise that my code is faulty, but I still wanted to know what the trigger was that caused the bug to appear.

Got it, I'd not picked up on you wishes to find the details of why.

> 
> From my testing with Wireshark, I can see that both Edge and Chrome create 20 connections to GET 20 files. The difference seems to be that Chrome does not attempt to re-use a connection, even though both client and server have sent Keep-Alive headers. Edge does attempt to re-use the connection.

Chrome will reuse the connections if you load enough files from the same server.
All browser do this to get a page displayed as fast as possible.
Because HTTP is half-duplex its the round trip time rather then bandwidth that controls
the time taken get all the asserts needed to render a page most of the time.

> 
> The difference between 3.7 and 3.8 is that 3.7 sends the data in separate packets for the status, each header, and then each chunk, whereas 3.8 sends the whole lot in a single packet.

That will change the timing enough to expose the problem.

I often find with network code bugs that its changes that makes the
timing different that expos bugs in supposed tested and working code.

In this case you could track down what was the cause, but it's often the case that it's not practical to do that.
You may not know what changed between when the code worked and when it broke in many cases.

> My guess is that 3.7 is slower to send the files, so Edge starts up all 20 connections before it has finished receiving the first one, whereas with 3.8, by the time it has opened a few connections the first file has been received, so it tries to re-use the same connection to receive the next one. By then I have closed the connection. If I am right, it is surprising that my program worked *some* of the time.

I have lost count of the number of times when we have found a bug in some code that we say "how did it ever work?".

> 
> The same reasoning would explain why it worked when connecting from a remote host. There would be enough delay to force it into the same behaviour as 3.7.

Yep and if there are any middle boxes, routers, man-in-middle-proxies, etc the timing/packets get pushed around.

> 
> It has been an interesting ride, and I have learned a lot. I will now look into fixing my program. The easy fix is to just send 'Connection: Close', but I will do it properly and implement 'Keep-Alive'.

Barry

> 
> Thanks all
> 
> Frank
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 


From souvik.viksou at gmail.com  Wed Mar 25 11:06:23 2020
From: souvik.viksou at gmail.com (Souvik Dutta)
Date: Wed, 25 Mar 2020 20:36:23 +0530
Subject: How to create an Excel app that runs Python?
In-Reply-To: 
References: 
 
 
 
Message-ID: 

It is better than tkinter and also kivy in some way. It uses pure oops
concept so it should be more intuitive and easy to set up. I learnt it in 7
days. Also it has still better community support at
pyqt at riverbankcomputing.com

On Wed, Mar 25, 2020, 7:59 PM  wrote:

> On Tuesday, 24 March 2020 16:12:00 UTC, Souvik Dutta  wrote:
> > You might try pyqt5 if you want to make a custom GUI and also if you have
> > tha time to do so.
> >
> > On Tue, Mar 24, 2020, 4:45 PM  wrote:
> >
> > > I have the following scenario:
> > >
> > > I have created lots of python files that I use to calculate a Cashflow
> > > model, when I run these files I get a beautiful pandas DataFrame that
> > > contains my final model. My mission is to show this table to the rest
> of
> > > the company in a friendly format ("Excel") and they need to be able to
> > > generate this table themselves from Excel, using the Python script I
> > > created ("the idea is that they open an excel file that has some type
> of
> > > dashboard and a form that they need to fill in, once they fill it in
> and
> > > press "Go" or "Run" or something like that, these parameters will be
> sent
> > > to the Python script to generate this final pandas DataFrame. Finally
> this
> > > DataFrame needs to be displayed/pasted in the Excel sheet that they
> > > initially opened)
> > >
> > >
> > > The problems:
> > >
> > > The company needs to be able to run this model, but the users, apart
> from
> > > me, use Excel and they can't open up a Jupyter notebook or VSC to run
> the
> > > code. They can't even install Python on their machines (or at least
> that is
> > > not ideal)
> > >
> > >
> > > My Attempts:
> > >
> > > I am currently using "xlwings" to run Python within Excel, although it
> > > requires that the user has Python and xlwings installed and has added
> the
> > > xlwings "Addin", which is not an ideal solution at all.
> > >
> > > I am thinking about using Dash, I don't know if it is what I need
> since I
> > > haven't looked into it that much yet (I have been trying to make it
> work on
> > > xlwings first)
> > >
> > >
> > >
> > > If you have any suggestions on how to do this, I would really
> appreciate
> > > that.
> > >
> > > Thank you
> > > --
> > > https://mail.python.org/mailman/listinfo/python-list
> > >
>
> Thank Souvik,
>
> I will check that library out, anything special about that library in
> particular?
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From hjp-python at hjp.at  Wed Mar 25 15:33:25 2020
From: hjp-python at hjp.at (Peter J. Holzer)
Date: Wed, 25 Mar 2020 20:33:25 +0100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
Message-ID: <20200325193325.GA32573@hjp.at>

On 2020-03-23 06:00:41 +1100, Chris Angelico wrote:
> Second point, and related to the above. The regex that defines break
> points, as found in the source code, is:
> 
> wordsep_re = re.compile(r'''
>         ( # any whitespace
>           %(ws)s+
>         | # em-dash between words
>           (?<=%(wp)s) -{2,} (?=\w)
>         | # word, possibly hyphenated
>           %(nws)s+? (?:
>             # hyphenated word
>               -(?: (?<=%(lt)s{2}-) | (?<=%(lt)s-%(lt)s-))
>               (?= %(lt)s -? %(lt)s)
>             | # end of word
>               (?=%(ws)s|\Z)
>             | # em-dash
>               (?<=%(wp)s) (?=-{2,}\w)
>             )
>         )''' % {'wp': word_punct, 'lt': letter,
>                 'ws': whitespace, 'nws': nowhitespace},
> 
> It's built primarily out of small matches with long assertions, eg
> "match a hyphen, as long as it's preceded by two letters or a letter
> and a hyphen".

Do you need that fancy logic? Could you only break on white-space
instead? It won't wrap "tetrabromo-phenolsulfonephthalein" in that case
but since you mentioned its for a twitter client, most users probably
won't mind (and those who do mind will probably insist that the
algorithm should be able to split it into tetrabromo-phenolsulfone-
phthalein, if that's where the line end is, as it was here purely by
lucky accident). A regexp for whitespace is pretty simple.

        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  Wed Mar 25 15:52:53 2020
From: hjp-python at hjp.at (Peter J. Holzer)
Date: Wed, 25 Mar 2020 20:52:53 +0100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
Message-ID: <20200325195253.GB32573@hjp.at>

On 2020-03-25 10:02:50 +1300, DL Neil via Python-list wrote:
> Today it feels like an anachronism because it is comes from the era of
> fixed-width fonts and line-lengths denominated in characters*. The issue is
> that it was designed to re-define 'white space' and to enable the conversion
> of text 'wrapped' in one (fixed) format, to suit another. With the
> arrival?predominance of proportional-width fonts, the skills of hyphenation
> have started to go the way of cursive hand-writing

That sounds like a non-sequitur to me. Books have always[1] used pro-
portional fonts and of course hand-writing is proportional, too. Both
use hyphenation. Fixed width fonts were only used by typewriters and
later character based terminals and printers. They waned after bitmapped
GUIs and printers became common.

If anything, I think it was fixed-width fonts which contributed to the
decline of hyphenation: With a fixed-width font you can't get a proper
justification anyway, and if your right margin is ragged, hyphenation is
much less important (at least in English, were most words are short -
it's different in German). And given that hyphenation is a really hard
problem even for a single language, it is not very surprising that most
programs don't even try.

        hp

[1] Except for a few textbooks from the early 1980s which hit the narrow
    window between "I have a computer so I don't need a professional
    typesetter" and "My computer now has proportional fonts").


-- 
   _  | 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 rshepard at appl-ecosys.com  Wed Mar 25 16:09:18 2020
From: rshepard at appl-ecosys.com (Rich Shepard)
Date: Wed, 25 Mar 2020 13:09:18 -0700 (PDT)
Subject: Module import best practice
Message-ID: 

I'm writing an application using Python3 and Tkinter. The views/ directory
contain multiple modules, including one called commonDlgs.py. This contains
classes (such as those for validating data entry) used by all the data entry
views. Some classes in commonDlgs imports other modules.

My question is whether to import into each view class those modules needed
by it or import all supporting modules at the top of commonDlgs.py, then
import that module in each view with:

from . import commonDlgs as cd

rather than importing specific classes in each view module?

Rich

From Richard at Damon-Family.org  Wed Mar 25 16:09:24 2020
From: Richard at Damon-Family.org (Richard Damon)
Date: Wed, 25 Mar 2020 16:09:24 -0400
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: <20200325195253.GB32573@hjp.at>
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
Message-ID: <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>

On 3/25/20 3:52 PM, Peter J. Holzer wrote:
> On 2020-03-25 10:02:50 +1300, DL Neil via Python-list wrote:
>> Today it feels like an anachronism because it is comes from the era of
>> fixed-width fonts and line-lengths denominated in characters*. The issue is
>> that it was designed to re-define 'white space' and to enable the conversion
>> of text 'wrapped' in one (fixed) format, to suit another. With the
>> arrival?predominance of proportional-width fonts, the skills of hyphenation
>> have started to go the way of cursive hand-writing
> That sounds like a non-sequitur to me. Books have always[1] used pro-
> portional fonts and of course hand-writing is proportional, too. Both
> use hyphenation. Fixed width fonts were only used by typewriters and
> later character based terminals and printers. They waned after bitmapped
> GUIs and printers became common.
>
> If anything, I think it was fixed-width fonts which contributed to the
> decline of hyphenation: With a fixed-width font you can't get a proper
> justification anyway, and if your right margin is ragged, hyphenation is
> much less important (at least in English, were most words are short -
> it's different in German). And given that hyphenation is a really hard
> problem even for a single language, it is not very surprising that most
> programs don't even try.
>
>         hp
>
> [1] Except for a few textbooks from the early 1980s which hit the narrow
>     window between "I have a computer so I don't need a professional
>     typesetter" and "My computer now has proportional fonts").

Actually, fixed width fonts are easy to justify, you just add additional 
space between words through the line. The varying spaces between words can 
be a bit annoying, but it was done. My thought is that variable width fonts
tend to put more characters per inch. and with wider screens we are no longer
trying as hard to keep to less than 80 characters per line (or less with margins),
so with micros-spacing justification the larger variance in natural line width isn't
as noticable.






-- 
Richard Damon


From rosuav at gmail.com  Wed Mar 25 16:11:46 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Thu, 26 Mar 2020 07:11:46 +1100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: <20200325193325.GA32573@hjp.at>
References: 
 <20200325193325.GA32573@hjp.at>
Message-ID: 

On Thu, Mar 26, 2020 at 6:34 AM Peter J. Holzer  wrote:
>
> On 2020-03-23 06:00:41 +1100, Chris Angelico wrote:
> > Second point, and related to the above. The regex that defines break
> > points, as found in the source code, is:
> >
> > wordsep_re = re.compile(r'''
> >         ( # any whitespace
> >           %(ws)s+
> >         | # em-dash between words
> >           (?<=%(wp)s) -{2,} (?=\w)
> >         | # word, possibly hyphenated
> >           %(nws)s+? (?:
> >             # hyphenated word
> >               -(?: (?<=%(lt)s{2}-) | (?<=%(lt)s-%(lt)s-))
> >               (?= %(lt)s -? %(lt)s)
> >             | # end of word
> >               (?=%(ws)s|\Z)
> >             | # em-dash
> >               (?<=%(wp)s) (?=-{2,}\w)
> >             )
> >         )''' % {'wp': word_punct, 'lt': letter,
> >                 'ws': whitespace, 'nws': nowhitespace},
> >
> > It's built primarily out of small matches with long assertions, eg
> > "match a hyphen, as long as it's preceded by two letters or a letter
> > and a hyphen".
>
> Do you need that fancy logic? Could you only break on white-space
> instead? It won't wrap "tetrabromo-phenolsulfonephthalein" in that case
> but since you mentioned its for a twitter client, most users probably
> won't mind (and those who do mind will probably insist that the
> algorithm should be able to split it into tetrabromo-phenolsulfone-
> phthalein, if that's where the line end is, as it was here purely by
> lucky accident). A regexp for whitespace is pretty simple.
>

If I *just* want to break on whitespace, I can do that (set both flags
to False, off it goes). And in fact, that's what I've done so far, and
it's working reasonably well. But I was hoping to be more flexible
than that.

ChrisA

From vlastimil.brom at gmail.com  Wed Mar 25 16:25:15 2020
From: vlastimil.brom at gmail.com (Vlastimil Brom)
Date: Wed, 25 Mar 2020 21:25:15 +0100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
Message-ID: 

22. 3. 2020 v 20:02 Chris Angelico :
>
> When using textwrap.fill() or friends, setting break_long_words=False
> without also setting break_on_hyphens=False has the very strange
> behaviour that a long hyphenated word will still be wrapped. I
> discovered this as a very surprising result when trying to wrap a
> paragraph that contained a URL, and wanting the URL to be kept
> unchanged:
> [...]
>
> Second point, and related to the above. The regex that defines break
> points, as found in the source code, is:
>
> wordsep_re = re.compile(r'''
>         ( # any whitespace
>           %(ws)s+
>         | # em-dash between words
>           (?<=%(wp)s) -{2,} (?=\w)
>         | # word, possibly hyphenated
>           %(nws)s+? (?:
>             # hyphenated word
>               -(?: (?<=%(lt)s{2}-) | (?<=%(lt)s-%(lt)s-))
>               (?= %(lt)s -? %(lt)s)
>             | # end of word
>               (?=%(ws)s|\Z)
>             | # em-dash
>               (?<=%(wp)s) (?=-{2,}\w)
>             )
>         )''' % {'wp': word_punct, 'lt': letter,
>                 'ws': whitespace, 'nws': nowhitespace},
>
> It's built primarily out of small matches with long assertions, eg
> "match a hyphen, as long as it's preceded by two letters or a letter
> and a hyphen". What I want to do is create a *negative* assertion:
> specifically, to disallow any breaking between "\b[a-z]+://" and "\b",
> which will mean that a URL will never be broken ("https://.........."
> until the next whitespace boundary). Regex assertions of this form
> have to be fixed lengths, though, so as described, this isn't
> possible. Regexperts, any ideas? How can I modify this to never break
> inside a URL?
> [...]
>
> ChrisA
>
Hi,
I might be missing something obvious, but it seems to me, that the
regex library might help with regard to your originally presented
approach:
https://pypi.org/project/regex/
https://bitbucket.org/mrabarnett/mrab-regex/

It supports variable-length lookaround assertions (beyond many other
extra features);
You could make textwrap or other code use it with a tweaked regex pattern.
However, I can't say whether it is sufficient in order to achieve the
needed functionality.

Regards,
         vbr

From xiangchnchn at gmail.com  Thu Mar 26 12:06:43 2020
From: xiangchnchn at gmail.com (Chengcheng Xiang)
Date: Thu, 26 Mar 2020 09:06:43 -0700 (PDT)
Subject: Profiler showing path dependency?
In-Reply-To: 
References: 
 
Message-ID: 

Hi,

Our tool can help with this: https://github.com/devopspp/pyliveupdate/blob/master/README.md#profiler. It can output a flamegraph and a per-path call summary. Feel free to check it out and let me know if there is any questions.

-CC

On Friday, March 13, 2020 at 4:52:51 PM UTC-7, Go Luhng wrote:
> Consider a simple call graph: `main()` calls `foo()`, which calls
> `bar()`. Then `main()` calls `qux()` which also calls `bar()`, but
> with different parameters.
> 
> When you run the above through cProfile and view the result in
> SnakeViz, you will see `main()` calling `foo()` and `qux()`, with each
> of them calling `bar()`. However, if you hover or click on `bar()`,
> you will see the global aggregate statistics for it. For example, the
> number of times it has been called, and their total time cost.
> 
> Is there a way to get a path-dependent profiler breakdown for `bar()`?
>  Specifically for this example, statistics for when it is called by
> `foo()`, and separately statistics for when it is called by `qux()`.

From rshepard at appl-ecosys.com  Thu Mar 26 14:07:37 2020
From: rshepard at appl-ecosys.com (Rich Shepard)
Date: Thu, 26 Mar 2020 11:07:37 -0700 (PDT)
Subject: Module import best practice
In-Reply-To: 
References: 
 
Message-ID: 

On Thu, 26 Mar 2020, Schachner, Joseph wrote:

> I can only tell you my preference. I prefer that Python modules be as
> self-contained as possible, because "global" is within a module; to share
> between modules you have to import something, as you know.

Joseph,

This makes good sense. I don't know that I'll end up with a chain of
namespaces, but I should avoid that possiility.

If I understand your reasoning, within commonDlg.py I should import required
modules for each class and not all of them at the beginning of the file. And
each module that uses classes from commonDlgs should include 'from commonDlg
import ...' only the classes it needs, even when there are several (but not
all commonDlg classes).

Is this correct?

Many thanks,

Rich


From hjp-python at hjp.at  Thu Mar 26 15:08:14 2020
From: hjp-python at hjp.at (Peter J. Holzer)
Date: Thu, 26 Mar 2020 20:08:14 +0100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
Message-ID: <20200326190814.GA2122@hjp.at>

On 2020-03-25 16:09:24 -0400, Richard Damon wrote:
> On 3/25/20 3:52 PM, Peter J. Holzer wrote:
> > If anything, I think it was fixed-width fonts which contributed to the
> > decline of hyphenation: With a fixed-width font you can't get a proper
> > justification anyway, and if your right margin is ragged, hyphenation is
> > much less important
> 
> Actually, fixed width fonts are easy to justify, you just add additional 
> space between words through the line.

Yes. It's easy to do it wrong and impossible to do it right :-)

(BTDT)

The problem is that you can only insert an integral number of spaces und
the number of spaces you need to insert is rarely a multiple of the
number of gaps between words. So you get uneven spacing, which looks
horrible.

        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 grant.b.edwards at gmail.com  Thu Mar 26 15:20:47 2020
From: grant.b.edwards at gmail.com (Grant Edwards)
Date: Thu, 26 Mar 2020 19:20:47 -0000 (UTC)
Subject: Confusing textwrap parameters, and request for RE help
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
 <20200326190814.GA2122@hjp.at>
Message-ID: 

On 2020-03-26, Peter J. Holzer  wrote:
>> Actually, fixed width fonts are easy to justify, you just add additional 
>> space between words through the line.
>
> Yes. It's easy to do it wrong and impossible to do it right :-)
>
> (BTDT)
>
> The problem is that you can only insert an integral number of spaces und
> the number of spaces you need to insert is rarely a multiple of the
> number of gaps between words. So you get uneven spacing, which looks
> horrible.

That was always an interesting freshman programming homework
problem. But you're right, nobody in their right mind would actually
want to generate real output that way.  Ragged-right is far, far
better than using fixed-width font justified with extra spaces
scattered in.

--
Grant




From Richard at Damon-Family.org  Thu Mar 26 15:33:57 2020
From: Richard at Damon-Family.org (Richard Damon)
Date: Thu, 26 Mar 2020 15:33:57 -0400
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
 <20200326190814.GA2122@hjp.at> 
Message-ID: 

On 3/26/20 3:20 PM, Grant Edwards wrote:
> On 2020-03-26, Peter J. Holzer  wrote:
>>> Actually, fixed width fonts are easy to justify, you just add additional 
>>> space between words through the line.
>> Yes. It's easy to do it wrong and impossible to do it right :-)
>>
>> (BTDT)
>>
>> The problem is that you can only insert an integral number of spaces und
>> the number of spaces you need to insert is rarely a multiple of the
>> number of gaps between words. So you get uneven spacing, which looks
>> horrible.
> That was always an interesting freshman programming homework
> problem. But you're right, nobody in their right mind would actually
> want to generate real output that way.  Ragged-right is far, far
> better than using fixed-width font justified with extra spaces
> scattered in.
>
> --
> Grant
>
>
>
Back in the day it was FREQUENTLY done, in part to show off, anyone
could type with a typewriter and get jagged right margins, but with a
computer you could get justified margins with uneven internal spacing!!
Status!

-- 
Richard Damon


From grant.b.edwards at gmail.com  Thu Mar 26 16:30:35 2020
From: grant.b.edwards at gmail.com (Grant Edwards)
Date: Thu, 26 Mar 2020 20:30:35 -0000 (UTC)
Subject: Confusing textwrap parameters, and request for RE help
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
 <20200326190814.GA2122@hjp.at> 
 
Message-ID: 

On 2020-03-26, Richard Damon  wrote:

>> [...] nobody in their right mind would actually
>> want to generate real output that way.
>
> Back in the day it was FREQUENTLY done, in part to show off, anyone
> could type with a typewriter and get jagged right margins, but with a
> computer you could get justified margins with uneven internal spacing!!
> Status!

It would have been better phrased "nobody _should_ actually want to".

Sure, it was fun _producing_ output like that. But for anybody who had
to read it, the novelty wore off pretty quickly. After few lines it
was just annoying.  Most of us don't need any help making our writing
even more annoying.

--
Grant



From PythonList at DancesWithMice.info  Thu Mar 26 16:46:36 2020
From: PythonList at DancesWithMice.info (DL Neil)
Date: Fri, 27 Mar 2020 09:46:36 +1300
Subject: Module import best practice
In-Reply-To: 
References: 
Message-ID: <97851394-ac00-3904-b5af-0a10329b1283@DancesWithMice.info>

Rich,


On 26/03/20 9:09 AM, Rich Shepard wrote:
> I'm writing an application using Python3 and Tkinter. The views/ directory
> contain multiple modules, including one called commonDlgs.py. This contains
> classes (such as those for validating data entry) used by all the data 
> entry
> views. Some classes in commonDlgs imports other modules.
> 
> My question is whether to import into each view class those modules needed
> by it or import all supporting modules at the top of commonDlgs.py, then
> import that module in each view with:
> 
> from . import commonDlgs as cd
> 
> rather than importing specific classes in each view module?


My personal approach is to follow 'the Zen of Python' and prefer 
"explicit" over "implicit".
(it helps beginners, as well as us old-fogies whose minds cannot retain 
things for very long)

I see little point in importing 'stuff' that's not used. On the other 
hand, if that becomes the criteria for splitting one's code-base into 
ever more modules, likely it will cause more trouble than good. Plus if 
a module contains two classes but you only import one, the entire class 
is imported anyway - so, it's not like you're saving CPU-time or 
storage-space!

As you've probably realised by now, there is a 'happy medium', but it's 
impossible to lay down a 'law'. It's probably one of those 'feelings' 
that comes with experience - and the only way you can gain experience is...

Another problem with trying to gain such experience, is that Python has 
changed. You have demonstrated a "relative import". Its introduction 
(and the importlib, and "packages") opened-up a whole new vista* of 
opportunities), but much of the material available on-the-web pre-dates 
this.
* Microsoft-ies may be confused by the real meaning of this word.


Aside from the drudge of typing, there are two (main) potential issues 
to be considered - and hopefully avoided: proliferation and circular 
references.


Proliferation:

My mother-in-law had five kids. At first, it worried me that in trying 
to attract my attention, she would 'pop the list' - in her confusion, 
calling out each of her kids' names in-turn, before she happened upon mine.
(especially given that most of them were/are girls!)

There seem to be a large-ish number of classes and modules to manage. 
The more of these you have, the harder it is to keep track of 
which-is-where. That said, if you have a multiplicity of classes and try 
to group them into fewer modules, the problem may not go away; unless 
you are able to group them by function, theme, or stage/part of the 
system in which they are used.

When faced with my mother-in-law's problem, many people resort to a 
tactic such as calling-out "hey you" [varies by culture and language]. 
Python has a similar facility! You can turn your "views/ directory" 
(which presumably contains a number of modules) into a "package".

Remember the __init__.py file (the "file" not the similarly-named object 
instantiation method!) which is normally an empty, useless-looking 
appendage? [no comments about my head, please!] This can be populated 
with a list of moduleNMs (etc), thus creating a grouping-effect, 
shortening the import process, and lightening your cognitive- and 
management-loads.


Circular references:

If you have a bunch of import-able modules which in-turn import other 
modules, it is possible to become a dog chasing its own tail. [this is 
loads of fun, until your teeth sink firmly into said tail. Yow, ouch! 
(I'm told, er, by a friend - you must understand?) ]

If there is module "fred.py" and it calls a class in "barney.py" but 
barney can't do anything without advice from "wilma.py", then that is 
all fine and can become the bed-rock of your program [sorry!].

However, if wilma needs to first confirm with "betty.py", who like any 
responsible wife goes to fred and asks "What are you up-to now, Fred?", 
fred will make excuses and blame barney, who in-turn will call for help 
and understanding from betty, who will want to put her head together 
with wilma's to decide how best to sort-out their men-folk, and...

Are you confused yet? So would the Python interpreter be, giving-up and 
throwing such code all over the floor!

Accordingly, you must design and manage the structure of your 
application - classes and modules should be encouraged not to gossip 
amongst themselves. The ComSc terms here include: "encapsulation", 
"coupling" and "cohesion", and because this is another area where ONE 
precise answer for the general case does not exist, the 
counter-considerations of such are "decoupling" and "the Law of Demeter"...

Once again, read carefully because many ComSc-level web.refs will 
concern themselves with language-related matters, which may not apply in 
Python!


Hoping this non-answer helps, by leaving you with reading topics which 
will realise advice for the concerns you had/hadn't noted to-date.


Now, it's time to get back to the (salt-)mines, if we expect to put 
(dino-)steaks on the table tonight...
[https://www.youtube.com/watch?v=2s13X66BFd8]
-- 
Regards =dn

From rosuav at gmail.com  Thu Mar 26 16:50:04 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Fri, 27 Mar 2020 07:50:04 +1100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
 <20200326190814.GA2122@hjp.at> 
 
 
Message-ID: 

On Fri, Mar 27, 2020 at 7:44 AM Grant Edwards  wrote:
>
> On 2020-03-26, Richard Damon  wrote:
>
> >> [...] nobody in their right mind would actually
> >> want to generate real output that way.
> >
> > Back in the day it was FREQUENTLY done, in part to show off, anyone
> > could type with a typewriter and get jagged right margins, but with a
> > computer you could get justified margins with uneven internal spacing!!
> > Status!
>
> It would have been better phrased "nobody _should_ actually want to".
>
> Sure, it was fun _producing_ output like that. But for anybody who had
> to read it, the novelty wore off pretty quickly. After few lines it
> was just annoying.  Most of us don't need any help making our writing
> even more annoying.
>

You know what's a lot more fun? Perfect block justification, no ragged
edges, no extra internal spaces. I'm not sure whether it's MORE
annoying or LESS than using internal spaces, but it's certainly a lot
more fun to write, since you have to compose on the fly.

And if even that becomes easy, try creating a column of just the
letter "e" in the middle of the paragraph.

ChrisA

From dcwhatthe at gmail.com  Thu Mar 26 17:02:06 2020
From: dcwhatthe at gmail.com (dcwhatthe at gmail.com)
Date: Thu, 26 Mar 2020 14:02:06 -0700 (PDT)
Subject: How come logging.error writes to a file,
 but not logging.debug or logging.info?
Message-ID: <904bad90-ce34-4a04-a488-1436459cebd9@googlegroups.com>

Hi,


When we run


    logging.basicConfig( filename = "TestLogging_" +  datetime.datetime.now().strftime("%Y%m%d_%H%M%S") + ".log" )

                        
, and then

    logging.error( "Test01\n" )
    logging.debug("Test02\n")
    logging.info("Test03\n")
    logging.error( "Test04\n" )


, only the error log lines get sent to the file.  


How do I get info() and debug() to go to the file, as well?




From rshepard at appl-ecosys.com  Thu Mar 26 17:12:33 2020
From: rshepard at appl-ecosys.com (Rich Shepard)
Date: Thu, 26 Mar 2020 14:12:33 -0700 (PDT)
Subject: Module import best practice
In-Reply-To: <97851394-ac00-3904-b5af-0a10329b1283@DancesWithMice.info>
References: 
 <97851394-ac00-3904-b5af-0a10329b1283@DancesWithMice.info>
Message-ID: 

On Fri, 27 Mar 2020, DL Neil via Python-list wrote:

> My personal approach is to follow 'the Zen of Python' and prefer
> "explicit" over "implicit". (it helps beginners, as well as us old-fogies
> whose minds cannot retain things for very long)

DL,

That was my original approach.

> I see little point in importing 'stuff' that's not used.

Agree.

> Hoping this non-answer helps, by leaving you with reading topics which
> will realise advice for the concerns you had/hadn't noted to-date.

Actually, it's a very good answer.

I'm not a professional coder. I'm an environmental consultant and I use a
variety of tools depending on the project's requirements. Most every day I'm
in emacs. use LyX for almost all writing, R and GRASS for data analyses, SQL
for database work, awk, sed, shell scripts, and python as required. This
means I'm constantly relearning what I forgot since the last time. This has
worked well for me for almost 30 years so I'm not complaining.

But now I am adding GUIs and other Real Application(TM) bits to postgres
applications I run from the command line for my own use so I can give these
tools to others who might benefit from them. The last database-backend
application I wrote in python2 and wxPython was more than a decade ago. Now
I'm working exclusively with Python3 and learning tkinter. I've much to
learn. ;-)

Thanks for the complete explanation and I hope your dinner didn't burn on
the grill.

Regards,

Rich


From cs at cskk.id.au  Thu Mar 26 17:35:08 2020
From: cs at cskk.id.au (Cameron Simpson)
Date: Fri, 27 Mar 2020 08:35:08 +1100
Subject: How come logging.error writes to a file, but not logging.debug
 or logging.info?
In-Reply-To: <904bad90-ce34-4a04-a488-1436459cebd9@googlegroups.com>
References: <904bad90-ce34-4a04-a488-1436459cebd9@googlegroups.com>
Message-ID: <20200326213508.GA88542@cskk.homeip.net>

On 26Mar2020 14:02, dcwhatthe at gmail.com  wrote:
>When we run
>
>    logging.basicConfig( filename = "TestLogging_" +  datetime.datetime.now().strftime("%Y%m%d_%H%M%S") + ".log" )
>
>, and then
>
>    logging.error( "Test01\n" )
>    logging.debug("Test02\n")
>    logging.info("Test03\n")
>    logging.error( "Test04\n" )
>
>, only the error log lines get sent to the file.
>
>How do I get info() and debug() to go to the file, as well?

You do this by adjusting the logging level of your programme. The idea 
is that you can put logging calls all through your code at suitable 
levels (info, error, warning debug) and change the logging verbosity 
just by adjusting the logging level of the logger involved.

So I often have a sniff around at startup in my programmes where I set 
up the logging, and default to logging.WARNING unless stderr is a 
terminal (inferring "interactive") and use logging.INFO. A command line 
switch or environment variable might be used to override these defaults.  
Having picked a level:

    root_logger = logging.getLogger()
    root_logger.setLevel(level)

sets the level of the root logger, thus changing the verbosity.

Obviously adjust if you've got a special purpose logger rather than the 
root logger.

Cheers,
Cameron Simpson 

From PythonList at DancesWithMice.info  Thu Mar 26 18:54:06 2020
From: PythonList at DancesWithMice.info (DL Neil)
Date: Fri, 27 Mar 2020 11:54:06 +1300
Subject: Module import best practice
In-Reply-To: 
References: 
 <97851394-ac00-3904-b5af-0a10329b1283@DancesWithMice.info>
 
Message-ID: <4f9c7398-aee5-1ff9-e8fb-c254bdcb0ea5@DancesWithMice.info>

> I'm not a professional coder. I'm an environmental consultant and I use a

I take it all back then...

No! No need to feel apologetic, the Python community works hard to be 
inclusive - which I take to include levels of expertise, not merely 
countering the various "-isms".


> variety of tools depending on the project's requirements. Most every day 
> I'm
> in emacs. use LyX for almost all writing, R and GRASS for data analyses, 
> SQL
> for database work, awk, sed, shell scripts, and python as required. This
> means I'm constantly relearning what I forgot since the last time. This has
> worked well for me for almost 30 years so I'm not complaining.

With that list, I'm having difficulty crediting your claim. It's good 
that you recognised programming as a tool, and made it work for you!


> But now I am adding GUIs and other Real Application(TM) bits to postgres
> applications I run from the command line for my own use so I can give these
> tools to others who might benefit from them. The last database-backend
> application I wrote in python2 and wxPython was more than a decade ago. Now
> I'm working exclusively with Python3 and learning tkinter. I've much to
> learn. ;-)

Know that feeling! I try to keep a note-/lab-/log-book of 
learning-experiences. Of course, remembering if/where I've noted topics 
is quite another matter...

The Python-list has gone a bit quiet. I imagine many are busy trying to 
encourage/support colleagues new to the work-from-home gig. (hopefully 
not any other reason!) Usually questions attract more, and more prompt, 
answers.

There are others who are tk-oriented. These days I (disclaiming bias) 
tend to follow the browser-based philosophy and thus web 
front-ends/HTML5-as-a-GUI (which don't need to be hosted on a web-server).

When introduced to Python GUIs (also wxPython), I found that following 
'the bare minimum' rule (cf 'kitchen sink') was the better option. 
Indeed it was usually easier to add things later, than to try to remove 
components - which usually 'broke stuff' at an alarming rate.

"YAGNI" applies!

Plus, before you try to hide your computing skills under the proverbial 
bushel, one of our most active skilled members has recently faced a 
similar issue of trying to add GUI-usually functionality into a cmdLN 
app. So...


> Thanks for the complete explanation and I hope your dinner didn't burn on
> the grill.

OT:
the word "environment" may mean slightly (or not so slight) different 
things to different people/cultures. Over here it is almost synonymous 
with "conservation" and the tourist advertising of "Clean, green, New 
Zealand". Thus, I think if I started on a diet of our living-dinosaurs, 
the Conservation Department would, shall we say, take an apposite stance.

Given the time zone (it's already Friday here - would the rest of you 
please try to keep up with us!) I look-forward to my dinner...

Pleased to hear of your age-group - hopefully it enabled you to 
understand the humor (and more readily accept (grand-)dad-jokes!).

Perhaps of interest, here's a combination of the two - environment and 
(grand-)children: the New Zealand Geographic (magazine) is:-
<<<
Every day of this lock-down New Zealand Geographic will send a story or 
a video that can be shared among your family. The first one is below, 
and with it some talking points to fill our days at home together. If 
you?re a grandparent or a Kiwi overseas, you can participate too, and 
join your family discussion over phone or video conferencing.
 >>>
https://www.nzgeo.com/newsletter/together-at-home/?t=34143_9db23c969a4ba2818c82d9b1c7f0ec9f&campaign_id=
-- 
Regards =dn

From deepaleedotkhare at gmail.com  Fri Mar 27 08:07:39 2020
From: deepaleedotkhare at gmail.com (deepalee khare)
Date: Fri, 27 Mar 2020 17:37:39 +0530
Subject: How to uninstall Python3.7 in Windows using cmd ?
Message-ID: 

Hi,

How to Uninstall Python3.7.3 using cmd ? i tried using cmd: Msiexec
/uninstall C:\Python37\python.exe But it gives me below error: enter
image description here

how do i uninstall it ?

Thanks,
Deepalee Khare

From grant.b.edwards at gmail.com  Fri Mar 27 15:36:32 2020
From: grant.b.edwards at gmail.com (Grant Edwards)
Date: Fri, 27 Mar 2020 19:36:32 -0000 (UTC)
Subject: Confusing textwrap parameters, and request for RE help
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
 <20200326190814.GA2122@hjp.at> 
 
 
 
Message-ID: 

On 2020-03-26, Chris Angelico  wrote:

> You know what's a lot more fun? Perfect block justification, no ragged
> edges, no extra internal spaces. I'm not sure whether it's MORE
> annoying or LESS than using internal spaces, but it's certainly a lot
> more fun to write, since you have to compose on the fly.

I was about to mention that.  I've seen paragraphs written that way
and marvelled that the language still seemed natural. I've never tried
to do it myself.

--
Grant


From dcwhatthe at gmail.com  Fri Mar 27 15:56:54 2020
From: dcwhatthe at gmail.com (Dan Campbell)
Date: Fri, 27 Mar 2020 15:56:54 -0400
Subject: How come logging.error writes to a file,
 but not logging.debug or logging.info?
In-Reply-To: 
References: <20200326213508.GA88542@cskk.homeip.net>
 <904bad90-ce34-4a04-a488-1436459cebd9@googlegroups.com>
 
Message-ID: 

Cameron, thanks.  I read something similar elsewhere, but I don't
understand what levels to set, and how many times.

Are we saying that we execute

    root_logger = logging.getLogger()
    root_logger.setLevel(1)  #Or some other level

, prior to running


 logging.basicConfig(...),

for each type of logging.

So like this?


    root_logger = logging.getLogger()
    root_logger.setLevel(1)  #Or some other level

logging.basicConfig( filename = "CheckConnectivity_error.log"  )


    root_logger = logging.getLogger()
    root_logger.setLevel(2)  #Or some other level

logging.basicConfig( filename = "CheckConnectivity_info.log"  )



    root_logger = logging.getLogger()
    root_logger.setLevel(3)  #Or some other level

logging.basicConfig( filename = "CheckConnectivity_debug.log"  )


?


Sorry, but I don't have the full context of this.


Regards,

DC





On Thu, Mar 26, 2020 at 5:35 PM Cameron Simpson  wrote:

> On 26Mar2020 14:02, dcwhatthe at gmail.com  wrote:
> >When we run
> >
> >    logging.basicConfig( filename = "TestLogging_" +
> datetime.datetime.now().strftime("%Y%m%d_%H%M%S") + ".log" )
> >
> >, and then
> >
> >    logging.error( "Test01\n" )
> >    logging.debug("Test02\n")
> >    logging.info("Test03\n")
> >    logging.error( "Test04\n" )
> >
> >, only the error log lines get sent to the file.
> >
> >How do I get info() and debug() to go to the file, as well?
>
> You do this by adjusting the logging level of your programme. The idea
> is that you can put logging calls all through your code at suitable
> levels (info, error, warning debug) and change the logging verbosity
> just by adjusting the logging level of the logger involved.
>
> So I often have a sniff around at startup in my programmes where I set
> up the logging, and default to logging.WARNING unless stderr is a
> terminal (inferring "interactive") and use logging.INFO. A command line
> switch or environment variable might be used to override these defaults.
> Having picked a level:
>
>     root_logger = logging.getLogger()
>     root_logger.setLevel(level)
>
> sets the level of the root logger, thus changing the verbosity.
>
> Obviously adjust if you've got a special purpose logger rather than the
> root logger.
>
> Cheers,
> Cameron Simpson 
>

From dcwhatthe at gmail.com  Fri Mar 27 16:18:17 2020
From: dcwhatthe at gmail.com (Dan Campbell)
Date: Fri, 27 Mar 2020 16:18:17 -0400
Subject: How come logging.error writes to a file,
 but not logging.debug or logging.info?
In-Reply-To: 
References: <20200326213508.GA88542@cskk.homeip.net>
 <904bad90-ce34-4a04-a488-1436459cebd9@googlegroups.com>
 
Message-ID: 

Got it.  I had to set the minimum level, in the basic config, thus:

    logging.basicConfig( filename = "whatthe.log", level=logging.INFO )

All set, thanks for the tip.

Regards,

DC


On Thu, Mar 26, 2020 at 5:35 PM Cameron Simpson  wrote:

> On 26Mar2020 14:02, dcwhatthe at gmail.com  wrote:
> >When we run
> >
> >    logging.basicConfig( filename = "TestLogging_" +
> datetime.datetime.now().strftime("%Y%m%d_%H%M%S") + ".log" )
> >
> >, and then
> >
> >    logging.error( "Test01\n" )
> >    logging.debug("Test02\n")
> >    logging.info("Test03\n")
> >    logging.error( "Test04\n" )
> >
> >, only the error log lines get sent to the file.
> >
> >How do I get info() and debug() to go to the file, as well?
>
> You do this by adjusting the logging level of your programme. The idea
> is that you can put logging calls all through your code at suitable
> levels (info, error, warning debug) and change the logging verbosity
> just by adjusting the logging level of the logger involved.
>
> So I often have a sniff around at startup in my programmes where I set
> up the logging, and default to logging.WARNING unless stderr is a
> terminal (inferring "interactive") and use logging.INFO. A command line
> switch or environment variable might be used to override these defaults.
> Having picked a level:
>
>     root_logger = logging.getLogger()
>     root_logger.setLevel(level)
>
> sets the level of the root logger, thus changing the verbosity.
>
> Obviously adjust if you've got a special purpose logger rather than the
> root logger.
>
> Cheers,
> Cameron Simpson 
>

From dcwhatthe at gmail.com  Fri Mar 27 16:21:20 2020
From: dcwhatthe at gmail.com (dcwhatthe at gmail.com)
Date: Fri, 27 Mar 2020 13:21:20 -0700 (PDT)
Subject: How come logging.error writes to a file,
 but not logging.debug or loggi
In-Reply-To: <743360268@f38.n261.z1.binkp.net>
References: <743360268@f38.n261.z1.binkp.net>
Message-ID: <31323794-c6b5-4d11-974f-fd5fa2a709cd@googlegroups.com>

On Friday, March 27, 2020 at 3:15:50 PM UTC-4, dcwhatthe wrote:
> Hi,
> 
> 
> When we run
> 
> 
>     logging.basicConfig( filename = "TestLogging_" +
> datetime.datetime.now().strftime("%Y%m%d_%H%M%S") + ".log" )
> 
> 
> , and then
> 
>     logging.error( "Test01\n" )
>     logging.debug("Test02\n")
>     logging.info("Test03\n")
>     logging.error( "Test04\n" )
> 
> 
> , only the error log lines get sent to the file.
> 
> 
> How do I get info() and debug() to go to the file, as well?

Got it.  Someone named Cameron, assisted with this.  For my purposes, I just needed to set the minimum level (INFO) inside the basic config function.  From there, the logging will take place for INFO and above, i.e. INFO, DEBUG, and ERROR in this case:


logging.basicConfig( filename = "TestLogging_" +
 datetime.datetime.now().strftime("%Y%m%d_%H%M%S") + ".log", level = logging.INFO )


Thanks, Cameron.


Regards,

DC


From rosuav at gmail.com  Fri Mar 27 16:59:54 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Sat, 28 Mar 2020 07:59:54 +1100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
 <20200326190814.GA2122@hjp.at> 
 
 
 
 
Message-ID: 

On Sat, Mar 28, 2020 at 7:24 AM Grant Edwards  wrote:
>
> On 2020-03-26, Chris Angelico  wrote:
>
> > You know what's a lot more fun? Perfect block justification, no ragged
> > edges, no extra internal spaces. I'm not sure whether it's MORE
> > annoying or LESS than using internal spaces, but it's certainly a lot
> > more fun to write, since you have to compose on the fly.
>
> I was about to mention that.  I've seen paragraphs written that way
> and marvelled that the language still seemed natural. I've never tried
> to do it myself.
>

It's a linguistic exercise - kinda like fitting your thoughts into a
poetic structure. It helps if you know a *lot* of synonyms for things
:)

ChrisA

From drsalists at gmail.com  Fri Mar 27 17:28:36 2020
From: drsalists at gmail.com (Dan Stromberg)
Date: Fri, 27 Mar 2020 14:28:36 -0700
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
 <20200326190814.GA2122@hjp.at> 
 
 
 
 
Message-ID: 

On Fri, Mar 27, 2020 at 1:23 PM Grant Edwards 
wrote:

> On 2020-03-26, Chris Angelico  wrote:
>
> > You know what's a lot more fun? Perfect block justification, no ragged
> > edges, no extra internal spaces. I'm not sure whether it's MORE
> > annoying or LESS than using internal spaces, but it's certainly a lot
> > more fun to write, since you have to compose on the fly.
>
> I was about to mention that.  I've seen paragraphs written that way
> and marvelled that the language still seemed natural. I've never tried
> to do it myself.
>

Back when I was a kid, and wordprocessors were exemplified by WordStar, I
heard about a study the conclusion of which was that aligned right edges
were harder to read - that it was better to align on the left and leave the
right ragged.

But one study doesn't establish truth.

From torriem at gmail.com  Fri Mar 27 17:46:54 2020
From: torriem at gmail.com (Michael Torrie)
Date: Fri, 27 Mar 2020 15:46:54 -0600
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
 <20200326190814.GA2122@hjp.at> 
 
 
 
 
 
Message-ID: <576d30c9-7588-999a-0019-deaf4471e6a1@gmail.com>

On 3/27/20 3:28 PM, Dan Stromberg wrote:
> Back when I was a kid, and wordprocessors were exemplified by WordStar, I
> heard about a study the conclusion of which was that aligned right edges
> were harder to read - that it was better to align on the left and leave the
> right ragged.
> 
> But one study doesn't establish truth.

I've read poorly-typeset, self-published books that were really hard to
read due to the way the full justification worked out.  Not sure if
that's just due to the poor typesetting job (a word processor probably
did it), or the font, or what.  There must be some tricks that
publishers use to both justify and keep the text looking good and
readable.  At one point in the print world, the majority of what I read
is fully justified, yet still quite readable.  Even now I think most
published books I've seen recently are fully justified. These days,
seems like more and more is ragged-right, such as magazines, which is
probably due to the prevalence of digital media where it's probably
easier to generate and easier to read on small screens.

From 2QdxY4RzWzUUiLuE at potatochowder.com  Fri Mar 27 18:50:47 2020
From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers)
Date: Fri, 27 Mar 2020 18:50:47 -0400
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: <576d30c9-7588-999a-0019-deaf4471e6a1@gmail.com>
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
 <20200326190814.GA2122@hjp.at> 
 
 
 
 
 
 <576d30c9-7588-999a-0019-deaf4471e6a1@gmail.com>
Message-ID: <20200327185047.bf189eac90c950d4fdab8a3a@potatochowder.com>

On Fri, 27 Mar 2020 15:46:54 -0600
Michael Torrie  wrote:

> On 3/27/20 3:28 PM, Dan Stromberg wrote:

> > Back when I was a kid, and wordprocessors were exemplified by
> > WordStar, I heard about a study the conclusion of which was that
> > aligned right edges were harder to read - that it was better to
> > align on the left and leave the right ragged.

I remember WordStar, and its text editor cousin WordMaster.

> > But one study doesn't establish truth.

> I've read poorly-typeset, self-published books that were really hard
> to read due to the way the full justification worked out.  Not sure if
> that's just due to the poor typesetting job (a word processor probably
> did it), or the font, or what.  There must be some tricks that
> publishers use to both justify and keep the text looking good and
> readable ...

Ask Donald Knuth why he invented TeX, and why math is enclosed in
literal $ (U+0024) characters.  ;-)

Also, there are word processors and there are word processors.  From an
aesthetics perspective, TeX has been producing beautiful printed pages
(and pairs and sequences of pages) for decades, Word still didn't the
last time I looked (maybe 8 or 10 years ago?), and there are dozens or
more in between.

> ... At one point in the print world, the majority of what I read is
> fully justified, yet still quite readable.  Even now I think most
> published books I've seen recently are fully justified. These days,
> seems like more and more is ragged-right, such as magazines, which is
> probably due to the prevalence of digital media where it's probably
> easier to generate and easier to read on small screens.

If content producers did their job well, a 2540 pixel per inch printed
page, a desktop 72 or 96 pixel per inch display screen, and a handheld
320 pixel per inch screen would all be optimized separately (through one
sort of style sheet mechanism or another).  But these days, they spend
more time and money on ads and SEO than typesetting.

Dan

-- 
?Atoms are not things.? ? Werner Heisenberg
Dan Sommers, http://www.tombstonezero.net/dan

From cameron.simpson at gmail.com  Fri Mar 27 18:57:24 2020
From: cameron.simpson at gmail.com (Cameron Simpson)
Date: Sat, 28 Mar 2020 09:57:24 +1100
Subject: How come logging.error writes to a file, but not logging.debug
 or logging.info?
In-Reply-To: 
References: 
Message-ID: <20200327225724.GA82037@cskk.homeip.net>

On 27Mar2020 16:18, Dan Campbell  wrote:
>Got it.  I had to set the minimum level, in the basic config, thus:
>
>    logging.basicConfig( filename = "whatthe.log", level=logging.INFO )

Good, you've found the table of predefined logging levels in the module 
docs then?

You'll notice that they are spaced apart by 10; in principle one can 
choose levels between them. Kind of irrelevant if nothing logs at such 
an intermediate level, but...

For example, I define for myself a TRACE value between INFO and WARNING, 
and a trace() call which logs at that level (like the predefined 
warning() function logs at logging.WARNING level). I often find my info 
calls are too verbose, and the warnings are only for badness, so I have 
a kind of intermediate call for "high level" far less frequent logs.

Cheers,
Cameron Simpson 

From robertvstepp at gmail.com  Fri Mar 27 20:36:44 2020
From: robertvstepp at gmail.com (boB Stepp)
Date: Fri, 27 Mar 2020 19:36:44 -0500
Subject: How to uninstall Python3.7 in Windows using cmd ?
In-Reply-To: 
References: 
Message-ID: 

On Fri, Mar 27, 2020 at 1:22 PM deepalee khare
 wrote:
>
> Hi,
>
> How to Uninstall Python3.7.3 using cmd ? i tried using cmd: Msiexec
> /uninstall C:\Python37\python.exe But it gives me below error: enter
> image description here
>
> how do i uninstall it ?
>
You appear to be using a version of Windows.  You can uninstall Python
like you would most other programs, using the built-in functionality
provided by Windows.  For instance in Win10 you can go to the Start
Menu, then settings and there is a section for handling Apps.  Find
Python in the list of Apps, click on it and you will get
repair/uninstall links.  Earlier versions of Windows are similarly
done.

HTH!


-- 
boB

From souvik.viksou at gmail.com  Fri Mar 27 20:44:16 2020
From: souvik.viksou at gmail.com (Souvik Dutta)
Date: Sat, 28 Mar 2020 06:14:16 +0530
Subject: How to uninstall Python3.7 in Windows using cmd ?
In-Reply-To: 
References: 
 
Message-ID: 

Control panel is still alive. So just using it would be better. Go to
control panel. Then click uninstall a program. Then find python in the list
and double click on it to uninstall.

On Sat, 28 Mar, 2020, 6:07 am boB Stepp,  wrote:

> On Fri, Mar 27, 2020 at 1:22 PM deepalee khare
>  wrote:
> >
> > Hi,
> >
> > How to Uninstall Python3.7.3 using cmd ? i tried using cmd: Msiexec
> > /uninstall C:\Python37\python.exe But it gives me below error: enter
> > image description here
> >
> > how do i uninstall it ?
> >
> You appear to be using a version of Windows.  You can uninstall Python
> like you would most other programs, using the built-in functionality
> provided by Windows.  For instance in Win10 you can go to the Start
> Menu, then settings and there is a section for handling Apps.  Find
> Python in the list of Apps, click on it and you will get
> repair/uninstall links.  Earlier versions of Windows are similarly
> done.
>
> HTH!
>
>
> --
> boB
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From dcwhatthe at gmail.com  Sat Mar 28 10:17:26 2020
From: dcwhatthe at gmail.com (Dan Campbell)
Date: Sat, 28 Mar 2020 10:17:26 -0400
Subject: How come logging.error writes to a file,
 but not logging.debug or logging.info?
In-Reply-To: 
References: <20200327225724.GA82037@cskk.homeip.net>
 
 
Message-ID: 

I probably won't need to do that, in this case.  But good advice, in other
contexts ; I'll put it in the pim, for further reference, thanks.



On Fri, Mar 27, 2020 at 7:09 PM Cameron Simpson 
wrote:

> On 27Mar2020 16:18, Dan Campbell  wrote:
> >Got it.  I had to set the minimum level, in the basic config, thus:
> >
> >    logging.basicConfig( filename = "whatthe.log", level=logging.INFO )
>
> Good, you've found the table of predefined logging levels in the module
> docs then?
>
> You'll notice that they are spaced apart by 10; in principle one can
> choose levels between them. Kind of irrelevant if nothing logs at such
> an intermediate level, but...
>
> For example, I define for myself a TRACE value between INFO and WARNING,
> and a trace() call which logs at that level (like the predefined
> warning() function logs at logging.WARNING level). I often find my info
> calls are too verbose, and the warnings are only for badness, so I have
> a kind of intermediate call for "high level" far less frequent logs.
>
> Cheers,
> Cameron Simpson 
>

From tjreedy at udel.edu  Sat Mar 28 14:06:26 2020
From: tjreedy at udel.edu (Terry Reedy)
Date: Sat, 28 Mar 2020 14:06:26 -0400
Subject: How to uninstall Python3.7 in Windows using cmd ?
In-Reply-To: 
References: 
Message-ID: 

On 3/27/2020 8:07 AM, deepalee khare wrote:

> How to Uninstall Python3.7.3 using cmd ? i tried using cmd: Msiexec
> /uninstall C:\Python37\python.exe But it gives me below error: enter
> image description here

Python is not currently installed with msi, hence cannot use it to 
uninstall.  Images and attachments are not allowed.


-- 
Terry Jan Reedy


From joepareti54 at gmail.com  Sat Mar 28 14:23:12 2020
From: joepareti54 at gmail.com (joseph pareti)
Date: Sat, 28 Mar 2020 19:23:12 +0100
Subject: mport pytorch fails on my windows 10 PC
Message-ID: 

apologies for asking here a presumably off-topic question:

I have installed pytorch using (miniconda3) the following command:

*conda install pytorch torchvision cpuonly -c pytorch*

In the jupyter notebook, the 'import torch' fails:

*ModuleNotFoundError: No module named 'torch._C'*

I am not sure if having several python versions on the system could cause
the issue:

./Users/joepareti/Miniconda3/envs/myenv/python.exe
./Users/joepareti/Miniconda3/envs/myenv1/python.exe
./Users/joepareti/Miniconda3/pkgs/python-3.6.8-h9f7ef89_0/python.exe
./Users/joepareti/Miniconda3/pkgs/python-3.6.8-h9f7ef89_1/python.exe
./Users/joepareti/Miniconda3/pkgs/python-3.7.1-h8c8aaf0_6/python.exe
./Users/joepareti/Miniconda3/python.exe
-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644

From paolo.cantore at t-online.de  Sat Mar 28 16:26:53 2020
From: paolo.cantore at t-online.de (Paolo G. Cantore)
Date: Sat, 28 Mar 2020 21:26:53 +0100
Subject: How to create an Excel app that runs Python?
In-Reply-To: 
References: 
 
 
 
 
Message-ID: 

Am 25.03.20 um 15:21 schrieb farayao.ds at gmail.com:

> 
> Hello Paolo,
> 
> Thanks for your reply, indeed now I'm thinking on building a web app, do you have any suggestions for this? I am thinking of using Tkinter, the method that you describe using HTML is also using Javascript?
> 
> Kind Regards
> Felipe
> 
Hello Felipe,

only bare HTML is needed, no Tkinter, no JavaScript.

Have a look in the attached prototype. For use in your Intranet some 
definitions have to be done by your IT people and the script run mode 
has to be changed too.

So far it is tested on my machine (Linux, Python3.6). The only 
dependancy is bottle.

Maybe it's suited for your needs.

Kind Regards
Paolo

From dcwhatthe at gmail.com  Sat Mar 28 18:37:15 2020
From: dcwhatthe at gmail.com (dcwhatthe at gmail.com)
Date: Sat, 28 Mar 2020 15:37:15 -0700 (PDT)
Subject: How to cover connection exception errors, and exit
Message-ID: <27484ba5-445b-42d9-88a0-bb21b3ba29a2@googlegroups.com>

Hi,

I've tried urllib, requests, and some other options.  But I haven't found a way to trap certain urls that aren't possible to connect from, outside the office.  In those cases, I need to just output an error.


So, the following code will cover the 404s and similar errors for most of the problem IPs and urls.  But for these particular problem urls, while debugging it keeps transferring control to adapters.py, and outputting 

     requests.exceptions.ConnectionError: 
     HTTPSConnectionPool(host='xxxxxxx.state.gov', port=443): Max retries 
     exceeded with url: /xxx/xxx/xxx....(Caused by 
     NewConnectionError(': Failed to establish a new connection: [Errno 11001] 
     getaddrinfo failed'))


How do I trap this error, without invoking adapters.py?


I've tried many things, but the most recent is this code, from the web:



    try:
        r = requests.get(url,timeout=3)
        r.raise_for_status()
    except requests.exceptions.HTTPError as errh:
        print ("Http Error:",errh)
    except requests.exceptions.ConnectionError as errc:
        print ("Error Connecting:",errc)
    except requests.exceptions.Timeout as errt:
        print ("Timeout Error:",errt)
    except requests.exceptions.RequestException as err:
        print ("OOps: Something Else",err)
        

It seems like the error should be trapped by the exception above requests.exceptions.ConnectionError, but instead its' hitting adapters.py.



From souvik.viksou at gmail.com  Sat Mar 28 20:36:22 2020
From: souvik.viksou at gmail.com (Souvik Dutta)
Date: Sun, 29 Mar 2020 06:06:22 +0530
Subject: mport pytorch fails on my windows 10 PC
In-Reply-To: 
References: 
Message-ID: 

Yes having two versions of python causes that problem.

On Sat, 28 Mar, 2020, 11:53 pm joseph pareti,  wrote:

> apologies for asking here a presumably off-topic question:
>
> I have installed pytorch using (miniconda3) the following command:
>
> *conda install pytorch torchvision cpuonly -c pytorch*
>
> In the jupyter notebook, the 'import torch' fails:
>
> *ModuleNotFoundError: No module named 'torch._C'*
>
> I am not sure if having several python versions on the system could cause
> the issue:
>
> ./Users/joepareti/Miniconda3/envs/myenv/python.exe
> ./Users/joepareti/Miniconda3/envs/myenv1/python.exe
> ./Users/joepareti/Miniconda3/pkgs/python-3.6.8-h9f7ef89_0/python.exe
> ./Users/joepareti/Miniconda3/pkgs/python-3.6.8-h9f7ef89_1/python.exe
> ./Users/joepareti/Miniconda3/pkgs/python-3.7.1-h8c8aaf0_6/python.exe
> ./Users/joepareti/Miniconda3/python.exe
> --
> Regards,
> Joseph Pareti - Artificial Intelligence consultant
> Joseph Pareti's AI Consulting Services
> https://www.joepareti54-ai.com/
> cell +49 1520 1600 209
> cell +39 339 797 0644
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From gentleman.for.ever.and.ever at gmail.com  Sat Mar 28 23:23:47 2020
From: gentleman.for.ever.and.ever at gmail.com (gentleman.for.ever.and.ever at gmail.com)
Date: Sat, 28 Mar 2020 20:23:47 -0700 (PDT)
Subject: NEED ASSISTANCE WITH PYTHON CLASS
Message-ID: <3e61ed18-58b5-4347-ae4c-533e208b3724@googlegroups.com>

Hi, I need help with coding assignments (python to be exact) in school. I am willing to pay for your attention by the hour. Please email me at aifam.c at protonmail.com if you?re interested. Please only reach out if you?re not a beginner. Trying to avoid the blind being led by the blind. Thanks!

From miked at dewhirst.com.au  Sun Mar 29 00:17:02 2020
From: miked at dewhirst.com.au (Mike Dewhirst)
Date: Sun, 29 Mar 2020 15:17:02 +1100
Subject: How to uninstall Python3.7 in Windows using cmd ?
In-Reply-To: 
References: 
 
Message-ID: <95a77f78-f293-b4a2-32b4-bbc477b0706e@dewhirst.com.au>

On 29/03/2020 5:06 am, Terry Reedy wrote:
> On 3/27/2020 8:07 AM, deepalee khare wrote:
>
>> How to Uninstall Python3.7.3 using cmd ? i tried using cmd: Msiexec
>> /uninstall C:\Python37\python.exe But it gives me below error: enter
>> image description here
>
> Python is not currently installed with msi, hence cannot use it to 
> uninstall.? Images and attachments are not allowed.
>
>

In that case install that same version of Python to the same location 
using msi - then remove it.

From __peter__ at web.de  Sun Mar 29 05:00:39 2020
From: __peter__ at web.de (Peter Otten)
Date: Sun, 29 Mar 2020 11:00:39 +0200
Subject: How to cover connection exception errors, and exit
References: <27484ba5-445b-42d9-88a0-bb21b3ba29a2@googlegroups.com>
Message-ID: 

dcwhatthe at gmail.com wrote:

> Hi,
> 
> I've tried urllib, requests, and some other options.  But I haven't found
> a way to trap certain urls that aren't possible to connect from, outside
> the office.  In those cases, I need to just output an error.
> 
> 
> So, the following code will cover the 404s and similar errors for most of
> the problem IPs and urls.  But for these particular problem urls, while
> debugging it keeps transferring control to adapters.py, and outputting
> 
>      requests.exceptions.ConnectionError:
>      HTTPSConnectionPool(host='xxxxxxx.state.gov', port=443): Max retries
>      exceeded with url: /xxx/xxx/xxx....(Caused by
>      NewConnectionError('      object at 0x03934538>: Failed to establish a new connection: [Errno
>      11001] getaddrinfo failed'))
> 
> 
> How do I trap this error, without invoking adapters.py?

If requests catches the error -- I don't know. 

If you fail to catch the error in your code -- what happens if you use a 
bare except? Like

try:
    ...  # your code
except:
    print(sys.exc_info())

This should print the type of exception you need to catch.


> I've tried many things, but the most recent is this code, from the web:
> 
> 
> 
>     try:
>         r = requests.get(url,timeout=3)
>         r.raise_for_status()
>     except requests.exceptions.HTTPError as errh:
>         print ("Http Error:",errh)
>     except requests.exceptions.ConnectionError as errc:
>         print ("Error Connecting:",errc)
>     except requests.exceptions.Timeout as errt:
>         print ("Timeout Error:",errt)
>     except requests.exceptions.RequestException as err:
>         print ("OOps: Something Else",err)
>         
> 
> It seems like the error should be trapped by the exception above
> requests.exceptions.ConnectionError, but instead its' hitting adapters.py.



From souvik.viksou at gmail.com  Sun Mar 29 05:36:37 2020
From: souvik.viksou at gmail.com (Souvik Dutta)
Date: Sun, 29 Mar 2020 15:06:37 +0530
Subject: mport pytorch fails on my windows 10 PC
In-Reply-To: 
References: 
 
 
Message-ID: 

Since it is not in the control panel, go to windows app execution aliases
and scroll down till you find python. Now toggle both of them and see if
this works.

On Sun, Mar 29, 2020, 2:53 PM joseph pareti  wrote:

> All right, thx, but how to uninstall the 'other' python version?
>
> The control panel only shows python 3.7 which is what I am using.
>
> Am So., 29. M?rz 2020 um 01:36 Uhr schrieb Souvik Dutta <
> souvik.viksou at gmail.com>:
>
>> Yes having two versions of python causes that problem.
>>
>> On Sat, 28 Mar, 2020, 11:53 pm joseph pareti, 
>> wrote:
>>
>>> apologies for asking here a presumably off-topic question:
>>>
>>> I have installed pytorch using (miniconda3) the following command:
>>>
>>> *conda install pytorch torchvision cpuonly -c pytorch*
>>>
>>> In the jupyter notebook, the 'import torch' fails:
>>>
>>> *ModuleNotFoundError: No module named 'torch._C'*
>>>
>>> I am not sure if having several python versions on the system could cause
>>> the issue:
>>>
>>> ./Users/joepareti/Miniconda3/envs/myenv/python.exe
>>> ./Users/joepareti/Miniconda3/envs/myenv1/python.exe
>>> ./Users/joepareti/Miniconda3/pkgs/python-3.6.8-h9f7ef89_0/python.exe
>>> ./Users/joepareti/Miniconda3/pkgs/python-3.6.8-h9f7ef89_1/python.exe
>>> ./Users/joepareti/Miniconda3/pkgs/python-3.7.1-h8c8aaf0_6/python.exe
>>> ./Users/joepareti/Miniconda3/python.exe
>>> --
>>> Regards,
>>> Joseph Pareti - Artificial Intelligence consultant
>>> Joseph Pareti's AI Consulting Services
>>> https://www.joepareti54-ai.com/
>>> cell +49 1520 1600 209
>>> cell +39 339 797 0644
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>
>
> --
> Regards,
> Joseph Pareti - Artificial Intelligence consultant
> Joseph Pareti's AI Consulting Services
> https://www.joepareti54-ai.com/
> cell +49 1520 1600 209
> cell +39 339 797 0644
>

From antoon.pardon at rece.vub.ac.be  Sun Mar 29 09:00:02 2020
From: antoon.pardon at rece.vub.ac.be (Antoon Pardon)
Date: Sun, 29 Mar 2020 15:00:02 +0200
Subject: super not behaving as I expected
Message-ID: <982a3bb5-36e3-d727-8169-df846f7e0c2f@rece.vub.ac.be>


I have the following program

class slt:
	__slots__ = ()

	def getslots(self):
		print("### slots =", self.__slots__)
		if self.__slots__ == ():
			return []
		else:
			ls = super().getslots()
			ls.extend(self.__slots__)
			return ls

	def __str__(self):
		ls = []
		attrs = self.getslots()
		for attr in attrs:
			ls.append(str(getattr( self, attr)))
		return '->'.join(ls)


class slt1 (slt):
	__slots__ = 'fld1', 'fld2'

	def __init__(self, vl1, vl2):
		self.fld1 = vl1
		self.fld2 = vl2

class slt2(slt1):
	__slots__ = 'fld3',
			
	def __init__(self, vl1, vl2, vl3):
		self.fld1 = vl1
		self.fld2 = vl2
		self.fld3 = vl3

rc1 = slt1(4, 7)
rc2 = slt2(11, 18, 29)

print(rc1)
print(rc2)

When I call this I would expect to see the following:

### slots = ('fld1', 'fld2')
### slots = ()
4->7
### slots = (fld3,)
### slots = ('fld1', 'fld2')
### slots = ()
11->18->29

What I actually get is:

### slots = ('fld1', 'fld2')
Traceback (most recent call last):
  File "slottest", line 39, in 
    print(rc1)
  File "slottest", line 15, in __str__
    attrs = self.getslots()
  File "slottest", line 9, in getslots
    ls = super().getslots()
AttributeError: 'super' object has no attribute 'getslots'

-- 
Antoon Pardon

From __peter__ at web.de  Sun Mar 29 10:49:03 2020
From: __peter__ at web.de (Peter Otten)
Date: Sun, 29 Mar 2020 16:49:03 +0200
Subject: super not behaving as I expected
References: <982a3bb5-36e3-d727-8169-df846f7e0c2f@rece.vub.ac.be>
Message-ID: 

Antoon Pardon wrote:

> 
> I have the following program
> 
> class slt:
> __slots__ = ()
> 
> def getslots(self):
> print("### slots =", self.__slots__)
> if self.__slots__ == ():
> return []
> else:
> ls = super().getslots()
> ls.extend(self.__slots__)
> return ls
> 
> def __str__(self):
> ls = []
> attrs = self.getslots()
> for attr in attrs:
> ls.append(str(getattr( self, attr)))
> return '->'.join(ls)
> 
> 
> class slt1 (slt):
> __slots__ = 'fld1', 'fld2'
> 
> def __init__(self, vl1, vl2):
> self.fld1 = vl1
> self.fld2 = vl2
> 
> class slt2(slt1):
> __slots__ = 'fld3',
> 
> def __init__(self, vl1, vl2, vl3):
> self.fld1 = vl1
> self.fld2 = vl2
> self.fld3 = vl3
> 
> rc1 = slt1(4, 7)
> rc2 = slt2(11, 18, 29)
> 
> print(rc1)
> print(rc2)
> 
> When I call this I would expect to see the following:
> 
> ### slots = ('fld1', 'fld2')
> ### slots = ()
> 4->7
> ### slots = (fld3,)
> ### slots = ('fld1', 'fld2')
> ### slots = ()
> 11->18->29
> 
> What I actually get is:
> 
> ### slots = ('fld1', 'fld2')
> Traceback (most recent call last):
>   File "slottest", line 39, in 
>     print(rc1)
>   File "slottest", line 15, in __str__
>     attrs = self.getslots()
>   File "slottest", line 9, in getslots
>     ls = super().getslots()
> AttributeError: 'super' object has no attribute 'getslots'
> 

Well...

super().method

looks up method in the parent class of the class where it's used -- in your 
case the parent class of slt, or object.

self.attribute

looks up the attribute in the instance, and if that fails works its way up 
the inheritance tree follong the mro; here it succeeds in slt1. This leeds 
to execution of the else branch in getslots() which in turn tries to invoke 
object.getslots() -- and fails.

That would be the normal behaviour. The __slots__ attribute is special, so 
there may be subtle differences.


Anyway, here's my attempt to collect inherited slots:

    @classmethod
    def get_slots(cls):
        all_slots = set()
        for C in cls.__mro__:
            try:
                slots = C.__slots__
            except AttributeError:
                assert C is object
            else:
                all_slots.update(slots)
        return all_slots



From tjreedy at udel.edu  Sun Mar 29 07:24:03 2020
From: tjreedy at udel.edu (Terry Reedy)
Date: Sun, 29 Mar 2020 07:24:03 -0400
Subject: How to uninstall Python3.7 in Windows using cmd ?
In-Reply-To: <95a77f78-f293-b4a2-32b4-bbc477b0706e@dewhirst.com.au>
References: 
 
 <95a77f78-f293-b4a2-32b4-bbc477b0706e@dewhirst.com.au>
Message-ID: 

On 3/29/2020 12:17 AM, Mike Dewhirst wrote:
> On 29/03/2020 5:06 am, Terry Reedy wrote:
>> On 3/27/2020 8:07 AM, deepalee khare wrote:
>>
>>> How to Uninstall Python3.7.3 using cmd ? i tried using cmd: Msiexec
>>> /uninstall C:\Python37\python.exe But it gives me below error: enter
>>> image description here
>>
>> Python is not currently installed with msi, hence cannot use it to 
>> uninstall.? Images and attachments are not allowed.
>>
>>
> 
> In that case install that same version of Python to the same location 
> using msi 

Just how do you propose that one do that?

- then remove it.

To clarify, the pydev/python.org installer does not use msi.  I don't 
know that anyone else does.  And if someone did, why do you think it 
would also uninstall the current installation?

-- 
Terry Jan Reedy



From Steve.A.Dore at outlook.com  Sun Mar 29 00:21:04 2020
From: Steve.A.Dore at outlook.com (Steve Smith)
Date: Sun, 29 Mar 2020 04:21:04 +0000
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: <20200327185047.bf189eac90c950d4fdab8a3a@potatochowder.com>
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
 <20200326190814.GA2122@hjp.at> 
 
 
 
 
 
 <576d30c9-7588-999a-0019-deaf4471e6a1@gmail.com>
 <20200327185047.bf189eac90c950d4fdab8a3a@potatochowder.com>
Message-ID: 

I am having the same issue. I can either get the text to wrap, which makes all the text wrap, or I can get the text to ignore independent '/n' characters, so that all the blank space is removed. I'd like to set up my code, so that only 1 blank space is remaining (I'll settle for none at this point), an the text wraps up to 100 chars or so out per line. Does anyone have any thoughts on the attached code? And what I'm not doing correctly?


#import statements
import textwrap
import requests
from bs4 import BeautifulSoup

#class extension of textwrapper
class DocumentWrapper(textwrap.TextWrapper):

    def wrap(self, text):
        split_text = text.split('\n')
        lines = [line for para in split_text for line in textwrap.TextWrapper.wrap(self, para)]
        return lines

#import statement of text.
page = requests.get("http://classics.mit.edu/Aristotle/rhetoric.mb.txt")
soup = BeautifulSoup(page.text, "html.parser")

#instantiation of extension of textwrap.wrap.
d = DocumentWrapper(width=110,initial_indent='',fix_sentence_endings=True )
new_string = d.fill(page.text)

#set up an optional variable, even attempted applying BOTH the extended method and the original method to the issue... nothing has worked.
#new_string_2 = textwrap.wrap(new_string,90)

#with loop with JUST the class extension of textwrapper.
with open("Art_of_Rhetoric.txt", "w") as f:
    f.writelines(new_string)

#with loop with JUST the standard textwrapper.text method applied to it.
with open("Art_of_Rhetoric2.txt", "w") as f:
    f.writelines(textwrap.wrap(page.text,90))


-----Original Message-----
From: Python-list  On Behalf Of Dan Sommers
Sent: Friday, March 27, 2020 3:51 PM
To: python-list at python.org
Subject: Re: Confusing textwrap parameters, and request for RE help

On Fri, 27 Mar 2020 15:46:54 -0600
Michael Torrie  wrote:

> On 3/27/20 3:28 PM, Dan Stromberg wrote:

> > Back when I was a kid, and wordprocessors were exemplified by 
> > WordStar, I heard about a study the conclusion of which was that 
> > aligned right edges were harder to read - that it was better to 
> > align on the left and leave the right ragged.

I remember WordStar, and its text editor cousin WordMaster.

> > But one study doesn't establish truth.

> I've read poorly-typeset, self-published books that were really hard 
> to read due to the way the full justification worked out.  Not sure if 
> that's just due to the poor typesetting job (a word processor probably 
> did it), or the font, or what.  There must be some tricks that 
> publishers use to both justify and keep the text looking good and 
> readable ...

Ask Donald Knuth why he invented TeX, and why math is enclosed in literal $ (U+0024) characters.  ;-)

Also, there are word processors and there are word processors.  From an aesthetics perspective, TeX has been producing beautiful printed pages (and pairs and sequences of pages) for decades, Word still didn't the last time I looked (maybe 8 or 10 years ago?), and there are dozens or more in between.

> ... At one point in the print world, the majority of what I read is 
> fully justified, yet still quite readable.  Even now I think most 
> published books I've seen recently are fully justified. These days, 
> seems like more and more is ragged-right, such as magazines, which is 
> probably due to the prevalence of digital media where it's probably 
> easier to generate and easier to read on small screens.

If content producers did their job well, a 2540 pixel per inch printed page, a desktop 72 or 96 pixel per inch display screen, and a handheld
320 pixel per inch screen would all be optimized separately (through one sort of style sheet mechanism or another).  But these days, they spend more time and money on ads and SEO than typesetting.

Dan

--
?Atoms are not things.? ? Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan
--
https://mail.python.org/mailman/listinfo/python-list

From swhobbs2000 at hotmail.com  Sun Mar 29 18:34:37 2020
From: swhobbs2000 at hotmail.com (Steven Hobbs)
Date: Sun, 29 Mar 2020 22:34:37 +0000
Subject: Unable to install or operate PIP on Windows 10
In-Reply-To: 
References: 
Message-ID: 


Hi all,

I have installed Python 3.7.7 on Windows 10 and I understood that pip came installed. However when I try using pip I get an unrecognised command error.

I tried following the instructions on this website:
https://docs.python.org/3/installing/index.html

However usage of pip as described at this website receives an unrecognised command error. I have also tried adding the python directory to the Path variable and running commands in the Python directory.

I have also tried this website without success:

https://pip.pypa.io/en/stable/installing/
Installation ? pip 20.0.2 documentation
Warning. Be cautious if you are using a Python install that is managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.
pip.pypa.io


Can I please have step by step instructions that have been verified to work with Windows 10 and Python 3.7.7 that list all requirements, dependencies and processes to install and run pip and then install libraries such as numpy and pillow.


Any help would be greatly appreciated.

Regards,

Steven Hobbs

From python at mrabarnett.plus.com  Sun Mar 29 19:51:36 2020
From: python at mrabarnett.plus.com (MRAB)
Date: Mon, 30 Mar 2020 00:51:36 +0100
Subject: Unable to install or operate PIP on Windows 10
In-Reply-To: 
References: 
 
Message-ID: <6e991723-bc37-0cf0-3a04-26b9ac3f3de7@mrabarnett.plus.com>

On 2020-03-29 23:34, Steven Hobbs wrote:
> 
> Hi all,
> 
> I have installed Python 3.7.7 on Windows 10 and I understood that pip came installed. However when I try using pip I get an unrecognised command error.
> 
> I tried following the instructions on this website:
> https://docs.python.org/3/installing/index.html
> 
> However usage of pip as described at this website receives an unrecognised command error. I have also tried adding the python directory to the Path variable and running commands in the Python directory.
> 
> I have also tried this website without success:
> 
> https://pip.pypa.io/en/stable/installing/
> Installation ? pip 20.0.2 documentation
> Warning. Be cautious if you are using a Python install that is managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.
> pip.pypa.io
> 
> 
> Can I please have step by step instructions that have been verified to work with Windows 10 and Python 3.7.7 that list all requirements, dependencies and processes to install and run pip and then install libraries such as numpy and pillow.
> 
> 
> Any help would be greatly appreciated.
> 
I'd recommend using the pip module via the Python launcher instead:

py -m pip install numpy

If you have multiple Python versions installed, then you can specify 
which one you want to use, e.g. for Python 3.7:

py -3.7 -m pip install numpy

From miked at dewhirst.com.au  Sun Mar 29 20:41:02 2020
From: miked at dewhirst.com.au (Mike Dewhirst)
Date: Mon, 30 Mar 2020 11:41:02 +1100
Subject: How to uninstall Python3.7 in Windows using cmd ?
In-Reply-To: 
References: 
 
 <95a77f78-f293-b4a2-32b4-bbc477b0706e@dewhirst.com.au>
 
Message-ID: <711a47a2-feb6-921c-d80c-e90325e7bc38@dewhirst.com.au>

On 29/03/2020 10:24 pm, Terry Reedy wrote:
> On 3/29/2020 12:17 AM, Mike Dewhirst wrote:
>> On 29/03/2020 5:06 am, Terry Reedy wrote:
>>> On 3/27/2020 8:07 AM, deepalee khare wrote:
>>>
>>>> How to Uninstall Python3.7.3 using cmd ? i tried using cmd: Msiexec
>>>> /uninstall C:\Python37\python.exe But it gives me below error: enter
>>>> image description here
>>>
>>> Python is not currently installed with msi, hence cannot use it to 
>>> uninstall.? Images and attachments are not allowed.
>>>
>>>
>>
>> In that case install that same version of Python to the same location 
>> using msi 
>
> Just how do you propose that one do that?

I would first determine whether it is the 32 or 64 bit version which is 
installed. I would then visit www.python.org and download the exact same 
python executable installer. Don't know what msi is but it doesn't 
matter. I think it just means microsoft installer.

If you launch the installer in Windows and choose the custom install it 
will let you select the location. You should choose C:\Python37 as you 
have already noted.

It is possible/probable that the installer will detect your existing 
Python 3.7.x and offer to repair it. Some parts of Python may have been 
omitted from the original installation. With a custom installation the 
msi installer lets you tick boxes to decide which components to install. 
To cover the uninstallation bases I would tick them all and proceed to 
completion.

In (my) theory that will do the install and hopefully let you do an 
ordinary Windows uninstall.

I assume (?) the original installation put the usual Python components 
including dll libraries in the conventional places for Windows and the 
python.org executable installer will follow suit.

The uninstallation probably won't delete the C:\Python37 directory but 
you can do that yourself.

If all the above fails, you can delete C:\Python37 and all its content 
as a precursor and then go through the installation again and try 
uninstalling again.

If that fails just delete C:\Python37 and its contents and hope for the 
best.

Good luck

Mike

>
> - then remove it.
>
> To clarify, the pydev/python.org installer does not use msi.? I don't 
> know that anyone else does.? And if someone did, why do you think it 
> would also uninstall the current installation?
>


From miked at dewhirst.com.au  Sun Mar 29 21:01:37 2020
From: miked at dewhirst.com.au (Mike Dewhirst)
Date: Mon, 30 Mar 2020 12:01:37 +1100
Subject: Unable to install or operate PIP on Windows 10
In-Reply-To: 
References: 
 
Message-ID: <159a0abc-d01c-c56e-a787-dbdf6646028a@dewhirst.com.au>

On 30/03/2020 9:34 am, Steven Hobbs wrote:
> Hi all,
>
> I have installed Python 3.7.7 on Windows 10 and I understood that pip came installed. However when I try using pip I get an unrecognised command error.
>
> I tried following the instructions on this website:
> https://docs.python.org/3/installing/index.html
>
> However usage of pip as described at this website receives an unrecognised command error. I have also tried adding the python directory to the Path variable and running commands in the Python directory.
>
> I have also tried this website without success:
>
> https://pip.pypa.io/en/stable/installing/
> Installation ? pip 20.0.2 documentation
> Warning. Be cautious if you are using a Python install that is managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.
> pip.pypa.io
>
>
> Can I please have step by step instructions that have been verified to work with Windows 10 and Python 3.7.7 that list all requirements, dependencies and processes to install and run pip and then install libraries such as numpy and pillow.

I don't know about numpy but pillow on Windows is a pain because it is 
only available as source and pip want's to compile it. That is the pain. 
Pip needs to use a C compiler and Windows was never designed to make 
life easy for developers out of the box. You need to set up a dev 
environment yourself for that. HOWEVER all is not lost ...

Visit https://www.lfd.uci.edu/~gohlke/pythonlibs/ which is Christoph 
Gohlke's page of pre-compiled binaries for Windows. I couldn't use 
Windows without it. That man deserves a Nobel prize for generosity.

You will find a suitable Pillow installer there. To install all you do 
is execute it in the venv. But there is a better way if you need to 
install it only in particular venvs.

Use pip!

If you download the Pillow installer to your Windows downloads 
directory, here is a pip install incantation which works for me in an 
activated venv ...

python -m pip install 
D:\Users\mike/downloads/Pillow-6.0.0-cp37-cp37m-win_amd64.whl

Don't worry about my slashes and backslashes. That part of the above 
line is copied from a requirements file assembled by batch file. Pip 
doesn't care about the angle of the slash.

I think numpy people use Anaconda to install stuff. Not sure about that.

Good luck

Mike



>
>
> Any help would be greatly appreciated.
>
> Regards,
>
> Steven Hobbs


From torriem at gmail.com  Sun Mar 29 23:55:57 2020
From: torriem at gmail.com (Michael Torrie)
Date: Sun, 29 Mar 2020 21:55:57 -0600
Subject: How to uninstall Python3.7 in Windows using cmd ?
In-Reply-To: <711a47a2-feb6-921c-d80c-e90325e7bc38@dewhirst.com.au>
References: 
 
 <95a77f78-f293-b4a2-32b4-bbc477b0706e@dewhirst.com.au>
 
 <711a47a2-feb6-921c-d80c-e90325e7bc38@dewhirst.com.au>
Message-ID: 

On 3/29/20 6:41 PM, Mike Dewhirst wrote:
> I would first determine whether it is the 32 or 64 bit version which is 
> installed. I would then visit www.python.org and download the exact same 
> python executable installer. Don't know what msi is but it doesn't 
> matter. I think it just means microsoft installer.

I think you misread both Terry and the original poster.

What Terry was trying to say is that there is no MSI installer available
for python, so you cannot use the Microsoft MSI command line tool
(msiexec), which was what the original poster was asking about.  Thus
you cannot use msiexec.exe to remove Python by way of a batch file or
script. He'll have to do it a different way.

From miked at dewhirst.com.au  Mon Mar 30 02:20:33 2020
From: miked at dewhirst.com.au (Mike Dewhirst)
Date: Mon, 30 Mar 2020 17:20:33 +1100
Subject: How to uninstall Python3.7 in Windows using cmd ?
In-Reply-To: 
References: 
 
 <95a77f78-f293-b4a2-32b4-bbc477b0706e@dewhirst.com.au>
 
 <711a47a2-feb6-921c-d80c-e90325e7bc38@dewhirst.com.au>
 
Message-ID: <088a3954-17f6-a356-87e9-24d592a20427@dewhirst.com.au>

On 30/03/2020 2:55 pm, Michael Torrie wrote:
> On 3/29/20 6:41 PM, Mike Dewhirst wrote:
>> I would first determine whether it is the 32 or 64 bit version which is
>> installed. I would then visit www.python.org and download the exact same
>> python executable installer. Don't know what msi is but it doesn't
>> matter. I think it just means microsoft installer.
> I think you misread both Terry and the original poster.

Maybe so but the method I suggested should install Python in a way which 
Windows should be able to uninstall and clear out what was there 
previously. That is why I said "it doesn't matter".

I hope.

>
> What Terry was trying to say is that there is no MSI installer available
> for python, so you cannot use the Microsoft MSI command line tool
> (msiexec), which was what the original poster was asking about.  Thus
> you cannot use msiexec.exe to remove Python by way of a batch file or
> script. He'll have to do it a different way.


From __peter__ at web.de  Mon Mar 30 04:04:32 2020
From: __peter__ at web.de (Peter Otten)
Date: Mon, 30 Mar 2020 10:04:32 +0200
Subject: Textwrapping with paragraphs, was RE: Confusing textwrap parameters,
 and request for RE help
References: 
 <4d64ae5f-2e9c-e712-6fbd-f85e886a50a1@DancesWithMice.info>
 <20200325195253.GB32573@hjp.at>
 <51bf06b9-ad25-dfa4-960b-1eda2cbca70c@Damon-Family.org>
 <20200326190814.GA2122@hjp.at> 
 
 
 
 
 
 <576d30c9-7588-999a-0019-deaf4471e6a1@gmail.com>
 <20200327185047.bf189eac90c950d4fdab8a3a@potatochowder.com>
 
Message-ID: 

Steve Smith wrote:

> I am having the same issue. I can either get the text to wrap, which makes
> all the text wrap, or I can get the text to ignore independent '/n'
> characters, so that all the blank space is removed. I'd like to set up my
> code, so that only 1 blank space is remaining (I'll settle for none at
> this point), an the text wraps up to 100 chars or so out per line. Does
> anyone have any thoughts on the attached code? And what I'm not doing
> correctly?
> 
> 
> #import statements
> import textwrap
> import requests
> from bs4 import BeautifulSoup
> 
> #class extension of textwrapper
> class DocumentWrapper(textwrap.TextWrapper):
> 
>     def wrap(self, text):
>         split_text = text.split('\n')
>         lines = [line for para in split_text for line in
>         textwrap.TextWrapper.wrap(self, para)] return lines
> 
> #import statement of text.
> page = requests.get("http://classics.mit.edu/Aristotle/rhetoric.mb.txt")
> soup = BeautifulSoup(page.text, "html.parser")
> 
> #instantiation of extension of textwrap.wrap.
> d = DocumentWrapper(width=110,initial_indent='',fix_sentence_endings=True
> ) new_string = d.fill(page.text)
> 
> #set up an optional variable, even attempted applying BOTH the extended
> #method and the original method to the issue... nothing has worked.
> #new_string_2 = textwrap.wrap(new_string,90)
> 
> #with loop with JUST the class extension of textwrapper.
> with open("Art_of_Rhetoric.txt", "w") as f:
>     f.writelines(new_string)
> 
> #with loop with JUST the standard textwrapper.text method applied to it.
> with open("Art_of_Rhetoric2.txt", "w") as f:
>     f.writelines(textwrap.wrap(page.text,90))

I think in your case the problem is that newlines in the source text do not
indicate paragraphs -- thus you should not keep them. Instead try 
interpreting empty lines as paragraph separators:

$ cat tmp.py                
import sys
import textwrap
import itertools

import requests
from bs4 import BeautifulSoup


class DocumentWrapper(textwrap.TextWrapper):
    def wrap(self, text):
        paras = (
            "".join(group) for non_empty, group in itertools.groupby(
                text.splitlines(True),
                key=lambda line: bool(line.strip())
            ) if non_empty
        )
        wrap = super().wrap
        lines = [line for para in paras for line in wrap(para)]
        return lines


page = requests.get("http://classics.mit.edu/Aristotle/rhetoric.mb.txt").text

d = DocumentWrapper(width=110, initial_indent='', fix_sentence_endings=True)
new_string = d.fill(page)

sys.stdout.write(new_string)
$ python3 tmp.py | head -n10
Provided by The Internet Classics Archive.  See bottom for copyright.  Available online at
http://classics.mit.edu//Aristotle/rhetoric.html
Rhetoric By Aristotle
Translated by W. Rhys Roberts
----------------------------------------------------------------------
BOOK I
Part 1
Rhetoric is the counterpart of Dialectic.  Both alike are concerned with such things as come, more or less,
within the general ken of all men and belong to no definite science.  Accordingly all men make use, more or
less, of both; for to a certain extent all men attempt to discuss statements and to maintain them, to defend
Traceback (most recent call last):
  File "tmp.py", line 27, in 
    sys.stdout.write(new_string)
BrokenPipeError: [Errno 32] Broken pipe
$


From dcwhatthe at gmail.com  Mon Mar 30 11:25:32 2020
From: dcwhatthe at gmail.com (dcwhatthe at gmail.com)
Date: Mon, 30 Mar 2020 08:25:32 -0700 (PDT)
Subject: how to specify trusted hosts in windows config file
Message-ID: <0e6b2676-f38b-4a9c-b514-6f5fe447cd1b@googlegroups.com>

Hi,

I'm able to get past the 

CERTIFICATE_VERIFY_FAILED


error with various packages by specifying trusted host on the command line.


But I can't seem to upgrade pip itself.  I keep getting the message

"You are using pip version 19.2.3, however 20.0.2 is available."

But none of the commands on the web seem to be able to upgrade pip, without getting either the CERTIFICATE_VERIFY_FAILED error, or the above message.


There are mentions of a pip.ini file that can be edited bypass the Certificate errors.  But I've done a global search on my hard drive, and cannot locate this pip.ini.


Is there some way of simply downloading the latest pip version, and extracting into the python\scripts folder?






From rosuav at gmail.com  Mon Mar 30 12:08:26 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 31 Mar 2020 03:08:26 +1100
Subject: how to specify trusted hosts in windows config file
In-Reply-To: <0e6b2676-f38b-4a9c-b514-6f5fe447cd1b@googlegroups.com>
References: <0e6b2676-f38b-4a9c-b514-6f5fe447cd1b@googlegroups.com>
Message-ID: 

On Tue, Mar 31, 2020 at 2:31 AM  wrote:
>
> Hi,
>
> I'm able to get past the
>
> CERTIFICATE_VERIFY_FAILED
>
>
> error with various packages by specifying trusted host on the command line.
>
>
> But I can't seem to upgrade pip itself.  I keep getting the message
>
> "You are using pip version 19.2.3, however 20.0.2 is available."
>
> But none of the commands on the web seem to be able to upgrade pip, without getting either the CERTIFICATE_VERIFY_FAILED error, or the above message.
>

Before trying to solve the symptom, see what the underlying problem
is. Are you actually sure you're getting to the right server? Maybe
the actual problem is that you aren't able to connect to the true
PyPI, and that's what the cert failure is warning you of.

ChrisA

From python at mrabarnett.plus.com  Mon Mar 30 12:06:26 2020
From: python at mrabarnett.plus.com (MRAB)
Date: Mon, 30 Mar 2020 17:06:26 +0100
Subject: how to specify trusted hosts in windows config file
In-Reply-To: <0e6b2676-f38b-4a9c-b514-6f5fe447cd1b@googlegroups.com>
References: <0e6b2676-f38b-4a9c-b514-6f5fe447cd1b@googlegroups.com>
Message-ID: <31141301-1f56-d9b7-128a-1cc25a103483@mrabarnett.plus.com>

On 2020-03-30 16:25, dcwhatthe at gmail.com wrote:
> Hi,
> 
> I'm able to get past the
> 
> CERTIFICATE_VERIFY_FAILED
> 
> 
> error with various packages by specifying trusted host on the command line.
> 
> 
> But I can't seem to upgrade pip itself.  I keep getting the message
> 
> "You are using pip version 19.2.3, however 20.0.2 is available."
> 
> But none of the commands on the web seem to be able to upgrade pip, without getting either the CERTIFICATE_VERIFY_FAILED error, or the above message.
> 
> 
> There are mentions of a pip.ini file that can be edited bypass the Certificate errors.  But I've done a global search on my hard drive, and cannot locate this pip.ini.
> 
> 
> Is there some way of simply downloading the latest pip version, and extracting into the python\scripts folder?
> 
Have you tried:

py -m pip install --upgrade pip


From 2maxleedham at gmail.com  Mon Mar 30 09:44:23 2020
From: 2maxleedham at gmail.com (JimathyJim Jim)
Date: Mon, 30 Mar 2020 14:44:23 +0100
Subject: 0x80070643 python download error
Message-ID: 

I am trying to download python on my laptop and this error came up. How do
I fix this error appearing and download python 3.8.2?

From jaya16122000 at gmail.com  Mon Mar 30 10:01:46 2020
From: jaya16122000 at gmail.com (JAYA KANOJIYA)
Date: Mon, 30 Mar 2020 19:31:46 +0530
Subject: [baseline 1.0.0] Easy String Baseline
In-Reply-To: 
References: 
 
Message-ID: 

how can we complete this project......
For this project, you?ll create a ?word cloud? from a text by writing a
script. This script needs to process the text, remove punctuation, count
the frequencies, and ignore uninteresting or irrelevant words.

On Mon, Mar 30, 2020 at 6:00 PM Dan Gass  wrote:

> I am please to announce the availability of the first major release of the
> "baseline" package.
>
> This tool streamlines creation and maintenance of tests which compare
> string
> output against a baseline. It offers a mechanism to compare a string
> against
> a baselined copy and update the baselined copy to match the new value when
> a
> mismatch occurs. The update process includes a manual step to facilitate a
> review of the change before acceptance. The tool uses multi-line string
> format
> for string baselines to improve readability for human review.
>
> Docs: https://baseline.readthedocs.io/en/latest/
> PyPi: https://pypi.org/project/baseline/
> Repo: https://github.com/dmgass/baseline
>
> License: MIT
>
> With Regards,
> Dan Gass
> (dan.gass at gmail)
>
> ***********
> Changes
> ***********
>
> The following summarizes changes since the previous "beta" release (the
> major revision bump signifies backwards incompatible changes):
>
> + Improve baseline update when multiple values compared against the
>   same baseline. Generate a single multi-line baseline with headers
>   between the various alternative values. This facilitates updating
>   the baseline again.
>
> + Support Python 3.8. Previously, when run using 3.8, the baseline
>   update tool misplaced baseline updates in the first triple quoted
>   string found above the baseline. (Python 3.8 stack frames now
>   report the line number of the first line in a statement rather
>   than the last.)
>
> + Change behavior of ``Baseline`` to use raw strings when updating
>   baselines when possible to improve readability.
>
> + Deprecate ``RawBaseline`` since ``Baseline`` now incorporates
>   its behavior.
>
>
> ***********
> Quick Start
> ***********
>
> Create an empty baseline with a triple quoted multi-line string. Place
> the ending triple quote on a separate line and indent it to the level
> you wish the string baseline update to be indented to. Add a compare of
> the string being tested to the baseline string. Then save the file as
> ``fox.py``:
>
> .. code-block:: python
>
>     from baseline import Baseline
>
>     expected = Baseline("""
>         """)
>
>     test_string = """THE QUICK BROWN FOX
>         JUMPS
>     OVER THE LAZY DOG."""
>
>     assert test_string == expected
>
>
> Run ``fox.py`` and observe that the ``assert`` raises an exception since
> the strings are not equal.  Because the comparison failed, the tool located
> the triple quoted baseline string in the source file and updated it with
> the
> mis-compared value. When the interpreter exited, the tool saved the updated
> source file but changed the file name to ``fox.update.py``:
>
> .. code-block:: python
>
>     from baseline import Baseline
>
>     expected = Baseline("""
>         THE QUICK BROWN FOX
>             JUMPS
>         OVER THE LAZY DOG.
>         """)
>
>     test_string = """THE QUICK BROWN FOX
>         JUMPS
>     OVER THE LAZY DOG."""
>
>     assert test_string == expected
>
>
> After reviewing the change with your favorite file differencing tool,
> accept the change by either manually overwriting the original file or use
> the ``baseline`` command line tool to scan the directory for updated
> scripts and accept them:
>
> .. code-block:: shell
>
>     $ python -m baseline *
>     Found updates for:
>       fox.py
>
>     Hit [ENTER] to update, [Ctrl-C] to cancel
>
>     fox.update.py -> fox.py
>
>
> Run ``fox.py`` again and observe the ``assert`` does not raise an exception
> nor is a source file update generated. If in the future the test value
> changes, the ``assert`` will raise an exception and cause a new source file
> update to be generated. Simply repeat the review and acceptance step and
> you
> are back in business!
>
>
> https://baseline.readthedocs.io/en/latest/
> --
> Python-announce-list mailing list -- python-announce-list at python.org
> To unsubscribe send an email to python-announce-list-leave at python.org
> https://mail.python.org/mailman3/lists/python-announce-list.python.org/
>
>         Support the Python Software Foundation:
>         http://www.python.org/psf/donations/
>

From rosuav at gmail.com  Mon Mar 30 12:56:44 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 31 Mar 2020 03:56:44 +1100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 
 
 
 
 
 <576d30c9-7588-999a-0019-deaf4471e6a1@gmail.com>
 <20200327185047.bf189eac90c950d4fdab8a3a@potatochowder.com>
 
 
Message-ID: 

On Tue, Mar 31, 2020 at 3:53 AM Dennis Lee Bieber  wrote:
>
> On Sun, 29 Mar 2020 04:21:04 +0000, Steve Smith 
> declaimed the following:
>
> >I am having the same issue. I can either get the text to wrap, which makes all the text wrap, or I can get the text to ignore independent '/n' characters, so that all the blank space is removed. I'd like to set up my code, so that only 1 blank space is remaining (I'll settle for none at this point), an the text wraps up to 100 chars or so out per line. Does anyone have any thoughts on the attached code? And what I'm not doing correctly?
> >
> >
> >#import statements
> >import textwrap
> >import requests
> >from bs4 import BeautifulSoup
> >
> >#class extension of textwrapper
> >class DocumentWrapper(textwrap.TextWrapper):
> >
> >    def wrap(self, text):
> >        split_text = text.split('\n')
> >        lines = [line for para in split_text for line in textwrap.TextWrapper.wrap(self, para)]
>
>         That... Looks rather incorrect.
>
>         In most all list-comprehensions, the result item is on the left, and
> the rest is the iteration clause... And why the (self, ...)? You inherited
> from textwrap.TextWrapper, yet here you bypass the inherited to invoke the
> wrap method (without instantiating it!).
>

I think this is a reasonable thing to do, but an awkward way to spell
it. If you mean to call the original wrap method, it would normally be
spelled super().wrap(para) instead.

Is that what you were intending, Steve?

ChrisA

From rosuav at gmail.com  Mon Mar 30 13:03:53 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 31 Mar 2020 04:03:53 +1100
Subject: [baseline 1.0.0] Easy String Baseline
In-Reply-To: 
References: 
 
 
Message-ID: 

On Tue, Mar 31, 2020 at 4:01 AM JAYA KANOJIYA  wrote:
>
> how can we complete this project......
> For this project, you?ll create a ?word cloud? from a text by writing a
> script. This script needs to process the text, remove punctuation, count
> the frequencies, and ignore uninteresting or irrelevant words.
>

You're replying to an unrelated post to ask for homework help.

Recommendation: Do your own homework. Reread your study materials and
*do the work*. You can't become a programmer by asking people to write
your code for you.

ChrisA

From dcwhatthe at gmail.com  Mon Mar 30 13:13:52 2020
From: dcwhatthe at gmail.com (dcwhatthe at gmail.com)
Date: Mon, 30 Mar 2020 10:13:52 -0700 (PDT)
Subject: how to specify trusted hosts in windows config file
In-Reply-To: 
References: <0e6b2676-f38b-4a9c-b514-6f5fe447cd1b@googlegroups.com>
 <31141301-1f56-d9b7-128a-1cc25a103483@mrabarnett.plus.com>
 
Message-ID: 

On Monday, March 30, 2020 at 12:09:48 PM UTC-4, MRAB wrote:
> On 2020-03-30 16:25, dcwhatthe wrote:
> > Hi,
> > 
> > I'm able to get past the
> > 
> > CERTIFICATE_VERIFY_FAILED
> > 
> > 
> > error with various packages by specifying trusted host on the command line.
> > 
> > 
> > But I can't seem to upgrade pip itself.  I keep getting the message
> > 
> > "You are using pip version 19.2.3, however 20.0.2 is available."
> > 
> > But none of the commands on the web seem to be able to upgrade pip, without getting either the CERTIFICATE_VERIFY_FAILED error, or the above message.
> > 
> > 
> > There are mentions of a pip.ini file that can be edited bypass the Certificate errors.  But I've done a global search on my hard drive, and cannot locate this pip.ini.
> > 
> > 
> > Is there some way of simply downloading the latest pip version, and extracting into the python\scripts folder?
> > 
> Have you tried:
> 
> py -m pip install --upgrade pip

Yes.  CERTIFICATE error.

From dcwhatthe at gmail.com  Mon Mar 30 13:15:24 2020
From: dcwhatthe at gmail.com (dcwhatthe at gmail.com)
Date: Mon, 30 Mar 2020 10:15:24 -0700 (PDT)
Subject: how to specify trusted hosts in windows config file
In-Reply-To: 
References: <0e6b2676-f38b-4a9c-b514-6f5fe447cd1b@googlegroups.com>
 
 
Message-ID: <4b2c759f-34bf-4b25-962f-804e11e2534c@googlegroups.com>

On Monday, March 30, 2020 at 12:08:54 PM UTC-4, Chris Angelico wrote:
> On Tue, Mar 31, 2020 at 2:31 AM wrote:
> >
> > Hi,
> >
> > I'm able to get past the
> >
> > CERTIFICATE_VERIFY_FAILED
> >
> >
> > error with various packages by specifying trusted host on the command line.
> >
> >
> > But I can't seem to upgrade pip itself.  I keep getting the message
> >
> > "You are using pip version 19.2.3, however 20.0.2 is available."
> >
> > But none of the commands on the web seem to be able to upgrade pip, without getting either the CERTIFICATE_VERIFY_FAILED error, or the above message.
> >
> 
> Before trying to solve the symptom, see what the underlying problem
> is. Are you actually sure you're getting to the right server? Maybe
> the actual problem is that you aren't able to connect to the true
> PyPI, and that's what the cert failure is warning you of.
> 
> ChrisA

Hi ChrisA,

Nope, I'm not certain.  I just copied and pasted a command line on the web.  The command line doesn't specify a server.


From rosuav at gmail.com  Mon Mar 30 13:33:56 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 31 Mar 2020 04:33:56 +1100
Subject: how to specify trusted hosts in windows config file
In-Reply-To: <4b2c759f-34bf-4b25-962f-804e11e2534c@googlegroups.com>
References: <0e6b2676-f38b-4a9c-b514-6f5fe447cd1b@googlegroups.com>
 
 
 <4b2c759f-34bf-4b25-962f-804e11e2534c@googlegroups.com>
Message-ID: 

On Tue, Mar 31, 2020 at 4:21 AM  wrote:
>
> On Monday, March 30, 2020 at 12:08:54 PM UTC-4, Chris Angelico wrote:
> > On Tue, Mar 31, 2020 at 2:31 AM wrote:
> > >
> > > Hi,
> > >
> > > I'm able to get past the
> > >
> > > CERTIFICATE_VERIFY_FAILED
> > >
> > >
> > > error with various packages by specifying trusted host on the command line.
> > >
> > >
> > > But I can't seem to upgrade pip itself.  I keep getting the message
> > >
> > > "You are using pip version 19.2.3, however 20.0.2 is available."
> > >
> > > But none of the commands on the web seem to be able to upgrade pip, without getting either the CERTIFICATE_VERIFY_FAILED error, or the above message.
> > >
> >
> > Before trying to solve the symptom, see what the underlying problem
> > is. Are you actually sure you're getting to the right server? Maybe
> > the actual problem is that you aren't able to connect to the true
> > PyPI, and that's what the cert failure is warning you of.
> >
> > ChrisA
>
> Hi ChrisA,
>
> Nope, I'm not certain.  I just copied and pasted a command line on the web.  The command line doesn't specify a server.
>

First off, try adding the "--verbose" option to pip, which should tell
you the exact URLs that it's trying to download (which, in effect,
will tell you the servers). When I do that, I'm seeing two key
servers: pypi.org (https://pypi.org/simple/pip/) and
files.pythonhosted.org (lots of
https://files.pythonhosted.org/packages/.... URLs). When I look up
those names, I get these results:

pypi.org. 86278 IN A 151.101.192.223
pypi.org. 86278 IN A 151.101.64.223
pypi.org. 86278 IN A 151.101.128.223
pypi.org. 86278 IN A 151.101.0.223

files.pythonhosted.org. 86400 IN CNAME dualstack.r.ssl.global.fastly.net.
dualstack.r.ssl.global.fastly.net. 30 IN A 151.101.81.63

Check two things: firstly, do your URLs show the same domains? And
secondly, are you connecting to the same IP addresses? If either of
those is different, it's possible that you have a local PyPI mirror,
or (more likely) something is blocking those requests and silently
redirecting them to something else, such as a login page. But at that
point, it's impossible to guess at anything, so start with the above.

ChrisA

From dcwhatthe at gmail.com  Mon Mar 30 14:43:41 2020
From: dcwhatthe at gmail.com (dcwhatthe at gmail.com)
Date: Mon, 30 Mar 2020 11:43:41 -0700 (PDT)
Subject: how to specify trusted hosts in windows config file
In-Reply-To: <3824255550@f38.n261.z1.binkp.net>
References: <3824255550@f38.n261.z1.binkp.net>
Message-ID: <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com>

These are some of the command lines I've typed, and the results.  It looks like it's going to https://pypi.org.

I have no idea whether that's correct, or not.

I'm able to get past the Certificate error with other packages like requests.  But I just can't update pip.

:


[C:\TCMD25]python -m pip install  --trusted-host pypi.org --trusted-host --upgrade pip
Requirement already satisfied: pip in c:\users\blahblah\appdata\local\programs\python\python38-32\lib\site-packages (19.2.3)
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.


[C:\......\Python\Python38-32\Scripts]python -m pip install --verbose --trusted-host pypi.org --trusted-host --upgrade pip
Created temporary directory: ...
Created requirements tracker ...
Requirement already satisfied: pip in c:\users\dBlah2\appdata\local\programs\python\python38-32\lib\site-packages (19.2.3)
Cleaning up...
Removed build tracker 'C:\\Users\\DBlah2\\AppData\\Local\\Temp\\pip-req-tracker-1djqfhix'
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.



[C:\......\Python\Python38-32\Scripts]python -m pip --verbose install --upgrade pip
Created temporary directory: ...
Created requirements tracker ...
1 location(s) to search for versions of pip:
* https://pypi.org/simple/pip/
Getting page https://pypi.org/simple/pip/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/pip/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
Incremented Retry for (url='/simple/pip/'): Retry(total=4, connect=None, read=None, redirect=None, status=None)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFIC
ATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pip/
Starting new HTTPS connection (2): pypi.org:443
Incremented Retry for (url='/simple/pip/'): Retry(total=3, connect=None, read=None, redirect=None, status=None)
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFIC
ATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pip/
Starting new HTTPS connection (3): pypi.org:443
Incremented Retry for (url='/simple/pip/'): Retry(total=2, connect=None, read=None, redirect=None, status=None)
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFIC
ATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pip/
Starting new HTTPS connection (4): pypi.org:443
Incremented Retry for (url='/simple/pip/'): Retry(total=1, connect=None, read=None, redirect=None, status=None)
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFIC
ATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pip/
Starting new HTTPS connection (5): pypi.org:443
Incremented Retry for (url='/simple/pip/'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFIC
ATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)'))': /simple/pip/
Starting new HTTPS connection (6): pypi.org:443
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceed
ed with url: /simple/pip/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certif
icate (_ssl.c:1108)'))) - skipping
Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
Given no hashes to check 0 links for project 'pip': discarding no candidates
Installed version (19.2.3) is most up-to-date (past versions: none)
Requirement already up-to-date: pip in c:\users\dBlah2\appdata\local\programs\python\python38-32\lib\site-packages (19.2.3)
Cleaning up...
Removed build tracker 'C:\\Users\\DBlah2\\AppData\\Local\\Temp\\pip-req-tracker-x0doslyv'
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.




From rosuav at gmail.com  Mon Mar 30 14:49:27 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 31 Mar 2020 05:49:27 +1100
Subject: how to specify trusted hosts in windows config file
In-Reply-To: <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com>
References: <3824255550@f38.n261.z1.binkp.net>
 <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com>
Message-ID: 

On Tue, Mar 31, 2020 at 5:46 AM  wrote:
>
> These are some of the command lines I've typed, and the results.  It looks like it's going to https://pypi.org.
>
> I have no idea whether that's correct, or not.
>
> I'm able to get past the Certificate error with other packages like requests.  But I just can't update pip.
>

That is the correct domain name. The question is, does it translate to
the correct IP address? Try doing a DNS lookup and compare it to the
results I got.

And, don't think in terms of *getting past the error*. Try to solve
the actual problem. The certificate error is protecting you against
installing a forged version of PIP.

ChrisA

From pieter-l at vanoostrum.org  Mon Mar 30 17:14:50 2020
From: pieter-l at vanoostrum.org (Pieter van Oostrum)
Date: Mon, 30 Mar 2020 23:14:50 +0200
Subject: 0x80070643 python download error
References: 
 
Message-ID: 

JimathyJim Jim <2maxleedham at gmail.com> writes:

> I am trying to download python on my laptop and this error came up. How do
> I fix this error appearing and download python 3.8.2?

Maybe you could specify what OS, and from what site/URL you are downloading. And at which moment the error appears.
-- 
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

From __peter__ at web.de  Mon Mar 30 17:18:50 2020
From: __peter__ at web.de (Peter Otten)
Date: Mon, 30 Mar 2020 23:18:50 +0200
Subject: Confusing textwrap parameters, and request for RE help
References: 
 
 
 
 
 
 <576d30c9-7588-999a-0019-deaf4471e6a1@gmail.com>
 <20200327185047.bf189eac90c950d4fdab8a3a@potatochowder.com>
 
 
 
Message-ID: 

Chris Angelico wrote:

[Steve]

>>>    def wrap(self, text):
>>>        split_text = text.split('\n')
>>>        lines = [line for para in split_text for line in 
textwrap.TextWrapper.wrap(self, para)]

[Dennis]
>>         That... Looks rather incorrect.
>>
>>         In most all list-comprehensions, the result item is on the left, 
and
>> the rest is the iteration clause... And why the (self, ...)? You 
inherited
>> from textwrap.TextWrapper, yet here you bypass the inherited to invoke 
the
>> wrap method (without instantiating it!).

> I think this is a reasonable thing to do, 

Indeed, Steve's trying to apply the superclass algo on every paragraph of 
the text.

> but an awkward way to spell it. If you mean to call the original wrap
> method, it would normally be spelled super().wrap(para) instead.

Probably a workaround because super() cannot do its magic in the list 
comprehensions namespace. Another workaround is to define

wrap = super().wrap

and then use just wrap() in the listcomp.


From dcwhatthe at gmail.com  Mon Mar 30 17:17:34 2020
From: dcwhatthe at gmail.com (dcwhatthe at gmail.com)
Date: Mon, 30 Mar 2020 14:17:34 -0700 (PDT)
Subject: how to specify trusted hosts in windows config file
In-Reply-To: 
References: <3824255550@f38.n261.z1.binkp.net>
 <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com>
 
 
Message-ID: <74b889d7-c1dd-45ae-adec-b73ddb215118@googlegroups.com>

On Monday, March 30, 2020 at 2:49:55 PM UTC-4, Chris Angelico wrote:
> On Tue, Mar 31, 2020 at 5:46 AM dc wrote:
> >
> > These are some of the command lines I've typed, and the results.  It looks like it's going to https://pypi.org.
> >
> > I have no idea whether that's correct, or not.
> >
> > I'm able to get past the Certificate error with other packages like requests.  But I just can't update pip.
> >
> 
> That is the correct domain name. The question is, does it translate to
> the correct IP address? Try doing a DNS lookup and compare it to the
> results I got.
> 
> And, don't think in terms of *getting past the error*. Try to solve
> the actual problem. The certificate error is protecting you against
> installing a forged version of PIP.
> 
> ChrisA

For pypi.org alone, my dns lookup differs from yours:  151.101.128.223.

Chris,

Is there a way to just install pip manually, and bypass all this?  I mean, if we know we're downloading it from the appropriate ftp or git site, then doesn't that in itself avoid a faulty PIP version?


From rosuav at gmail.com  Mon Mar 30 17:32:49 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 31 Mar 2020 08:32:49 +1100
Subject: Confusing textwrap parameters, and request for RE help
In-Reply-To: 
References: 
 
 
 
 
 
 <576d30c9-7588-999a-0019-deaf4471e6a1@gmail.com>
 <20200327185047.bf189eac90c950d4fdab8a3a@potatochowder.com>
 
 
 
 
Message-ID: 

On Tue, Mar 31, 2020 at 8:20 AM Peter Otten <__peter__ at web.de> wrote:
>
> Chris Angelico wrote:
> > but an awkward way to spell it. If you mean to call the original wrap
> > method, it would normally be spelled super().wrap(para) instead.
>
> Probably a workaround because super() cannot do its magic in the list
> comprehensions namespace. Another workaround is to define
>
> wrap = super().wrap
>
> and then use just wrap() in the listcomp.
>

Ah ha, I didn't think of that. And yes, I would agree, that's probably
the cleanest way. Alternatively, the longhand super(__class__, self)
should work too, as I believe __class__ isn't redefined by the
implicit closure.

ChrisA

From rosuav at gmail.com  Mon Mar 30 17:35:35 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 31 Mar 2020 08:35:35 +1100
Subject: how to specify trusted hosts in windows config file
In-Reply-To: <74b889d7-c1dd-45ae-adec-b73ddb215118@googlegroups.com>
References: <3824255550@f38.n261.z1.binkp.net>
 <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com>
 
 
 <74b889d7-c1dd-45ae-adec-b73ddb215118@googlegroups.com>
Message-ID: 

On Tue, Mar 31, 2020 at 8:21 AM  wrote:
>
> On Monday, March 30, 2020 at 2:49:55 PM UTC-4, Chris Angelico wrote:
> > On Tue, Mar 31, 2020 at 5:46 AM dc wrote:
> > >
> > > These are some of the command lines I've typed, and the results.  It looks like it's going to https://pypi.org.
> > >
> > > I have no idea whether that's correct, or not.
> > >
> > > I'm able to get past the Certificate error with other packages like requests.  But I just can't update pip.
> > >
> >
> > That is the correct domain name. The question is, does it translate to
> > the correct IP address? Try doing a DNS lookup and compare it to the
> > results I got.
> >
> > And, don't think in terms of *getting past the error*. Try to solve
> > the actual problem. The certificate error is protecting you against
> > installing a forged version of PIP.
> >
> > ChrisA
>
> For pypi.org alone, my dns lookup differs from yours:  151.101.128.223.
>
> Chris,
>
> Is there a way to just install pip manually, and bypass all this?  I mean, if we know we're downloading it from the appropriate ftp or git site, then doesn't that in itself avoid a faulty PIP version?
>

Ahh, I think I see what's happening. Something's interfering with your
DNS - that's a Fastly IP address. I think the best solution would be
to undo or bypass whatever's messing with your network, and then
you'll be able to use pip normally without any sort of issues.

ChrisA

From dcwhatthe at gmail.com  Tue Mar 31 05:48:34 2020
From: dcwhatthe at gmail.com (dcwhatthe at gmail.com)
Date: Tue, 31 Mar 2020 02:48:34 -0700 (PDT)
Subject: how to specify trusted hosts in windows config file
In-Reply-To: 
References: <3824255550@f38.n261.z1.binkp.net>
 <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com>
 
 
 <74b889d7-c1dd-45ae-adec-b73ddb215118@googlegroups.com>
 
 
Message-ID: 

On Monday, March 30, 2020 at 5:36:00 PM UTC-4, Chris Angelico wrote:
> On Tue, Mar 31, 2020 at 8:21 AM  wrote:
> >
> > On Monday, March 30, 2020 at 2:49:55 PM UTC-4, Chris Angelico wrote:
> > > On Tue, Mar 31, 2020 at 5:46 AM dc wrote:
> > > >
> > > > These are some of the command lines I've typed, and the results.  It looks like it's going to https://pypi.org.
> > > >
> > > > I have no idea whether that's correct, or not.
> > > >
> > > > I'm able to get past the Certificate error with other packages like requests.  But I just can't update pip.
> > > >
> > >
> > > That is the correct domain name. The question is, does it translate to
> > > the correct IP address? Try doing a DNS lookup and compare it to the
> > > results I got.
> > >
> > > And, don't think in terms of *getting past the error*. Try to solve
> > > the actual problem. The certificate error is protecting you against
> > > installing a forged version of PIP.
> > >
> > > ChrisA
> >
> > For pypi.org alone, my dns lookup differs from yours:  151.101.128.223.
> >
> > Chris,
> >
> > Is there a way to just install pip manually, and bypass all this?  I mean, if we know we're downloading it from the appropriate ftp or git site, then doesn't that in itself avoid a faulty PIP version?
> >
> 
> Ahh, I think I see what's happening. Something's interfering with your
> DNS - that's a Fastly IP address. I think the best solution would be
> to undo or bypass whatever's messing with your network, and then
> you'll be able to use pip normally without any sort of issues.
> 
> ChrisA

Which is what I thought I was trying to do.

Why does the latest Python come with an earlier version of pip, to begin with?

Maybe I can update pip on another Win10 PC, identify the changed folders, and copy them over.

From dcwhatthe at gmail.com  Tue Mar 31 06:18:58 2020
From: dcwhatthe at gmail.com (dcwhatthe at gmail.com)
Date: Tue, 31 Mar 2020 03:18:58 -0700 (PDT)
Subject: how to specify trusted hosts in windows config file
In-Reply-To: 
References: <3824255550@f38.n261.z1.binkp.net>
 <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com>
 
 
 <74b889d7-c1dd-45ae-adec-b73ddb215118@googlegroups.com>
 
 
 
Message-ID: 

On Tuesday, March 31, 2020 at 5:48:50 AM UTC-4, dcwh... at gmail.com wrote:
> On Monday, March 30, 2020 at 5:36:00 PM UTC-4, Chris Angelico wrote:
> > On Tue, Mar 31, 2020 at 8:21 AM  wrote:
> > >
> > > On Monday, March 30, 2020 at 2:49:55 PM UTC-4, Chris Angelico wrote:
> > > > On Tue, Mar 31, 2020 at 5:46 AM dc wrote:
> > > > >
> > > > > These are some of the command lines I've typed, and the results.  It looks like it's going to https://pypi.org.
> > > > >
> > > > > I have no idea whether that's correct, or not.
> > > > >
> > > > > I'm able to get past the Certificate error with other packages like requests.  But I just can't update pip.
> > > > >
> > > >
> > > > That is the correct domain name. The question is, does it translate to
> > > > the correct IP address? Try doing a DNS lookup and compare it to the
> > > > results I got.
> > > >
> > > > And, don't think in terms of *getting past the error*. Try to solve
> > > > the actual problem. The certificate error is protecting you against
> > > > installing a forged version of PIP.
> > > >
> > > > ChrisA
> > >
> > > For pypi.org alone, my dns lookup differs from yours:  151.101.128.223.
> > >
> > > Chris,
> > >
> > > Is there a way to just install pip manually, and bypass all this?  I mean, if we know we're downloading it from the appropriate ftp or git site, then doesn't that in itself avoid a faulty PIP version?
> > >
> > 
> > Ahh, I think I see what's happening. Something's interfering with your
> > DNS - that's a Fastly IP address. I think the best solution would be
> > to undo or bypass whatever's messing with your network, and then
> > you'll be able to use pip normally without any sort of issues.
> > 
> > ChrisA
> 
> Which is what I thought I was trying to do.
> 
> Why does the latest Python come with an earlier version of pip, to begin with?
> 
> Maybe I can update pip on another Win10 PC, identify the changed folders, and copy them over.

Finally got it.  Damn, this was a nightmare:


python get-pip.py --trusted-host pypi.org --trusted-host files.pythonhosted.org

Collecting pip
  Downloading pip-20.0.2-py2.py3-none-any.whl (1.4 MB)
     |????????????????????????????????| 1.4 MB 64 kB/s
Collecting wheel
  Downloading wheel-0.34.2-py2.py3-none-any.whl (26 kB)
Installing collected packages: pip, wheel
  Attempting uninstall: pip
    Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
Successfully installed pip-20.0.2 wheel-0.34.2


From rosuav at gmail.com  Tue Mar 31 06:37:20 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Tue, 31 Mar 2020 21:37:20 +1100
Subject: how to specify trusted hosts in windows config file
In-Reply-To: 
References: <3824255550@f38.n261.z1.binkp.net>
 <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com>
 
 
 <74b889d7-c1dd-45ae-adec-b73ddb215118@googlegroups.com>
 
 
 
Message-ID: 

On Tue, Mar 31, 2020 at 8:51 PM  wrote:
>
> On Monday, March 30, 2020 at 5:36:00 PM UTC-4, Chris Angelico wrote:
> > On Tue, Mar 31, 2020 at 8:21 AM  wrote:
> > >
> > > On Monday, March 30, 2020 at 2:49:55 PM UTC-4, Chris Angelico wrote:
> > > > On Tue, Mar 31, 2020 at 5:46 AM dc wrote:
> > > > >
> > > > > These are some of the command lines I've typed, and the results.  It looks like it's going to https://pypi.org.
> > > > >
> > > > > I have no idea whether that's correct, or not.
> > > > >
> > > > > I'm able to get past the Certificate error with other packages like requests.  But I just can't update pip.
> > > > >
> > > >
> > > > That is the correct domain name. The question is, does it translate to
> > > > the correct IP address? Try doing a DNS lookup and compare it to the
> > > > results I got.
> > > >
> > > > And, don't think in terms of *getting past the error*. Try to solve
> > > > the actual problem. The certificate error is protecting you against
> > > > installing a forged version of PIP.
> > > >
> > > > ChrisA
> > >
> > > For pypi.org alone, my dns lookup differs from yours:  151.101.128.223.
> > >
> > > Chris,
> > >
> > > Is there a way to just install pip manually, and bypass all this?  I mean, if we know we're downloading it from the appropriate ftp or git site, then doesn't that in itself avoid a faulty PIP version?
> > >
> >
> > Ahh, I think I see what's happening. Something's interfering with your
> > DNS - that's a Fastly IP address. I think the best solution would be
> > to undo or bypass whatever's messing with your network, and then
> > you'll be able to use pip normally without any sort of issues.
> >
> > ChrisA
>
> Which is what I thought I was trying to do.
>
> Why does the latest Python come with an earlier version of pip, to begin with?

Because the latest Python is older than the latest pip.

> Finally got it.  Damn, this was a nightmare:
>
> python get-pip.py --trusted-host pypi.org --trusted-host files.pythonhosted.org

What you just did was say "hey, I know that I'm being lied to about
where pypi.org is, but I'm going to pretend that it's perfect". Do you
REALLY trust it so much that you would ignore the protections of SSL
certificates? You just installed something onto your computer without
knowing that it's what it claims to be. For all you know, that could
be a forged version of pip that has anything at all in it.

It would be FAR better to actually fix the problem - change your DNS
settings so you actually get the true server.

ChrisA

From nicolas.maratclimb at gmail.com  Tue Mar 31 06:43:28 2020
From: nicolas.maratclimb at gmail.com (Nicolas Marat)
Date: Tue, 31 Mar 2020 03:43:28 -0700 (PDT)
Subject: my matplotlib realtime plot doesn't show the line between the points
Message-ID: 

hi guys, i need help because my matplotlib realtime plot doesn't show the line between the points.
even if i right '.k-' 
thit plot is display in a qwidget in an other code
wirdely that if i put bar it actualy working.
the real time data come from an arduino sensor 
that the shape of the data i have to plot:

    ser_bytes = ser.readline()
    value = float(ser_bytes[0:len(ser_bytes)-2].decode("utf-8"))




that is my code: 

class MplWidget(QWidget ):
    
    
    def __init__( self, parent = None):

        QWidget.__init__(self, parent)
        
        self.canvas = FigureCanvas(Figure())
        
        vertical_layout = QVBoxLayout() 
        vertical_layout.addWidget(self.canvas)
        
        self.canvas.axes = self.canvas.figure.add_subplot(1,1,1)
        self.canvas.axes.set_ylim(0,90)
        self.canvas.axes.set_xlim(0,100)
        self.setLayout(vertical_layout)
       
        
    def update_graph(self, value):
        
        y = list()
        x = list()


        y.append(value)
        x.append(self.i)
                             
        self.i += 1
        
       
        self.MplWidget.canvas.axes.set_xlim(left=max(0, self.i-40), right= self.i+60)
        self.MplWidget.canvas.axes.bar(x, y,)#'.k-')
        self.MplWidget.canvas.axes.set_title('pull') 
        self.MplWidget.canvas.draw()



thanks for help!
        

From nicolas.maratclimb at gmail.com  Tue Mar 31 06:54:27 2020
From: nicolas.maratclimb at gmail.com (Nicolas Marat)
Date: Tue, 31 Mar 2020 03:54:27 -0700 (PDT)
Subject: my matplotlib realtime plot doesn't show the line between the
 points
In-Reply-To: 
References: 
Message-ID: <6657d87a-749c-4316-9226-e0064bc56f89@googlegroups.com>

sorry that the real piece of code




        self.MplWidget.canvas.axes.set_xlim(left=max(0, self.i-40), right= self.i+60)
        self.MplWidget.canvas.axes.plot(x, y,'.k-')
        self.MplWidget.canvas.axes.set_title('pull')
        self.MplWidget.canvas.draw()

From audisantosh at gmail.com  Tue Mar 31 01:55:32 2020
From: audisantosh at gmail.com (Santosh Reddy)
Date: Tue, 31 Mar 2020 11:25:32 +0530
Subject: error in running python
Message-ID: 

i installed python and when i open the app, i get this

the code execution cannot proceed because python38.dll was not found.
reinstalling the proram may fix this problem.

please help me in this one.

From kapugantirakesh123 at gmail.com  Tue Mar 31 02:23:49 2020
From: kapugantirakesh123 at gmail.com (Kapuganti Rakesh)
Date: Tue, 31 Mar 2020 11:53:49 +0530
Subject: about to resolve problem in installation
Message-ID: 

Respected sir,
                     I have downloaded the latest version of python 3.8.2
in my windows 10. I have installed that.After completion of installation
process it is displaying three options of modify,repair and uninstall. How
to resolve that issue. please help me
                                           Thanking You

From if.only at outlook.com  Tue Mar 31 01:56:27 2020
From: if.only at outlook.com (if only)
Date: Tue, 31 Mar 2020 05:56:27 +0000
Subject: Not Running from Kindle
Message-ID: 

I?m following the Kindle download and get to writing hello world but that does not get to my command window?


J Carrod

Sent from Mail for Windows 10


From dasydong at gmail.com  Tue Mar 31 04:13:18 2020
From: dasydong at gmail.com (Dasy Dong)
Date: Tue, 31 Mar 2020 16:13:18 +0800
Subject: [baseline 1.0.0] Easy String Baseline
In-Reply-To: 
References: 
 
Message-ID: 

>
> I am please to  share you with a interview summary[Chinese Language] about
> python.
> Mainly covering backend architecture  including python principle, design
> patterns , data structure, Git, Redis, MySql, Spider, ELK,Kafka, Istio,
> Kubernetes...
> I will keep updating contents future , If you love the  Chinese version,
> welcome  to join contribution
>
> Repo: https://github.com/DasyDong/interview_python_practice/
>
> With Regards
> Dasy
> --
> Python-announce-list mailing list -- python-announce-list at python.org
> To unsubscribe send an email to python-announce-list-leave at python.org
> https://mail.python.org/mailman3/lists/python-announce-list.python.org/
>
>         Support the Python Software Foundation:
>         http://www.python.org/psf/donations/
>

From yaswanthjami2512 at gmail.com  Tue Mar 31 06:23:06 2020
From: yaswanthjami2512 at gmail.com (Jami Yaswanth)
Date: Tue, 31 Mar 2020 15:53:06 +0530
Subject: error in importing
Message-ID: 

i am not able to use the libraries that are installed
using "pip install pandas"

From mal at europython.eu  Tue Mar 31 07:52:49 2020
From: mal at europython.eu (M.-A. Lemburg)
Date: Tue, 31 Mar 2020 13:52:49 +0200
Subject: EuroPython 2020: Online conference from July 23-26
Message-ID: 

In the last two weeks, we have discussed and investigated concepts
around running this year?s EuroPython conference as an online
conference. We have looked at conference tools, your feedback, drafted
up ideas on what we can do to make the event interesting and what we
can accomplish given our limited resources.

Today, we are happy to announce that we will be running


			 * EuroPython 2020 *

			from July 23 - 26 2020
		       as an online conference


We are planning the following structure:

- 2 conference days with keynotes, talks, lightning talks, poster
  session (Thursday and Friday)

- 2 sprint days with multiple sprint teams (Saturday and Sunday)

Attending the conference days will require a ticket, participating in
the sprint days will be free.


We will publish additional information on the new format as it becomes
available. A few updates for today (more details will follow in
separate blog posts):

Call for Papers (CFP)
---------------------

With the new plan in place, we will extend and retarget the CFP we had
been running in the last three weeks to the online setup.

Please note that we will not have training sessions at EuroPython
2020. We will have keynotes, 30 and 45-minute talks, panels,
interactive sessions, as well as try to come up with a format for
doing posters and lightning talks.

Unlike for our in-person event, speakers will get free tickets to the
event, since we don?t have to cover catering costs.

We need your help
-----------------

Given that we had already put a lot of work into the in-person event
organization, a lot of which we?ll now have to adapt or redo for the
online set up in the few months ahead of us, we will need more help
from the community to make this happen.

If you would like to help, please write to board at europython.eu. We are
specifically looking for people with experience using online
conference tools to help host tracks during the conference days.

Sponsoring
----------

As for the in-person event, we will have sponsorship packages
available for the online event as well. Because the format is
different, we?ll have to adjust the packages we had intended for the
in-person to an online setup.

If you are interested in sponsoring EuroPython 2020, please write to
sponsoring at europython.eu. We will then send you more details, as they
become available.


Help spread the word
--------------------

Please help us spread this message by sharing it on your social
networks as widely as possible. Thank you !

Link to the blog post:

https://blog.europython.eu/post/614102095419850752/europython-2020-online-conference-from-july-23-26

Tweet:

https://twitter.com/europython/status/1244947459006173184

Thanks,
--
EuroPython 2020 Team
https://ep2020.europython.eu/
https://www.europython-society.org/


From souvik.viksou at gmail.com  Tue Mar 31 08:29:37 2020
From: souvik.viksou at gmail.com (Souvik Dutta)
Date: Tue, 31 Mar 2020 17:59:37 +0530
Subject: error in running python
In-Reply-To: 
References: 
Message-ID: 

Do you have direct X installed in your machine?

On Tue, Mar 31, 2020, 5:44 PM Santosh Reddy  wrote:

> i installed python and when i open the app, i get this
>
> the code execution cannot proceed because python38.dll was not found.
> reinstalling the proram may fix this problem.
>
> please help me in this one.
> --
> https://mail.python.org/mailman/listinfo/python-list
>

From cspealma at redhat.com  Tue Mar 31 09:14:58 2020
From: cspealma at redhat.com (Calvin Spealman)
Date: Tue, 31 Mar 2020 09:14:58 -0400
Subject: Not Running from Kindle
In-Reply-To: 
References: 
Message-ID: 

There is no official Python app download for Kindle fire. If that's what
you've found and are trying to use, you'll need to contact the developer
responsible. If you want the official distribution of Python, you can
download it from python.org on a Windows, Mac, or Linux PC.

On Tue, Mar 31, 2020 at 8:26 AM if only  wrote:

> I?m following the Kindle download and get to writing hello world but that
> does not get to my command window?
>
>
> J Carrod
>
> Sent from Mail for
> Windows 10
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspealma at redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] 
TRIED. TESTED. TRUSTED. 

From cspealma at redhat.com  Tue Mar 31 09:16:09 2020
From: cspealma at redhat.com (Calvin Spealman)
Date: Tue, 31 Mar 2020 09:16:09 -0400
Subject: about to resolve problem in installation
In-Reply-To: 
References: 
Message-ID: 

You are trying to run the installer after you've already installed Python.

Instead, you want to open your start menu and search for Python or IDLE
(the Python editor) to actually run and use the Python version you've
already installed.

On Tue, Mar 31, 2020 at 8:22 AM Kapuganti Rakesh <
kapugantirakesh123 at gmail.com> wrote:

> Respected sir,
>                      I have downloaded the latest version of python 3.8.2
> in my windows 10. I have installed that.After completion of installation
> process it is displaying three options of modify,repair and uninstall. How
> to resolve that issue. please help me
>                                            Thanking You
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspealma at redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] 
TRIED. TESTED. TRUSTED. 

From stephan.lukits at gmail.com  Tue Mar 31 10:44:51 2020
From: stephan.lukits at gmail.com (Stephan Lukits)
Date: Tue, 31 Mar 2020 17:44:51 +0300
Subject: dynamic import of dynamically created modules failes
Message-ID: 

Hello,

background:

- a daemon creates package p1 (e.g. directory with __init__.py-file) and 
in p1 a module m1 is created.

- Then the daemon wants to import from m1, which functions (so far all 
the time).

- Then a module m2 is created in p1 and the daemon wants to import from 
m2 which fails (most of the time but *not* always) with ModuleNotFoundError.

See the little test script at the end which reproduces the problem.

The very strange thing for me is, that the import of m2 in the test 
script sometimes works.? I wonder if there is some 
package-content-caching.? And if so how to prevent or re-trigger it.

(neither a reload of p1 nor a deletion of p1 from sys.modules does the 
trick)


-----------------test-script-------------------

"""

(python --version: Python 3.8.2)

Dynamic import of dynamically created modules right after creation.
"""

from shutil import rmtree
from os import path, chdir, mkdir, listdir
from importlib import import_module, reload
import sys

# for test-package creation
P1 = 'p1'
INIT = '__init__.py'
INIT_CONTENT = """\
# -*- coding: utf-8 -*-
"""

# for first test-module creation
M1 = 'm1'
M1_CONTENT = """\
# -*- coding: utf-8 -*-

answer = 42
"""

# for second test-module creation
M2 = 'm2'
M2_CONTENT = """\
# -*- coding: utf-8 -*-

hello = 'world'
"""

chdir(path.dirname(__file__))??? # make sure we are in the right directory

if path.isdir(P1):
 ??? rmtree(P1)?????????????????? # always start off under the same 
conditions


mkdir(P1)??????????????????????? # create test-package and first test-module
with open(path.join(P1, INIT), 'w') as f:
 ??? f.write(INIT_CONTENT)
with open(path.join(P1, M1+'.py'), 'w') as f:
 ??? f.write(M1_CONTENT)

# import from the just created module; this worked always so far
from p1.m1 import answer

print(f'{answer=}')

with open(path.join(P1, M2+'.py'), 'w') as f:
 ??? f.write(M2_CONTENT)????????? # create the second test-module

# check current directory, file and module structure
print('wd-content:', ', '.join(listdir()))
print('p1-content:', ', '.join(listdir(P1)))
print('p1-modlues:', ', '.join([m for m in sys.modules if 
m.startswith('p1')]))
# reload(sys.modules['p1'])? # neither a reload
# del sys.modules['p1']????? # nor a deletion of p1 does the trick

# here it most of the time fails (but NOT all the time)
# so far if it fails it fails in all three variants
# so far if it works the 'from ...'-import works already
try:
 ??? from p1.m2 import hello
except ModuleNotFoundError:
 ??? try:
 ??????? hello = getattr(import_module('p1.m2'), 'hello')
 ??? except ModuleNotFoundError:
 ??????? try:
 ??????????? hello = getattr(__import__('p1.m2', fromlist=[None]), 'hello')
 ??????? except ModuleNotFoundError:
 ??????????? raise
 ??????? else:
 ??????????? print("__import__-import worked")
 ??? else:
 ??????? print("import_module-import worked")
else:
 ??? print("'from ... '-import worked")

print(f'{hello=}')


From dcwhatthe at gmail.com  Tue Mar 31 12:25:56 2020
From: dcwhatthe at gmail.com (dcwhatthe at gmail.com)
Date: Tue, 31 Mar 2020 09:25:56 -0700 (PDT)
Subject: how to specify trusted hosts in windows config file
In-Reply-To: 
References: <3824255550@f38.n261.z1.binkp.net>
 <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com>
 
 
 <74b889d7-c1dd-45ae-adec-b73ddb215118@googlegroups.com>
 
 
 
 
 
Message-ID: <81d807af-8c99-44f4-ba34-a52b7ea497d1@googlegroups.com>

I don't have control over this, Chris.  This is at my office.  I'm not the resource who manages network or other settings.  And we have various anti-spyware in place, that at leasts mitigates the risk.

What I'm doing isn't unprecedented.  People get false positives all the time on the web, and ask for this type of assistance.  Maybe my results were real evidence of something funky, but either way I have to get work done.

Thanks for trying to help, anyway.  I'll do a compare of the refreshed PIP files on the office PC, to a copy of pip elsewhere that I know is legit.

From tjreedy at udel.edu  Tue Mar 31 09:09:18 2020
From: tjreedy at udel.edu (Terry Reedy)
Date: Tue, 31 Mar 2020 09:09:18 -0400
Subject: about to resolve problem in installation
In-Reply-To: 
References: 
Message-ID: 

On 3/31/2020 2:23 AM, Kapuganti Rakesh wrote:
> Respected sir,
>                       I have downloaded the latest version of python 3.8.2
> in my windows 10. I have installed that.After completion of installation
> process it is displaying three options of modify,repair and uninstall. How
> to resolve that issue. please help me

You are re-running the installer.  Hit 'start' in lower left corner and 
find python under 'p'.

-- 
Terry Jan Reedy


From kapugantirakesh123 at gmail.com  Tue Mar 31 09:33:19 2020
From: kapugantirakesh123 at gmail.com (Kapuganti Rakesh)
Date: Tue, 31 Mar 2020 19:03:19 +0530
Subject: Fwd: about to resolve problem in installation
In-Reply-To: 
References: 
 
 
Message-ID: 

---------- Forwarded message ---------
From: Kapuganti Rakesh 
Date: Tue, 31 Mar 2020 at 19:02
Subject: Re: about to resolve problem in installation
To: Calvin Spealman 


I have already search in my pc but it is showing nothing and later i
searched python and started that app.After some it showing
I am getting confuse over this. pls help me

On Tue, 31 Mar 2020 at 18:46, Calvin Spealman  wrote:

> You are trying to run the installer after you've already installed Python.
>
> Instead, you want to open your start menu and search for Python or IDLE
> (the Python editor) to actually run and use the Python version you've
> already installed.
>
> On Tue, Mar 31, 2020 at 8:22 AM Kapuganti Rakesh <
> kapugantirakesh123 at gmail.com> wrote:
>
>> Respected sir,
>>                      I have downloaded the latest version of python 3.8.2
>> in my windows 10. I have installed that.After completion of installation
>> process it is displaying three options of modify,repair and uninstall. How
>> to resolve that issue. please help me
>>                                            Thanking You
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>>
>
> --
>
> CALVIN SPEALMAN
>
> SENIOR QUALITY ENGINEER
>
> cspealma at redhat.com  M: +1.336.210.5107
> [image: https://red.ht/sig] 
> TRIED. TESTED. TRUSTED. 
>

From dieter at handshake.de  Tue Mar 31 13:00:07 2020
From: dieter at handshake.de (Dieter Maurer)
Date: Tue, 31 Mar 2020 19:00:07 +0200
Subject: dynamic import of dynamically created modules failes
In-Reply-To: 
References: 
Message-ID: <24195.30487.693711.210548@ixdm.fritz.box>

Stephan Lukits wrote at 2020-3-31 17:44 +0300:
>background:
>
>- a daemon creates package p1 (e.g. directory with __init__.py-file) and
>in p1 a module m1 is created.
>
>- Then the daemon wants to import from m1, which functions (so far all
>the time).
>
>- Then a module m2 is created in p1 and the daemon wants to import from
>m2 which fails (most of the time but *not* always) with ModuleNotFoundError.
>
>See the little test script at the end which reproduces the problem.
> ...

I remember a similar report (some time ago). There, caching has
been responsible. I have forgotten how to invalidate the caches.
But, you could try logic found in
`importlib._bootstrap_external.PathFinder.invalidate_caches`.

From pieter-l at vanoostrum.org  Tue Mar 31 14:01:46 2020
From: pieter-l at vanoostrum.org (Pieter van Oostrum)
Date: Tue, 31 Mar 2020 20:01:46 +0200
Subject: dynamic import of dynamically created modules failes
References: 
 <24195.30487.693711.210548@ixdm.fritz.box>
 
Message-ID: 

"Dieter Maurer"  writes:

> Stephan Lukits wrote at 2020-3-31 17:44 +0300:
>>background:
>>
>>- a daemon creates package p1 (e.g. directory with __init__.py-file) and
>>in p1 a module m1 is created.
>>
>>- Then the daemon wants to import from m1, which functions (so far all
>>the time).
>>
>>- Then a module m2 is created in p1 and the daemon wants to import from
>>m2 which fails (most of the time but *not* always) with ModuleNotFoundError.
>>
>>See the little test script at the end which reproduces the problem.
>> ...
>
> I remember a similar report (some time ago). There, caching has
> been responsible. I have forgotten how to invalidate the caches.
> But, you could try logic found in
> `importlib._bootstrap_external.PathFinder.invalidate_caches`.

The first import creates a file __pycache__ in the directory p1.
To remove it use rmtree(path.join(P1,'__pycache__'))
Then the second import will succeed.
-- 
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

From rosuav at gmail.com  Tue Mar 31 14:13:59 2020
From: rosuav at gmail.com (Chris Angelico)
Date: Wed, 1 Apr 2020 05:13:59 +1100
Subject: how to specify trusted hosts in windows config file
In-Reply-To: <81d807af-8c99-44f4-ba34-a52b7ea497d1@googlegroups.com>
References: <3824255550@f38.n261.z1.binkp.net>
 <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com>
 
 
 <74b889d7-c1dd-45ae-adec-b73ddb215118@googlegroups.com>
 
 
 
 
 
 <81d807af-8c99-44f4-ba34-a52b7ea497d1@googlegroups.com>
Message-ID: 

On Wed, Apr 1, 2020 at 3:31 AM  wrote:
>
> I don't have control over this, Chris.  This is at my office.  I'm not the resource who manages network or other settings.  And we have various anti-spyware in place, that at leasts mitigates the risk.
>

Then talk to the person who does. Ask if s/he is okay with you
downloading untrusted code from the internet and running it with your
full permissions. Then ask if it would be better to be able to trust
that code's origin.

> What I'm doing isn't unprecedented.  People get false positives all the time on the web, and ask for this type of assistance.  Maybe my results were real evidence of something funky, but either way I have to get work done.
>

Yes, you have to get work done, so you ran random code from the
internet, downloaded on an unsecured connection, when the evidence
clearly showed that you were NOT getting it from the official source.

> Thanks for trying to help, anyway.  I'll do a compare of the refreshed PIP files on the office PC, to a copy of pip elsewhere that I know is legit.
>

Good luck. Chances are you won't know you've been hit with any spyware
or anything, so you'll feel confident.

ChrisA

From pieter-l at vanoostrum.org  Tue Mar 31 14:14:31 2020
From: pieter-l at vanoostrum.org (Pieter van Oostrum)
Date: Tue, 31 Mar 2020 20:14:31 +0200
Subject: dynamic import of dynamically created modules failes
References: 
 <24195.30487.693711.210548@ixdm.fritz.box>
 
 
Message-ID: 

Pieter van Oostrum  writes:

>
> The first import creates a file __pycache__ in the directory p1.
That should be 'a directory __pycache__'
> To remove it use rmtree(path.join(P1,'__pycache__'))
> Then the second import will succeed.
> -- 
> Pieter van Oostrum
> www: http://pieter.vanoostrum.org/
> PGP key: [8DAE142BE17999C4]

-- 
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

From stephan.lukits at gmail.com  Tue Mar 31 14:23:10 2020
From: stephan.lukits at gmail.com (Stephan Lukits)
Date: Tue, 31 Mar 2020 21:23:10 +0300
Subject: dynamic import of dynamically created modules failes
In-Reply-To: 
References: 
 <24195.30487.693711.210548@ixdm.fritz.box>
 
 
Message-ID: <69c0b516-3dcd-29b3-09b3-801dcab526ba@gmail.com>


On 3/31/20 9:01 PM, Pieter van Oostrum wrote:
> "Dieter Maurer"  writes:
>
>> Stephan Lukits wrote at 2020-3-31 17:44 +0300:
>>> background:
>>>
>>> - a daemon creates package p1 (e.g. directory with __init__.py-file) and
>>> in p1 a module m1 is created.
>>>
>>> - Then the daemon wants to import from m1, which functions (so far all
>>> the time).
>>>
>>> - Then a module m2 is created in p1 and the daemon wants to import from
>>> m2 which fails (most of the time but *not* always) with ModuleNotFoundError.
>>>
>>> See the little test script at the end which reproduces the problem.
>>> ...
>> I remember a similar report (some time ago). There, caching has
>> been responsible. I have forgotten how to invalidate the caches.
>> But, you could try logic found in
>> `importlib._bootstrap_external.PathFinder.invalidate_caches`.
> The first import creates a file __pycache__ in the directory p1.
> To remove it use rmtree(path.join(P1,'__pycache__'))
> Then the second import will succeed.


Thank you, but the behavior doesn't change.? I added


rmtree(path.join(P1, '__pycache__'))


Before the import:


try:
 ??? from p1.m2 import hello


and still get (please note that there isn't a __pycache__ directory 
anymore):

answer=42
wd-content: __init__.py, p1
p1-content: __init__.py, __pycache__, m1.py, m2.py
p1-modlues: p1, p1.m1
p1-content after rmtree: __init__.py, m1.py, m2.py
Traceback (most recent call last):
 ? File "dynamic_modules/__init__.py", line 68, in 
 ??? from p1.m2 import hello
ModuleNotFoundError: No module named 'p1.m2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 ? File "dynamic_modules/__init__.py", line 71, in 
 ??? hello = getattr(import_module('p1.m2'), 'hello')
 ? File 
"/home/goedel/.pyenv/versions/3.8.2/lib/python3.8/importlib/__init__.py", 
line 127, in import_module
 ??? return _bootstrap._gcd_import(name[level:], package, level)
 ? File "", line 1014, in _gcd_import
 ? File "", line 991, in _find_and_load
 ? File "", line 973, in 
_find_and_load_unlocked
ModuleNotFoundError: No module named 'p1.m2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 ? File "dynamic_modules/__init__.py", line 74, in 
 ??? hello = getattr(__import__('p1.m2', fromlist=[None]), 'hello')
ModuleNotFoundError: No module named 'p1.m2'


From stephan.lukits at gmail.com  Tue Mar 31 14:39:14 2020
From: stephan.lukits at gmail.com (Stephan Lukits)
Date: Tue, 31 Mar 2020 21:39:14 +0300
Subject: [Solved] Re: dynamic import of dynamically created modules failes
In-Reply-To: <24195.30487.693711.210548@ixdm.fritz.box>
References: 
 <24195.30487.693711.210548@ixdm.fritz.box>
Message-ID: <88cdf10d-9cb7-0cb6-01f3-9e7fc186b3cb@gmail.com>


On 3/31/20 8:00 PM, Dieter Maurer wrote:
> Stephan Lukits wrote at 2020-3-31 17:44 +0300:
>> background:
>>
>> - a daemon creates package p1 (e.g. directory with __init__.py-file) and
>> in p1 a module m1 is created.
>>
>> - Then the daemon wants to import from m1, which functions (so far all
>> the time).
>>
>> - Then a module m2 is created in p1 and the daemon wants to import from
>> m2 which fails (most of the time but *not* always) with ModuleNotFoundError.
>>
>> See the little test script at the end which reproduces the problem.
>> ...
> I remember a similar report (some time ago). There, caching has
> been responsible. I have forgotten how to invalidate the caches.
> But, you could try logic found in
> `importlib._bootstrap_external.PathFinder.invalidate_caches`.

Yes, removing the entry for p1 from 'sys.path_importer_cache' seems to 
solve the problem.

Thank you.




From __peter__ at web.de  Tue Mar 31 14:42:58 2020
From: __peter__ at web.de (Peter Otten)
Date: Tue, 31 Mar 2020 20:42:58 +0200
Subject: dynamic import of dynamically created modules failes
References: 
 <24195.30487.693711.210548@ixdm.fritz.box>
Message-ID: 

Dieter Maurer wrote:

> Stephan Lukits wrote at 2020-3-31 17:44 +0300:
>>background:
>>
>>- a daemon creates package p1 (e.g. directory with __init__.py-file) and
>>in p1 a module m1 is created.
>>
>>- Then the daemon wants to import from m1, which functions (so far all
>>the time).
>>
>>- Then a module m2 is created in p1 and the daemon wants to import from
>>m2 which fails (most of the time but *not* always) with
>>ModuleNotFoundError.
>>
>>See the little test script at the end which reproduces the problem.
>> ...
> 
> I remember a similar report (some time ago). There, caching has
> been responsible. I have forgotten how to invalidate the caches.
> But, you could try logic found in
> `importlib._bootstrap_external.PathFinder.invalidate_caches`.

[brainstorm mode]

Do namespace packages cache as aggressively? Maybe it would help to omit 
p1/__init__.py.


From PythonList at DancesWithMice.info  Tue Mar 31 18:08:47 2020
From: PythonList at DancesWithMice.info (DL Neil)
Date: Wed, 1 Apr 2020 11:08:47 +1300
Subject: error in importing
In-Reply-To: 
References: 
Message-ID: <3054774d-06e0-46e9-304e-8422822b3746@DancesWithMice.info>

On 31/03/20 11:23 PM, Jami Yaswanth wrote:
> i am not able to use the libraries that are installed
> using "pip install pandas"

Welcome to Python!

Are you aware of the Python-Tutor Discussion List?
(https://mail.python.org/mailman/listinfo/tutor)

Please describe how you installed these libraries.

Please describe how you start Python.

Please copy-paste all relevant code, plus the error messages received.
-- 
Regards =dn

From robertvstepp at gmail.com  Tue Mar 31 21:58:38 2020
From: robertvstepp at gmail.com (boB Stepp)
Date: Tue, 31 Mar 2020 20:58:38 -0500
Subject: about to resolve problem in installation
In-Reply-To: 
References: 
 
 
 
Message-ID: 

On Tue, Mar 31, 2020 at 12:02 PM Kapuganti Rakesh
 wrote:

> I have already search in my pc but it is showing nothing and later i
> searched python and started that app.After some it showing
> I am getting confuse over this. pls help me

If you press your Windows key (or click on the Windows symbol on the
task bar) you will have an alphabetically arranged list of programs.
Scroll down till you reach Python 3.8.  Expand that entry by clicking
on it.  If you did a normal installation you should see "IDLE...",
"Python 3.8..." and "Python 3.8 Module Docs..."  For your purposes you
probably would want to start with IDLE.  It will take you to Python's
interactive interpreter.  You will see a prompt that looks like ">>>"
You may type in Python statements after the prompt such as ">>> 3*2"
You can do more in IDLE (Much more), but you will need to have a
beginner's Python book or tutorial to guide you in what to do next.

By the way, there is a Python Tutor list that exists to help newcomers
to Python and/or programming.  Its subscription page may be found at:

https://mail.python.org/mailman/listinfo/tutor

Hope this helps you through your first steps!

Cheers!
boB