From miked at dewhirst.com.au Thu Jun 1 02:53:01 2023 From: miked at dewhirst.com.au (Mike Dewhirst) Date: Thu, 1 Jun 2023 16:53:01 +1000 Subject: Is there a Python module to parse a date like the 'date' command in Linux? In-Reply-To: <35891e6a-ef32-9497-bdc7-221d0ead167b@dewhirst.com.au> References: <35891e6a-ef32-9497-bdc7-221d0ead167b@dewhirst.com.au> Message-ID: <0b16a809-d947-4f41-07c4-50c93451228c@dewhirst.com.au> On 24/05/2023 6:00 pm, Mike Dewhirst wrote: > On 23/05/2023 7:16 pm, Chris Green wrote: >> Mike Dewhirst wrote: >>> [-- multipart/mixed, encoding 7bit, 22 lines --] >>> >>> [-- text/plain, encoding base64, charset: UTF-8, 16 lines --] >>> >>> On 21/05/2023 5:53 am, Chris Green wrote: >>>> I'm converting a bash script to python as it has become rather clumsy >>>> in bash. >>> What is the use case? >>> >> A script I use to create diary entries, so it's very handy to be able >> to give the date as 'yesterday' or 'friday'. > > OK - I thought maybe baklabel might suit, but that delivers a day-name > (backup filename prefix) for today or a given date I have just refreshed baklabel on PyPI and upped it from my local svn server to github [1] The changes include resolving ambiguous dates across locales eg USA vs Australia 5/6/2023 being detected as May in USA and June in Australia on the assumption that the user knows what is required. [1] https://github.com/mdewhirst/baklabel > > > > -- > Signed email is an absolute defence against phishing. This email has > been signed with my private key. If you import my public key you can > automatically decrypt my signature and be sure it came from me. Your > email software can handle signing. -- Signed email is an absolute defence against phishing. This email has been signed with my private key. If you import my public key you can automatically decrypt my signature and be sure it came from me. Your email software can handle signing. -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 495 bytes Desc: OpenPGP digital signature URL: From info at egenix.com Mon Jun 5 11:49:07 2023 From: info at egenix.com (eGenix Team) Date: Mon, 5 Jun 2023 17:49:07 +0200 Subject: =?UTF-8?Q?ANN=3a_Python_Meeting_D=c3=bcsseldorf_-_07=2e06=2e2023?= Message-ID: <8215c5c7-e6cf-46ea-e6d9-1ee6c791d323@egenix.com> /This announcement is in German since it targets a local user group//meeting in D?sseldorf, Germany/ Ank?ndigung Python Meeting D?sseldorf - Juni 2023 Ein Treffen von Python Enthusiasten und Interessierten in ungezwungener Atmosph?re. *07.06.2023, 18:00 Uhr* Raum 1, 2.OG im B?rgerhaus Stadtteilzentrum Bilk D?sseldorfer Arcaden , Bachstr. 145, 40217 D?sseldorf Programm Bereits angemeldete Vortr?ge: * Marc-Andre Lemburg: /Building *your own Web Archive* with Python/ * Nico Kreiling: /Raised by Pandas, striving for more. In opinionated introduction to *Polars*/ * Charlie Clark: LT... /Combining *Descriptors and Slots*/ * Marc-Andre Lemburg: LT... /What's new in *Python 3.12*/ Weitere Vortr?ge k?nnen gerne noch angemeldet werden. Bei Interesse, bitte unter info at pyddf.de melden. Startzeit und Ort Wir treffen uns um 18:00 Uhr im B?rgerhaus in den D?sseldorfer Arcaden. Das B?rgerhaus teilt sich den Eingang mit dem Schwimmbad und befindet sich an der Seite der Tiefgarageneinfahrt der D?sseldorfer Arcaden. ?ber dem Eingang steht ein gro?es "Schwimm? in Bilk" Logo. Hinter der T?r direkt links zu den zwei Aufz?gen, dann in den 2. Stock hochfahren. Der Eingang zum Raum 1 liegt direkt links, wenn man aus dem Aufzug kommt. >>> Eingang in Google Street View Corona Die Corona Einschr?nkungen sind mittlerweile aufgehoben worden. Vorsicht ist zwar immer noch geboten, aber jetzt jedem selbst ?berlassen. *?? Wichtig*: Bitte nur dann anmelden, wenn ihr absolut sicher seid, dass ihr auch kommt. Angesichts der begrenzten Anzahl Pl?tze, haben wir kein Verst?ndnis f?r kurzfristige Absagen oder No-Shows. Einleitung Das Python Meeting D?sseldorf ist eine regelm??ige Veranstaltung in D?sseldorf, die sich an Python Begeisterte aus der Region wendet. Einen guten ?berblick ?ber die Vortr?ge bietet unser PyDDF YouTube-Kanal , auf dem wir Videos der Vortr?ge nach den Meetings ver?ffentlichen. Veranstaltet wird das Meeting von der eGenix.com GmbH , Langenfeld, in Zusammenarbeit mit Clark Consulting & Research , D?sseldorf: Format Das Python Meeting D?sseldorf nutzt eine Mischung aus (Lightning) Talks und offener Diskussion. Vortr?ge k?nnen vorher angemeldet werden, oder auch spontan w?hrend des Treffens eingebracht werden. Ein Beamer mit HDMI und FullHD Aufl?sung steht zur Verf?gung. (Lightning) Talk Anmeldung bitte formlos per EMail an info at pyddf.de Kostenbeteiligung Das Python Meeting D?sseldorf wird von Python Nutzern f?r Python Nutzer veranstaltet. Da Tagungsraum, Beamer, Internet und Getr?nke Kosten produzieren, bitten wir die Teilnehmer um einen Beitrag in H?he von EUR 10,00 inkl. 19% Mwst. Sch?ler und Studenten zahlen EUR 5,00 inkl. 19% Mwst. Wir m?chten alle Teilnehmer bitten, den Betrag in bar mitzubringen. Anmeldung Da wir nur 25 Personen in dem angemieteten Raum empfangen k?nnen, m?chten wir bitten, sich vorher anzumelden. *Meeting Anmeldung* bitte per Meetup Weitere Informationen Weitere Informationen finden Sie auf der Webseite des Meetings: https://pyddf.de/ Viel Spa? ! -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Experts (#1, Jun 05 2023) >>> 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 ndbecker2 at gmail.com Tue Jun 6 10:04:08 2023 From: ndbecker2 at gmail.com (Neal Becker) Date: Tue, 6 Jun 2023 10:04:08 -0400 Subject: f-string syntax deficiency? Message-ID: The following f-string does not parse and gives syntax error on 3.11.3: f'thruput/{"user" if opt.return else "cell"} vs. elevation\n' However this expression, which is similar does parse correctly: f'thruput/{"user" if True else "cell"} vs. elevation\n' I don't see any workaround. Parenthesizing doesn't help: f'thruput/{"user" if (opt.return) else "cell"} vs. elevation\n' also gives a syntax error From rosuav at gmail.com Tue Jun 6 10:08:04 2023 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 7 Jun 2023 00:08:04 +1000 Subject: f-string syntax deficiency? In-Reply-To: References: Message-ID: On Wed, 7 Jun 2023 at 00:06, Neal Becker wrote: > > The following f-string does not parse and gives syntax error on 3.11.3: > > f'thruput/{"user" if opt.return else "cell"} vs. elevation\n' > > However this expression, which is similar does parse correctly: > > f'thruput/{"user" if True else "cell"} vs. elevation\n' > > I don't see any workaround. Parenthesizing doesn't help: > f'thruput/{"user" if (opt.return) else "cell"} vs. elevation\n' > > also gives a syntax error Is this a problem with the f-string, or with the expression opt.return? That's a keyword. ChrisA From roel at roelschroeven.net Tue Jun 6 10:41:16 2023 From: roel at roelschroeven.net (Roel Schroeven) Date: Tue, 6 Jun 2023 16:41:16 +0200 Subject: f-string syntax deficiency? In-Reply-To: References: Message-ID: Op 6/06/2023 om 16:08 schreef Chris Angelico: > On Wed, 7 Jun 2023 at 00:06, Neal Becker wrote: > > > > The following f-string does not parse and gives syntax error on 3.11.3: > > > > f'thruput/{"user" if opt.return else "cell"} vs. elevation\n' > > > > However this expression, which is similar does parse correctly: > > > > f'thruput/{"user" if True else "cell"} vs. elevation\n' > > > > I don't see any workaround. Parenthesizing doesn't help: > > f'thruput/{"user" if (opt.return) else "cell"} vs. elevation\n' > > > > also gives a syntax error > > Is this a problem with the f-string, or with the expression > opt.return? That's a keyword. 'return' being a keyowrd is definitely going to be the problem. Neal, I assume you're using 'opt.return' also outside of that f-string. Does that work? How did you manage to do that? I tried to make a simple class with an attribute called 'return', but that already fails with a syntax error. (Recently there has been an effort to provide clearer and more useful error messages; this seems to be a case where there is still room for improvement: "SyntaxError: invalid syntax" doesn't immediately remind me of that fact that 'return' is a keyword and therefor can't be used as an attribute.) -- "Don't Panic." -- Douglas Adams, The Hitchhiker's Guide to the Galaxy From roel at roelschroeven.net Tue Jun 6 10:47:12 2023 From: roel at roelschroeven.net (Roel Schroeven) Date: Tue, 6 Jun 2023 16:47:12 +0200 Subject: f-string syntax deficiency? In-Reply-To: References: Message-ID: <87c25051-a524-9160-d85a-e4c4d01bd42e@roelschroeven.net> Op 6/06/2023 om 16:41 schreef Roel Schroeven: > 'return' being a keyowrd is definitely going to be the problem. *keyword -- "Don't Panic." -- Douglas Adams, The Hitchhiker's Guide to the Galaxy From rosuav at gmail.com Tue Jun 6 10:48:21 2023 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 7 Jun 2023 00:48:21 +1000 Subject: f-string syntax deficiency? In-Reply-To: References: Message-ID: On Wed, 7 Jun 2023 at 00:42, Roel Schroeven wrote: > (Recently there has been an effort to provide clearer and more useful > error messages; this seems to be a case where there is still room for > improvement: "SyntaxError: invalid syntax" doesn't immediately remind me > of that fact that 'return' is a keyword and therefor can't be used as an > attribute.) That's true, but depending on exactly how you're seeing the error, it might highlight the exact part that's a problem: >>> opt.return File "", line 1 opt.return ^^^^^^ SyntaxError: invalid syntax It's extremely hard to guess what the programmer might have intended in these situations, as the error might not be the word "return" but perhaps the punctuation (maybe that was supposed to be a semicolon, or something). So Python does the best it can, and points out that the "return" keyword in this context doesn't make syntactic sense. ChrisA From roel at roelschroeven.net Tue Jun 6 10:56:35 2023 From: roel at roelschroeven.net (Roel Schroeven) Date: Tue, 6 Jun 2023 16:56:35 +0200 Subject: f-string syntax deficiency? In-Reply-To: References: Message-ID: <29dc7d8c-34c3-f199-0bae-dad3af01c4bb@roelschroeven.net> Op 6/06/2023 om 16:48 schreef Chris Angelico via Python-list: > On Wed, 7 Jun 2023 at 00:42, Roel Schroeven wrote: > > (Recently there has been an effort to provide clearer and more useful > > error messages; this seems to be a case where there is still room for > > improvement: "SyntaxError: invalid syntax" doesn't immediately remind me > > of that fact that 'return' is a keyword and therefor can't be used as an > > attribute.) > > That's true, but depending on exactly how you're seeing the error, it > might highlight the exact part that's a problem: > > >>> opt.return > File "", line 1 > opt.return > ^^^^^^ > SyntaxError: invalid syntax > > It's extremely hard to guess what the programmer might have intended > in these situations, as the error might not be the word "return" but > perhaps the punctuation (maybe that was supposed to be a semicolon, or > something). So Python does the best it can, and points out that the > "return" keyword in this context doesn't make syntactic sense. Ah yes, good point. -- "Don't Panic." -- Douglas Adams, The Hitchhiker's Guide to the Galaxy From nntp.mbourne at spamgourmet.com Tue Jun 6 15:46:38 2023 From: nntp.mbourne at spamgourmet.com (Mark Bourne) Date: Tue, 6 Jun 2023 20:46:38 +0100 Subject: f-string syntax deficiency? In-Reply-To: References: Message-ID: Roel Schroeven wrote: > Op 6/06/2023 om 16:08 schreef Chris Angelico: >> On Wed, 7 Jun 2023 at 00:06, Neal Becker wrote: >> > >> > The following f-string does not parse and gives syntax error on 3.11.3: >> > >> > f'thruput/{"user" if opt.return else "cell"} vs. elevation\n' >> > >> > However this expression, which is similar does parse correctly: >> > >> > f'thruput/{"user" if True else "cell"} vs. elevation\n' >> > >> > I don't see any workaround.? Parenthesizing doesn't help: >> >? f'thruput/{"user" if (opt.return) else "cell"} vs. elevation\n' >> > >> > also gives a syntax error >> >> Is this a problem with the f-string, or with the expression >> opt.return? That's a keyword. > 'return' being a keyowrd is definitely going to be the problem. > > Neal, I assume you're using 'opt.return' also outside of that f-string. > Does that work? How did you manage to do that? I tried to make a simple > class with an attribute called 'return', but that already fails with a > syntax error. Just for fun, here's a class which has any attribute you like, including `return`: ``` class AnyAttr: def __getattr__(self, name): return f'This is the value of the <{name}> attribute' ``` The usual "dot" notation to access the attributes works for arbitrary attributes, but not for `return` because, as mentioned, that's a keyword: ``` >>> aa = AnyAttr() >>> aa.myattribute 'This is the value of the attribute' >>> aa.random 'This is the value of the attribute' >>> aa.return File "", line 1 aa.return ^ SyntaxError: invalid syntax ``` If you really do have an instance with a `return` attribute (perhaps because it does fun things with `__getattr__`), you can access it if necessary using `getattr`: ``` >>> getattr(aa, 'return') 'This is the value of the attribute' ``` You can even access attributes with spaces and other usually-invalid characters: ``` >>> getattr(aa, 'This really is an attribute name!') 'This is the value of the attribute' ``` Using `getattr` to access the value, Neal's f-string can be made to work: ``` >>> f'thruput/{"user" if getattr(aa, "return") else "cell"} vs. elevation\n' 'thruput/user vs. elevation\n' ``` But if you have control over the implementation of that `opt` object, it's probably better to give the attribute a different name which is a valid identifier. PEP-8 suggests a convention of using a single trailing underscore (e.g. `return_`) to avoid conflicts with keywords, if there's no better name. Perhaps `opt` is the arguments returned by `argparse.ArgumentParser` and you want the command-line option to be `--return`. In that case, see the `dest` argument to `add_argument()` which can specify a different name for the attribute used in code (it's almost like they thought about this type of problem ;o)). If it's from `optparse`, that has a similar argument, but `optparse` is deprecated so consider updating to `argparse`. > > (Recently there has been an effort to provide clearer and more useful > error messages; this seems to be a case where there is still room for > improvement: "SyntaxError: invalid syntax" doesn't immediately remind me > of that fact that 'return' is a keyword and therefor can't be used as an > attribute.) -- Mark. From lukasz at langa.pl Wed Jun 7 02:58:19 2023 From: lukasz at langa.pl (=?utf-8?Q?=C5=81ukasz_Langa?=) Date: Wed, 7 Jun 2023 08:58:19 +0200 Subject: [RELEASE] Python 3.11.4, 3.10.12, 3.9.17, 3.8.17, 3.7.17, and 3.12.0 beta 2 are now available Message-ID: Greetings! Time for another combined release of six separate versions of Python! Before you scroll away to the download links Please test the 3.12 beta! Downloading it and trying it out helps us a lot in ensuring Python 3.12.0 will be as polished as possible. We welcome 3.10 to the prestigious club of security-only releases. It?s officially an old version of Python now! If you haven?t rewritten all your if:elif:else:s with pattern matching yet, are you even still writing Python? At the same time, it looks like 3.7 is reaching end-of-life. Unless another security release happens in June, 3.7.17 will be the final release of Python 3.7. I mean, now that I typed it out for all you to read, I?m sure I jinxed it. But in case I didn?t, I would like to thank Ned Deily for serving as the release manager of Python 3.6 and Python 3.7. He was my mentor as Release Manager, and continues serving Python as the provider of Mac installers for new releases. Thank you, Ned! Speaking of installers, Steve Dower used to be the sole provider of Windows installers for Python releases for years now. His secret was a well-automated Azure pipeline that let him build, sign, and publish releases with minimal manual effort. Now he extended the power to press the blue ?Run pipeline? button to more members of the team. Thank you, Steve! This is an important bus factor increment. In fact, the Windows installers for both 3.12.0b2 and 3.11.4 were made by meinitiated by me . If there?s anything wrong with them, well, I guess that means I pressed the button wrong. Security fixes in today?s releases Updating is recommended due to security content: 3.7 - 3.12: gh-103142 : The version of OpenSSL used in Windows and Mac installers has been upgraded to 1.1.1u to address CVE-2023-2650, CVE-2023-0465, CVE-2023-0466, CVE-2023-0464, as well as CVE-2023-0286, CVE-2022-4303, and CVE-2022-4303 fixed previously in 1.1.1t (gh-101727). 3.7 - 3.11: gh-102153 : urllib.parse.urlsplit() now strips leading C0 control and space characters following the specification for URLs defined by WHATWG in response to CVE-2023-24329. 3.7 - 3.11: gh-99889 : Fixed a security in flaw in uu.decode() that could allow for directory traversal based on the input if no out_file was specified. 3.7 - 3.11: gh-104049 : Do not expose the local on-disk location in directory indexes produced by http.client.SimpleHTTPRequestHandler. 3.7 - 3.11: gh-101283 : subprocess.Popen now uses a safer approach to find cmd.exe when launching with shell=True. 3.8 - 3.11: gh-103935 : trace.__main__ now uses io.open_code() for files to be executed instead of raw open(). 3.8 - 3.11: gh-102953 : The extraction methods in tarfile, and shutil.unpack_archive(), have a new filterargument that allows limiting tar features than may be surprising or dangerous, such as creating files outside the destination directory. See Extraction filters for details. 3.9: gh-102126 : Fixed a deadlock at shutdown when clearing thread states if any finalizer tries to acquire the runtime head lock. 3.9: gh-100892 : Fixed a crash due to a race while iterating over thread states in clearing threading.local. Python 3.12.0 beta 2 Get it here: 3.12.0b2 116 new commits since 3.12.0 beta 1. Python 3.11.4 Get it here: 3.11.4 233 new commits. Python 3.10.12 Get it here: 3.10.12 Security-only release with no binaries. 20 new commits. Python 3.9.17 Get it here: 3.9.17 Security-only release with no binaries. 26 commits. Python 3.8.17 Get it here: 3.8.17 Security-only release with no binaries. 24 commits. Python 3.7.17 Get it here as it might be the last release of 3.7 ever : 3.7.17 Security-only release with no binaries. 21 commits. We hope you enjoy the new releases! Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation . ? ?ukasz Langa @ambv on behalf of your friendly release team, Ned Deily @nad Steve Dower @steve.dower Pablo Galindo Salgado @pablogsal ?ukasz Langa @ambv Thomas Wouters @thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: Message signed with OpenPGP URL: From florianguilbault.jdb at gmail.com Wed Jun 7 10:54:23 2023 From: florianguilbault.jdb at gmail.com (Florian Guilbault) Date: Wed, 7 Jun 2023 16:54:23 +0200 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation Message-ID: Dear Python Technical Team, I hope this email finds you well. I am reaching out to you today to seek assistance with an issue I am facing regarding the installation of 'pip' despite my numerous attempts to resolve the problem. Recently, I performed installation, uninstallation, and even repair operations on Python 3.10 on my computer. However, I have noticed that 'pip' has never been installed successfully. When I check via the command prompt, I receive the following error: "'pip' is not recognized as an internal or external command, operable program, or batch file." I have tried several approaches to resolve this issue. I have verified that the PATH environment variable is correctly configured to include the path to the Python Scripts directory. I have also attempted to run the 'get-pip.py' installation script from the command line, but it did not work either. I am aware that 'pip' is typically installed automatically with Python, but I am encountering this persistent difficulty. Therefore, I would like to request your assistance and expertise in resolving this 'pip' installation issue. I would like to be able to use 'pip' to manage my Python packages efficiently. I am open to any suggestions and steps you can provide to help me resolve this problem. Please note that I am a user on the Windows operating system. Thank you sincerely for your attention and support. I eagerly await your guidance to resolve this situation. Best regards, From toby+esnews at tobiah.org Wed Jun 7 10:57:26 2023 From: toby+esnews at tobiah.org (Tobiah) Date: Wed, 7 Jun 2023 07:57:26 -0700 Subject: Using pydal for standalone scripts Message-ID: I am looking into creating a database abstraction library using pydal and mysql as the engine. I noticed that I have to specify a 'folder' with the connection string to tell pydal where to save "table files". So I'll have hundreds of different databases and install this library on many machines. Do I need to standardize a place for these files and make sure that directory exists on every machine that uses the library? It seems rather cumbersome. I mean, couldn't pydal have just put this information into the database in its own private table? Thanks! From barry at barrys-emacs.org Wed Jun 7 11:43:38 2023 From: barry at barrys-emacs.org (Barry) Date: Wed, 7 Jun 2023 16:43:38 +0100 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: References: Message-ID: <124D545B-D611-4333-861D-6AAAF230E276@barrys-emacs.org> > On 7 Jun 2023, at 16:39, Florian Guilbault via Python-list wrote: > > ?Dear Python Technical Team, > > I hope this email finds you well. I am reaching out to you today to seek > assistance with an issue I am facing regarding the installation of 'pip' > despite my numerous attempts to resolve the problem. > > Recently, I performed installation, uninstallation, and even repair > operations on Python 3.10 on my computer. However, I have noticed that > 'pip' has never been installed successfully. When I check via the command > prompt, I receive the following error: "'pip' is not recognized as an > internal or external command, operable program, or batch file." > > I have tried several approaches to resolve this issue. I have verified that > the PATH environment variable is correctly configured to include the path > to the Python Scripts directory. I have also attempted to run the > 'get-pip.py' installation script from the command line, but it did not work > either. > > I am aware that 'pip' is typically installed automatically with Python, but > I am encountering this persistent difficulty. Therefore, I would like to > request your assistance and expertise in resolving this 'pip' installation > issue. I would like to be able to use 'pip' to manage my Python packages > efficiently. > > I am open to any suggestions and steps you can provide to help me resolve > this problem. Please note that I am a user on the Windows operating system. > > Thank you sincerely for your attention and support. I eagerly await your > guidance to resolve this situation. You can run pip like this, that works with needing to mess with your PATH. py -m pip Barty > > Best regards, > -- > https://mail.python.org/mailman/listinfo/python-list > From python at mrabarnett.plus.com Wed Jun 7 12:08:44 2023 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 7 Jun 2023 17:08:44 +0100 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: References: Message-ID: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> On 2023-06-07 15:54, Florian Guilbault via Python-list wrote: > Dear Python Technical Team, > > I hope this email finds you well. I am reaching out to you today to seek > assistance with an issue I am facing regarding the installation of 'pip' > despite my numerous attempts to resolve the problem. > > Recently, I performed installation, uninstallation, and even repair > operations on Python 3.10 on my computer. However, I have noticed that > 'pip' has never been installed successfully. When I check via the command > prompt, I receive the following error: "'pip' is not recognized as an > internal or external command, operable program, or batch file." > > I have tried several approaches to resolve this issue. I have verified that > the PATH environment variable is correctly configured to include the path > to the Python Scripts directory. I have also attempted to run the > 'get-pip.py' installation script from the command line, but it did not work > either. > > I am aware that 'pip' is typically installed automatically with Python, but > I am encountering this persistent difficulty. Therefore, I would like to > request your assistance and expertise in resolving this 'pip' installation > issue. I would like to be able to use 'pip' to manage my Python packages > efficiently. > > I am open to any suggestions and steps you can provide to help me resolve > this problem. Please note that I am a user on the Windows operating system. > > Thank you sincerely for your attention and support. I eagerly await your > guidance to resolve this situation. > On Windows, it's recommended to use the Python Launcher and the pip module: py -m pip install whatever From mats at wichmann.us Wed Jun 7 12:36:22 2023 From: mats at wichmann.us (Mats Wichmann) Date: Wed, 7 Jun 2023 10:36:22 -0600 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> Message-ID: <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> On 6/7/23 10:08, MRAB via Python-list wrote: > On 2023-06-07 15:54, Florian Guilbault via Python-list wrote: >> Dear Python Technical Team, >> >> I hope this email finds you well. I am reaching out to you today to seek >> assistance with an issue I am facing regarding the installation of 'pip' >> despite my numerous attempts to resolve the problem. >> >> Recently, I performed installation, uninstallation, and even repair >> operations on Python 3.10 on my computer. However, I have noticed that >> 'pip' has never been installed successfully. When I check via the command >> prompt, I receive the following error: "'pip' is not recognized as an >> internal or external command, operable program, or batch file." >> >> I have tried several approaches to resolve this issue. I have verified >> that >> the PATH environment variable is correctly configured to include the path >> to the Python Scripts directory. I'm assuming you checked - say, with Explorer - that pip.exe really is where you think it is? Anyway, if you ask a Windows shell (cmd) to locate it, and it doesn't, then your PATH is not set up correctly after all. where pip should give you back a path that ends witn ...\Scripts\pip.exe That said, the suggestions already given are on point. Running pip as a module (rather than as a standalone command) assures that it's associated with the Python you want it associated with. In today's world, a lot of developer systems end up with multiple Python installations (*), and you don't want to use a pip that is bound to the wrong one, or the next email will be "I installed foo module but my Python fails to import it". (*) You can have different Python versions for compat checking, you can have project-specific virtualenvs, you can have Pythons that come bundled with a subsystem like Conda, etc. > On Windows, it's recommended to use the Python Launcher and the pip module: > > py -m pip install whatever > From list1 at tompassin.net Wed Jun 7 15:12:22 2023 From: list1 at tompassin.net (Thomas Passin) Date: Wed, 7 Jun 2023 15:12:22 -0400 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: References: Message-ID: <3a06f644-9e74-efa9-5e5c-7886a0aa5071@tompassin.net> On 6/7/2023 10:54 AM, Florian Guilbault via Python-list wrote: > Dear Python Technical Team, > > I hope this email finds you well. I am reaching out to you today to seek > assistance with an issue I am facing regarding the installation of 'pip' > despite my numerous attempts to resolve the problem. > > Recently, I performed installation, uninstallation, and even repair > operations on Python 3.10 on my computer. However, I have noticed that > 'pip' has never been installed successfully. When I check via the command > prompt, I receive the following error: "'pip' is not recognized as an > internal or external command, operable program, or batch file." > > I have tried several approaches to resolve this issue. I have verified that > the PATH environment variable is correctly configured to include the path > to the Python Scripts directory. I have also attempted to run the > 'get-pip.py' installation script from the command line, but it did not work > either. > > I am aware that 'pip' is typically installed automatically with Python, but > I am encountering this persistent difficulty. Therefore, I would like to > request your assistance and expertise in resolving this 'pip' installation > issue. I would like to be able to use 'pip' to manage my Python packages > efficiently. > > I am open to any suggestions and steps you can provide to help me resolve > this problem. Please note that I am a user on the Windows operating system. > > Thank you sincerely for your attention and support. I eagerly await your > guidance to resolve this situation. You have by now seen several responses, and the one most likely to be helpful is to run pip with py -m pip I would like to suggest some ways you can make it more likely that you will get useful suggestions in the future. Basically, please fill in details about your situation. 1. Say what operating system your computer is running. All the responses so far have assumed that it is some version of Windows. This may or may not be correct. We can infer it in this case from the message you reported ("'pip' is not recognized as an internal or external command, operable program, or batch file."), but you should say so that we don't need to guess. 2. Since this question is about your python installation, say how you installed it, since there are several possibilities. For example, you may have used the installer from python.org, you may have installed it from the Microsoft store, etc. These different installations are not always the same. 3. When you wrote that you "verified that the PATH environment variable is correctly configured to include the path to the Python Scripts directory", tell us what that PATH actually is, not just that it is "correct". We don't know if your idea of "correct" matches ours. 4. Say how you tried to run programs that appeared to fail - running "python" in a console may launch a different version from the one you expect. On Windows, running "py" will run the most recent one. BTW, my own python.org installation of Python 3.11 on Windows 10 does not include a get-pip.exe or a get-pip.py in its Python311\Scripts directory (not that it was needed). From jsf80238 at gmail.com Wed Jun 7 18:18:14 2023 From: jsf80238 at gmail.com (Jason Friedman) Date: Wed, 7 Jun 2023 16:18:14 -0600 Subject: Match statement with literal strings Message-ID: This gives the expected results: with open(data_file, newline="") as reader: csvreader = csv.DictReader(reader) for row in csvreader: #print(row) match row[RULE_TYPE]: case "RANGE": print("range") case "MANDATORY": print("mandatory") case _: print("nothing to do") This: RANGE = "RANGE" MANDATORY = "MANDATORY" with open(data_file, newline="") as reader: csvreader = csv.DictReader(reader) for row in csvreader: #print(row) match row[RULE_TYPE]: case RANGE: print("range") case MANDATORY: print("mandatory") case _: print("nothing to do") Gives (and I don't understand why): SyntaxError: name capture 'RANGE' makes remaining patterns unreachable From eryksun at gmail.com Wed Jun 7 18:28:13 2023 From: eryksun at gmail.com (Eryk Sun) Date: Wed, 7 Jun 2023 17:28:13 -0500 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: <3a06f644-9e74-efa9-5e5c-7886a0aa5071@tompassin.net> References: <3a06f644-9e74-efa9-5e5c-7886a0aa5071@tompassin.net> Message-ID: On 6/7/23, Thomas Passin via Python-list wrote: > > You have by now seen several responses, and the one most likely to be > helpful is to run pip with > > py -m pip That won't be of any help if pip isn't installed. By default, Python's installer attempts to install pip by running the ensurepip package, but sometimes it fails. It can help to try to manually run ensurepip in the shell. For example: py -m ensurepip --default-pip --upgrade --verbose From greg.ewing at canterbury.ac.nz Wed Jun 7 19:58:51 2023 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Thu, 8 Jun 2023 11:58:51 +1200 Subject: Match statement with literal strings In-Reply-To: References: Message-ID: On 8/06/23 10:18 am, Jason Friedman wrote: > SyntaxError: name capture 'RANGE' makes remaining patterns unreachable The bytecode compiler doesn't know that you intend RANGE to be a constant -- it thinks it's a variable to bind a value to. To make this work you need to find a way to refer to the value that isn't just a bare name. One way would be to define your constants using an enum: class Options(Enum): RANGE = "RANGE" MANDATORY = "MANDATORY" match stuff: case Options.RANGE: ... case Options.MANDATORY: ... -- Greg From rosuav at gmail.com Wed Jun 7 20:01:55 2023 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 8 Jun 2023 10:01:55 +1000 Subject: Match statement with literal strings In-Reply-To: References: Message-ID: On Thu, 8 Jun 2023 at 08:19, Jason Friedman via Python-list wrote: > > This gives the expected results: > > with open(data_file, newline="") as reader: > csvreader = csv.DictReader(reader) > for row in csvreader: > #print(row) > match row[RULE_TYPE]: > case "RANGE": > print("range") > case "MANDATORY": > print("mandatory") > case _: > print("nothing to do") > > This: > > RANGE = "RANGE" > MANDATORY = "MANDATORY" > with open(data_file, newline="") as reader: > csvreader = csv.DictReader(reader) > for row in csvreader: > #print(row) > match row[RULE_TYPE]: > case RANGE: > print("range") > case MANDATORY: > print("mandatory") > case _: > print("nothing to do") > > Gives (and I don't understand why): > > SyntaxError: name capture 'RANGE' makes remaining patterns unreachable It's being as clear as it can. When you say "case RANGE:", that is not a literal, that is a name capture. Check the docs and examples for case statements for more details. ChrisA From jsf80238 at gmail.com Wed Jun 7 20:44:53 2023 From: jsf80238 at gmail.com (Jason Friedman) Date: Wed, 7 Jun 2023 18:44:53 -0600 Subject: Match statement with literal strings In-Reply-To: References: Message-ID: > > The bytecode compiler doesn't know that you intend RANGE > to be a constant -- it thinks it's a variable to bind a > value to. > > To make this work you need to find a way to refer to the > value that isn't just a bare name. One way would be to > define your constants using an enum: > > class Options(Enum): > RANGE = "RANGE" > MANDATORY = "MANDATORY" > > match stuff: > case Options.RANGE: > ... > case Options.MANDATORY: > ... > Got it, thank you. On Wed, Jun 7, 2023 at 6:01?PM Greg Ewing via Python-list < python-list at python.org> wrote: > On 8/06/23 10:18 am, Jason Friedman wrote: > > SyntaxError: name capture 'RANGE' makes remaining patterns unreachable > > The bytecode compiler doesn't know that you intend RANGE > to be a constant -- it thinks it's a variable to bind a > value to. > > To make this work you need to find a way to refer to the > value that isn't just a bare name. One way would be to > define your constants using an enum: > > class Options(Enum): > RANGE = "RANGE" > MANDATORY = "MANDATORY" > > match stuff: > case Options.RANGE: > ... > case Options.MANDATORY: > ... > > -- > Greg > > > -- > https://mail.python.org/mailman/listinfo/python-list > From list1 at tompassin.net Thu Jun 8 00:01:29 2023 From: list1 at tompassin.net (Thomas Passin) Date: Thu, 8 Jun 2023 00:01:29 -0400 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: References: <3a06f644-9e74-efa9-5e5c-7886a0aa5071@tompassin.net> Message-ID: On 6/7/2023 6:28 PM, Eryk Sun wrote: > On 6/7/23, Thomas Passin via Python-list wrote: >> >> You have by now seen several responses, and the one most likely to be >> helpful is to run pip with >> >> py -m pip > > That won't be of any help if pip isn't installed. By default, Python's > installer attempts to install pip by running the ensurepip package, > but sometimes it fails. It can help to try to manually run ensurepip > in the shell. For example: > > py -m ensurepip --default-pip --upgrade --verbose Yes, but why should anyone besides the OP think pip isn't installed? Let him try py -m pip. If pip isn't installed he will see something like C:\Users\tom\AppData\Local\Programs\Python\Python311\python.exe: No module named pip Then ensurepip should take care of it. Otherwise it's just that he hasn't tried the one thing that will certainly work as expected if pip is present. From eryksun at gmail.com Thu Jun 8 03:00:15 2023 From: eryksun at gmail.com (Eryk Sun) Date: Thu, 8 Jun 2023 02:00:15 -0500 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: References: <3a06f644-9e74-efa9-5e5c-7886a0aa5071@tompassin.net> Message-ID: On 6/7/23, Thomas Passin via Python-list wrote: > On 6/7/2023 6:28 PM, Eryk Sun wrote: > >> That won't be of any help if pip isn't installed. By default, Python's >> installer attempts to install pip by running the ensurepip package, >> but sometimes it fails. It can help to try to manually run ensurepip >> in the shell. For example: >> >> py -m ensurepip --default-pip --upgrade --verbose > > Yes, but why should anyone besides the OP think pip isn't installed? Let > him try py -m pip. If pip isn't installed he will see something like I didn't mean to imply that the OP shouldn't first try to run `py -m pip` or `py -3.10 -m pip`. From mk1853387 at gmail.com Thu Jun 8 15:48:05 2023 From: mk1853387 at gmail.com (marc nicole) Date: Thu, 8 Jun 2023 21:48:05 +0200 Subject: cubes library docs are not accurate, first example failing unexpectedly Message-ID: Hello to All, I want to create a cube from csv data file and to perform and aggregation on it, the code is below: from sqlalchemy import create_enginefrom cubes.tutorial.sql import create_table_from_csvfrom cubes import Workspace, Cell, browser import dataif __name__ == '__main__': engine = create_engine('sqlite:///data.sqlite') create_table_from_csv(engine, "../data/data.csv", table_name="irbd_balance", fields=[ ("category", "string"), ("category_label", "string"), ("subcategory", "string"), ("subcategory_label", "string"), ("line_item", "string"), ("year", "integer"), ("amount", "integer")], create_id=True ) print("done. file data.sqlite created") workspace = Workspace() workspace.register_default_store("sql", url="sqlite:///data.sqlite") workspace.import_model("../model.json") cube = workspace.cube("irbd_balance") browser = workspace.browser("irbd_balance") cell = Cell(cube) result = browser.aggregate(cell, drilldown=["year"]) for record in result.drilldown: print(record) The tutorial and the library are available here: https://pythonhosted.org/cubes/tutorial.html The error stack is : result = browser.aggregate(cell, drilldown=["year"]) File "C:\Users\path\venv\lib\site-packages\cubes\browser.py", line 145, in aggregate result = self.provide_aggregate(cell, File "C:\path\venv\lib\site-packages\cubes\sql\browser.py", line 400, in provide_aggregate (statement, labels) = self.aggregation_statement(cell, File "C:\path\venv\lib\site-packages\cubes\sql\browser.py", line 532, in aggregation_statement raise ArgumentError("List of aggregates should not be empty") cubes.errors.ArgumentError: List of aggregates should not be empty It seems the tutorial contains some typos. Any idea how to fix this? Else is there any other better olap cubes library for Python that has great docs? From wlfraed at ix.netcom.com Thu Jun 8 15:14:34 2023 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Thu, 08 Jun 2023 15:14:34 -0400 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> Message-ID: On Wed, 7 Jun 2023 10:36:22 -0600, Mats Wichmann declaimed the following: >I'm assuming you checked - say, with Explorer - that pip.exe really is >where you think it is? >Anyway, if you ask a Windows shell (cmd) to locate it, and it doesn't, >then your PATH is not set up correctly after all. > >where pip > >should give you back a path that ends witn ...\Scripts\pip.exe > I'm having a suspicion that recent Windows installers are not including a pip.exe... -=-=- C:\Users\Owner>echo %path% C:\Python310\Scripts\;C:\Python310\;C:\Python310\Tools\Scripts;C:\Program Files\PuTTY\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Common Files\Acronis\VirtualFile\;C:\Program Files (x86)\Common Files\Acronis\VirtualFile64\;C:\Program Files (x86)\Common Files\Acronis\FileProtector\;C:\Program Files (x86)\Common Files\Acronis\FileProtector64\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files\ooRexx;C:\Program Files\rexx.org\Regina;C:\Program Files\Microchip\xc8\v2.41\bin;C:\Program Files\Microchip\xc8\v2.36\bin;C:\Program Files\Microchip\xc16\v2.00\bin;C:\Program Files\Microchip\xc32\v4.21\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\dotnet\;C:\Program Files\TortoiseHg\;C:\Program Files\Calibre2\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin\;C:\Users\Owner\AppData\Local\Microsoft\WindowsApps;C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.2\bin;;C:\Users\Owner\.dotnet\tools C:\Users\Owner>where pip.* INFO: Could not find files for the given pattern(s). C:\Users\Owner> -=-=- Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https://aka.ms/pscore6 PS C:\Users\Owner> Get-ChildItem -Path C:\Python310\ -Recurse -Name -Filter "pip.*" Lib\site-packages\pip Lib\site-packages\pipenv\patched\pip Lib\site-packages\pipenv\utils\pip.py Lib\site-packages\pipenv\utils\__pycache__\pip.cpython-310.pyc PS C:\Users\Owner> -=-=- I've just run the installer -- python-3.10.11-amd64.exe -- as admin, in "repair" mode! There is NO pip.exe under the Python install directory. From list1 at tompassin.net Thu Jun 8 17:22:22 2023 From: list1 at tompassin.net (Thomas Passin) Date: Thu, 8 Jun 2023 17:22:22 -0400 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> Message-ID: <8d5a68c4-6bca-9a01-e443-6e57d178948b@tompassin.net> On 6/8/2023 3:14 PM, Dennis Lee Bieber via Python-list wrote: > On Wed, 7 Jun 2023 10:36:22 -0600, Mats Wichmann > declaimed the following: > > >> I'm assuming you checked - say, with Explorer - that pip.exe really is >> where you think it is? >> Anyway, if you ask a Windows shell (cmd) to locate it, and it doesn't, >> then your PATH is not set up correctly after all. >> >> where pip >> >> should give you back a path that ends witn ...\Scripts\pip.exe >> > > I'm having a suspicion that recent Windows installers are not including > a pip.exe... > > -=-=- > C:\Users\Owner>echo %path% > C:\Python310\Scripts\;C:\Python310\;C:\Python310\Tools\Scripts;C:\Program > Files\PuTTY\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program > Files (x86)\Common Files\Acronis\VirtualFile\;C:\Program Files (x86)\Common > Files\Acronis\VirtualFile64\;C:\Program Files (x86)\Common > Files\Acronis\FileProtector\;C:\Program Files (x86)\Common > Files\Acronis\FileProtector64\;C:\Program Files (x86)\Common > Files\Acronis\SnapAPI\;C:\Program Files\ooRexx;C:\Program > Files\rexx.org\Regina;C:\Program Files\Microchip\xc8\v2.41\bin;C:\Program > Files\Microchip\xc8\v2.36\bin;C:\Program > Files\Microchip\xc16\v2.00\bin;C:\Program > Files\Microchip\xc32\v4.21\bin;C:\Program Files\Microsoft VS > Code\bin;C:\Program Files\dotnet\;C:\Program Files\TortoiseHg\;C:\Program > Files\Calibre2\;C:\Program Files\Microsoft SQL > Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client > SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\IVI > Foundation\VISA\WinNT\Bin\;C:\Users\Owner\AppData\Local\Microsoft\WindowsApps;C:\Program > Files\JetBrains\PyCharm Community Edition > 2021.1.2\bin;;C:\Users\Owner\.dotnet\tools > > C:\Users\Owner>where pip.* > INFO: Could not find files for the given pattern(s). > > C:\Users\Owner> > -=-=- > Windows PowerShell > Copyright (C) Microsoft Corporation. All rights reserved. > > Try the new cross-platform PowerShell https://aka.ms/pscore6 > > PS C:\Users\Owner> Get-ChildItem -Path C:\Python310\ -Recurse -Name -Filter > "pip.*" > Lib\site-packages\pip > Lib\site-packages\pipenv\patched\pip > Lib\site-packages\pipenv\utils\pip.py > Lib\site-packages\pipenv\utils\__pycache__\pip.cpython-310.pyc > PS C:\Users\Owner> > -=-=- > > I've just run the installer -- python-3.10.11-amd64.exe -- as admin, in > "repair" mode! There is NO pip.exe under the Python install directory. It's in the Scripts directory: C:\Users\tom\AppData\Local\Programs\Python\Python311\Scripts\pip3.exe Note that this installation was made for a single user, not "All Users" - this is an install-time option. For an "All Users" location (I happened to install 3.9 for "All Users"), it does go into %PROGRAMFILES%: C:\Program Files\Python39\Scripts\pip.exe Whether this directory ends up on the PATH depends on a user option during installation. That's one among several reasons to invoke pip with py -m pip. It always gets installed, though. From eryksun at gmail.com Thu Jun 8 18:23:16 2023 From: eryksun at gmail.com (Eryk Sun) Date: Thu, 8 Jun 2023 17:23:16 -0500 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: <8d5a68c4-6bca-9a01-e443-6e57d178948b@tompassin.net> References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> <8d5a68c4-6bca-9a01-e443-6e57d178948b@tompassin.net> Message-ID: On 6/8/23, Thomas Passin via Python-list wrote: > > It always gets installed, though. By default, the option to install pip is enabled. It's implemented by executing ensurepip after the interpreter is installed. However, ensurepip may silently fail during installation. As a CPython triager I've come across this problem a couple of times, but it should be rare. It can possibly be resolved by manually executing ensurepip via the following command: py [-3[.X]] -m ensurepip --default-pip --upgrade --verbose If Python is installed for all users, the latter should be executed from a shell that has administrator access. Even if this command also fails, the verbose output in the console may be helpful to further diagnose the problem. From list1 at tompassin.net Thu Jun 8 18:52:00 2023 From: list1 at tompassin.net (Thomas Passin) Date: Thu, 8 Jun 2023 18:52:00 -0400 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> <8d5a68c4-6bca-9a01-e443-6e57d178948b@tompassin.net> Message-ID: On 6/8/2023 6:23 PM, Eryk Sun wrote: > on 6/8/23, Thomas Passin via Python-list wrote: >> >> It always gets installed, though. > > By default, the option to install pip is enabled. It's implemented by > executing ensurepip after the interpreter is installed. However, > ensurepip may silently fail during installation. As a CPython triager > I've come across this problem a couple of times, but it should be > rare. It can possibly be resolved by manually executing ensurepip via > the following command: > > py [-3[.X]] -m ensurepip --default-pip --upgrade --verbose > > If Python is installed for all users, the latter should be executed > from a shell that has administrator access. Even if this command also > fails, the verbose output in the console may be helpful to further > diagnose the problem. Hah! I *knew* someone would come up with an exceptional case. It would be pretty hard for an ordinary user to know about this encantation or make progress if something does go wrong. Lucky for me I've always had the python.org installer work smoothly. "By default, the option to install pip is enabled" - Why would someone opt not to install pip, though? Would that be an attempt to prevent users from installing packages on their own? From gvanem at yahoo.no Fri Jun 9 04:44:35 2023 From: gvanem at yahoo.no (Gisle Vanem) Date: Fri, 9 Jun 2023 10:44:35 +0200 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> Message-ID: <668c5aa1-5f78-1ea9-9a9e-2892b463ac7b@yahoo.no> Dennis Lee Bieber wrote: > Windows PowerShell > Copyright (C) Microsoft Corporation. All rights reserved. > > Try the new cross-platform PowerShell https://aka.ms/pscore6 > > PS C:\Users\Owner> Get-ChildItem -Path C:\Python310\ -Recurse -Name -Filter > "pip.*" Tried it. Oh man what a slow process: sync & timer & pwsh -Command Get-ChildItem -Path F:\gv\Python310\ -Recurse -Name -Filter "pip.*" & timer (15 results stripped). Completed in 12.44 sec! As opposed to my own Envtool: sync & timer & envtool.exe --evry pip.* | grep "Python310" & timer (15 results stripped) Completed in 0.57 sec! But I have 5 GByte of stuff under 'f:\gv\Python310\' Envtool is at https://github.com/gvanem/Envtool Works best together with the amazing EveryThing search engine by David Carpenter at https://www.voidtools.com -- --gv From simon+python at bleah.co.uk Fri Jun 9 11:41:42 2023 From: simon+python at bleah.co.uk (Simon Ward) Date: Fri, 9 Jun 2023 16:41:42 +0100 Subject: OT: Addition of a .= operator In-Reply-To: <23670349-c935-f10a-af48-f21862b28736@DancesWithMice.info> References: <435bae66-e0b8-49da-bb39-10606492b59dn@googlegroups.com> <08af3c3a-ba3b-0b15-554e-6ff12cbcf880@btinternet.com> <20230523210326.cxxuju345jkqaqp5@hjp.at> <9d8badab-4af7-8b5b-92a3-2fc7b1ea2fec@btinternet.com> <7485cf2f-f9ff-7891-024e-b1e395a6bb6a@DancesWithMice.info> <23670349-c935-f10a-af48-f21862b28736@DancesWithMice.info> Message-ID: <20230609154142.GB9360@bleah.co.uk> On Wed, May 24, 2023 at 05:18:52PM +1200, dn via Python-list wrote: >>Note that the line numbers correctly show the true cause of the >>problem, despite both of them being ValueErrors. So if you have to >>debug this sort of thing, make sure the key parts are on separate >>lines (even if they're all one expression, as in this example), and >>then the tracebacks should tell you what you need to know. > > >Yes, an excellent example to show newcomers to make use of 'the >information *provided*' - take a deep breath and read through it all, >picking-out the important information... > > >However, returning to "condense this into a single line", the >frequently-seen coding is (in my experience, at least): > > quantity = float( input( "How many would you like? " ) ) > >which would not produce the helpful distinction between >line-numbers/function-calls which the above (better-formatted) code >does! Old thread I know, but thought it was worth pointing out that Python 3.11 brought in fine-graned error locations in tracebacks[1]: $ python3.10 asin.py Enter a small number: 4 Traceback (most recent call last): File "/home/p10365088/asin.py", line 3, in print(math.asin(float(input("Enter a small number: ")))) ValueError: math domain error $ python3.11 asin.py Enter a small number: 4 Traceback (most recent call last): File "/home/p10365088/asin.py", line 3, in print(math.asin(float(input("Enter a small number: ")))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: math domain error [1]: https://docs.python.org/3/whatsnew/3.11.html#whatsnew311-pep657 Regards, Simon -- A complex system that works is invariably found to have evolved from a simple system that works.?John Gall From wlfraed at ix.netcom.com Fri Jun 9 13:43:40 2023 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Fri, 09 Jun 2023 13:43:40 -0400 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> <8d5a68c4-6bca-9a01-e443-6e57d178948b@tompassin.net> Message-ID: On Thu, 8 Jun 2023 17:22:22 -0400, Thomas Passin declaimed the following: >On 6/8/2023 3:14 PM, Dennis Lee Bieber via Python-list wrote: > C:\Users\Owner> >> -=-=- >> Windows PowerShell >> Copyright (C) Microsoft Corporation. All rights reserved. >> >> Try the new cross-platform PowerShell https://aka.ms/pscore6 >> >> PS C:\Users\Owner> Get-ChildItem -Path C:\Python310\ -Recurse -Name -Filter >> "pip.*" >> Lib\site-packages\pip >> Lib\site-packages\pipenv\patched\pip >> Lib\site-packages\pipenv\utils\pip.py >> Lib\site-packages\pipenv\utils\__pycache__\pip.cpython-310.pyc >> PS C:\Users\Owner> >> -=-=- >> >> I've just run the installer -- python-3.10.11-amd64.exe -- as admin, in >> "repair" mode! There is NO pip.exe under the Python install directory. > >It's in the Scripts directory: > >C:\Users\tom\AppData\Local\Programs\Python\Python311\Scripts\pip3.exe > >Note that this installation was made for a single user, not "All Users" >- this is an install-time option. For an "All Users" location (I >happened to install 3.9 for "All Users"), it does go into %PROGRAMFILES%: > I always install in "All Users" mode, but specify a directory that is NOT under "Program Files" -- in this case, C:\Python310 The PowerShell command recurses into all subdirectories of the -path argument. As it shows, the ONLY "pip" found is the actual library module. PS C:\Users\Owner> Get-ChildItem -Path C:\P*\ -Recurse -Name -Filter "pip.*" R\R-4.2.3\library\climextRemes\pip R\R-4.2.3\library\vICC\help\figures\pip.png Package Cache\{5C3F818F-9EF5-444C-9386-77A0063A383A}v3.10.11150.0\pip.msi Package Cache\{861EF849-90A5-4F4A-BAD4-479141466551}v3.10.10150.0\pip.msi Lib\site-packages\pip Lib\site-packages\pipenv\patched\pip Lib\site-packages\pipenv\utils\pip.py Lib\site-packages\pipenv\utils\__pycache__\pip.cpython-310.pyc PS C:\Users\Owner> Get-ChildItem -Path C:\P*\ -Recurse -Name -Filter "pip*.exe" Common Files\Microsoft Shared\ink\pipanel.exe {F87E77CE-BAA2-49E1-AAE3-1F6B2704ABAA}\OFFLINE\8AFA5EE\A9DCCED0\Pipe.exe PS C:\Users\Owner> Two variations, both now including "Program Files" (and x86), "ProgramData", and the Python install; one looking for "pip", the other "pipexe". Again, nothing found except the library module. "ensurepip" appears to only verify that the library module is installed and does not seem to look for any .exe or other convenience access file. PS C:\Users\Owner> python -m ensurepip Looking in links: c:\Users\Owner\AppData\Local\Temp\tmp0cr7yu4s Requirement already satisfied: setuptools in c:\python310\lib\site-packages (67.6.1) Requirement already satisfied: pip in c:\python310\lib\site-packages (23.0.1) PS C:\Users\Owner> From list1 at tompassin.net Sat Jun 10 09:29:15 2023 From: list1 at tompassin.net (Thomas Passin) Date: Sat, 10 Jun 2023 09:29:15 -0400 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> <8d5a68c4-6bca-9a01-e443-6e57d178948b@tompassin.net> Message-ID: <557ca297-2fc4-57b8-0b52-ad3350b4c63e@tompassin.net> On 6/9/2023 1:43 PM, Dennis Lee Bieber via Python-list wrote: > On Thu, 8 Jun 2023 17:22:22 -0400, Thomas Passin > declaimed the following: > >> On 6/8/2023 3:14 PM, Dennis Lee Bieber via Python-list wrote: >> C:\Users\Owner> >>> -=-=- >>> Windows PowerShell >>> Copyright (C) Microsoft Corporation. All rights reserved. >>> >>> Try the new cross-platform PowerShell https://aka.ms/pscore6 >>> >>> PS C:\Users\Owner> Get-ChildItem -Path C:\Python310\ -Recurse -Name -Filter >>> "pip.*" >>> Lib\site-packages\pip >>> Lib\site-packages\pipenv\patched\pip >>> Lib\site-packages\pipenv\utils\pip.py >>> Lib\site-packages\pipenv\utils\__pycache__\pip.cpython-310.pyc >>> PS C:\Users\Owner> >>> -=-=- >>> >>> I've just run the installer -- python-3.10.11-amd64.exe -- as admin, in >>> "repair" mode! There is NO pip.exe under the Python install directory. >> >> It's in the Scripts directory: >> >> C:\Users\tom\AppData\Local\Programs\Python\Python311\Scripts\pip3.exe I copied the wrong line of my output - pip.exe is in the same place as pip3.exe. >> Note that this installation was made for a single user, not "All Users" >> - this is an install-time option. For an "All Users" location (I >> happened to install 3.9 for "All Users"), it does go into %PROGRAMFILES%: >> > I always install in "All Users" mode, but specify a directory that is > NOT under "Program Files" -- in this case, C:\Python310 > > The PowerShell command recurses into all subdirectories of the -path > argument. As it shows, the ONLY "pip" found is the actual library module. > > PS C:\Users\Owner> Get-ChildItem -Path C:\P*\ -Recurse -Name -Filter > "pip.*" > R\R-4.2.3\library\climextRemes\pip > R\R-4.2.3\library\vICC\help\figures\pip.png > Package Cache\{5C3F818F-9EF5-444C-9386-77A0063A383A}v3.10.11150.0\pip.msi > Package Cache\{861EF849-90A5-4F4A-BAD4-479141466551}v3.10.10150.0\pip.msi > Lib\site-packages\pip > Lib\site-packages\pipenv\patched\pip > Lib\site-packages\pipenv\utils\pip.py > Lib\site-packages\pipenv\utils\__pycache__\pip.cpython-310.pyc > PS C:\Users\Owner> Get-ChildItem -Path C:\P*\ -Recurse -Name -Filter > "pip*.exe" > Common Files\Microsoft Shared\ink\pipanel.exe > {F87E77CE-BAA2-49E1-AAE3-1F6B2704ABAA}\OFFLINE\8AFA5EE\A9DCCED0\Pipe.exe > PS C:\Users\Owner> > > Two variations, both now including "Program Files" (and x86), > "ProgramData", and the Python install; one looking for > "pip", the other "pipexe". Again, nothing > found except the library module. > > "ensurepip" appears to only verify that the library module is installed > and does not seem to look for any .exe or other convenience access file. > > PS C:\Users\Owner> python -m ensurepip > Looking in links: c:\Users\Owner\AppData\Local\Temp\tmp0cr7yu4s > Requirement already satisfied: setuptools in c:\python310\lib\site-packages > (67.6.1) > Requirement already satisfied: pip in c:\python310\lib\site-packages > (23.0.1) > PS C:\Users\Owner> The standard python.org installs pip.exe in the Scripts directory and a pip folder in the Lib\site-packages directory. The pip directory does not include an actual file named "pip.py", but through Python invocation magic (involving __main__), py -m pip finds the right entry point and runs what you want. We can find pip.exe using good old-fashioned dir (we don't need any new-fangled Powershell): C:\Users\tom>dir AppData\Local\Programs\Python /Aa /S /W /B |find "pip"|find "Scripts" C:\Users\tom\AppData\Local\Programs\Python\Python310\Scripts\pip.exe C:\Users\tom\AppData\Local\Programs\Python\Python310\Scripts\pip3.10.exe C:\Users\tom\AppData\Local\Programs\Python\Python310\Scripts\pip3.exe C:\Users\tom\AppData\Local\Programs\Python\Python310\Scripts\pipx.exe C:\Users\tom\AppData\Local\Programs\Python\Python311\Scripts\pip.exe C:\Users\tom\AppData\Local\Programs\Python\Python311\Scripts\pip3.11.exe C:\Users\tom\AppData\Local\Programs\Python\Python311\Scripts\pip3.exe C:\Users\tom\AppData\Local\Programs\Python\Python37\Scripts\pip.exe C:\Users\tom\AppData\Local\Programs\Python\Python37\Scripts\pip3.10.exe C:\Users\tom\AppData\Local\Programs\Python\Python37\Scripts\pip3.7.exe C:\Users\tom\AppData\Local\Programs\Python\Python37\Scripts\pip3.exe Searching for a "pip" directory: C:\Users\tom>dir AppData\Local\Programs\Python /Ad /S /W /B |find "pip" |find /V "_" C:\Users\tom\AppData\Local\Programs\Python\Python310\Lib\ensurepip C:\Users\tom\AppData\Local\Programs\Python\Python310\Lib\site-packages\pip C:\Users\tom\AppData\Local\Programs\Python\Python310\Lib\site-packages\pip-23.1.dist-info C:\Users\tom\AppData\Local\Programs\Python\Python310\Lib\site-packages\pipx C:\Users\tom\AppData\Local\Programs\Python\Python310\Lib\site-packages\pipx-1.1.0.dist-info C:\Users\tom\AppData\Local\Programs\Python\Python310\Lib\site-packages\mypy\typeshed\stdlib\ensurepip C:\Users\tom\AppData\Local\Programs\Python\Python310\Lib\site-packages\mypy\typeshed\stdlib\@python2\ensurepip C:\Users\tom\AppData\Local\Programs\Python\Python310\Lib\site-packages\pipx\commands C:\Users\tom\AppData\Local\Programs\Python\Python310\Lib\site-packages\win32\Demos\pipes C:\Users\tom\AppData\Local\Programs\Python\Python311\Lib\ensurepip C:\Users\tom\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip C:\Users\tom\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip-23.1.2.dist-info C:\Users\tom\AppData\Local\Programs\Python\Python37\Lib\ensurepip C:\Users\tom\AppData\Local\Programs\Python\Python37\Lib\site-packages\pip C:\Users\tom\AppData\Local\Programs\Python\Python37\Lib\site-packages\pip-22.3.1.dist-info C:\Users\tom\AppData\Local\Programs\Python\Python37\Lib\site-packages\win32\Demos\pipes A little hard to read but it does find the site-packages pip directory. If you have a grep or awk available, you could use it instead of find to make the output more concise. Or if you have grep or awk and don't mind waiting a little longer for the results: C:\Users\tom>dir AppData /Ad /S /W /B |awk "/\\pip$/ {print $1}" C:\Users\tom\AppData\Local\pip C:\Users\tom\AppData\Local\Programs\Python\Python310\Lib\site-packages\pip C:\Users\tom\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip C:\Users\tom\AppData\Local\Programs\Python\Python37\Lib\site-packages\pip C:\Users\tom\AppData\Roaming\Python\Python39\site-packages\pip and, with grep: C:\Users\tom>dir AppData /Aa /S /W /B |agrep "pip.exe" C:\Users\tom\AppData\Local\Programs\Python\Python310\Scripts\pip.exe C:\Users\tom\AppData\Local\Programs\Python\Python311\Scripts\pip.exe C:\Users\tom\AppData\Local\Programs\Python\Python37\Scripts\pip.exe C:\Users\tom\AppData\Roaming\Python\Python310\Scripts\pip.exe C:\Users\tom\AppData\Roaming\Python\Python39\Scripts\pip.exe Grand Total: 5 match(es) found. From eryksun at gmail.com Sat Jun 10 12:32:53 2023 From: eryksun at gmail.com (Eryk Sun) Date: Sat, 10 Jun 2023 11:32:53 -0500 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: <557ca297-2fc4-57b8-0b52-ad3350b4c63e@tompassin.net> References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> <8d5a68c4-6bca-9a01-e443-6e57d178948b@tompassin.net> <557ca297-2fc4-57b8-0b52-ad3350b4c63e@tompassin.net> Message-ID: On 6/10/23, Thomas Passin via Python-list wrote: > > We can find pip.exe using good old-fashioned dir (we don't need any > new-fangled Powershell): > > C:\Users\tom>dir AppData\Local\Programs\Python /Aa /S /W /B |find > "pip"|find "Scripts" CMD's `dir` and `for` commands support simple wildcard matching. For example, the following recursively searches for a file named "pip*.exe" under "%ProgramFiles%\Python311": C:\>dir /b /s "%ProgramFiles%\Python311\pip*.exe" C:\Program Files\Python311\Scripts\pip.exe C:\Program Files\Python311\Scripts\pip3.11.exe C:\Program Files\Python311\Scripts\pip3.exe C:\>for /r "%ProgramFiles%\Python311" %f in (pip*.exe) do @(echo %f) C:\Program Files\Python311\Scripts\pip.exe C:\Program Files\Python311\Scripts\pip3.11.exe C:\Program Files\Python311\Scripts\pip3.exe The following recursively searches for a directory named "pip" under "%ProgramFiles%\Python311: C:\>dir /ad /b /s "%ProgramFiles%\Python311\pip" C:\Program Files\Python311\Lib\site-packages\pip Or search for a directory name that starts with "pip": C:\>dir /ad /b /s "%ProgramFiles%\Python311\pip*" C:\Program Files\Python311\Lib\site-packages\pip C:\Program Files\Python311\Lib\site-packages\pip-22.3.1.dist-info C:\Program Files\Python311\Lib\site-packages\win32\Demos\pipes With a recursive `for /r path [/d]` loop, the strings in the set have to include wildcard characters to actually check for an existing file or directory, else each string in the set simply gets appended to the directory names in the recursive walk. For example, the following recursively searches for a directory (i.e. /d) named "pip*" under "%ProgramFiles%\Python311": C:\>for /r "%ProgramFiles%\Python311" /d %d in (pip*) do @(echo %d) C:\Program Files\Python311\Lib\site-packages\pip C:\Program Files\Python311\Lib\site-packages\pip-22.3.1.dist-info C:\Program Files\Python311\Lib\site-packages\win32\Demos\pipes To match a specific name, you can filter the matches using an `if` statement to compare the base filename of the loop variable (i.e. [n]ame + e[x]tension) with the required name. For example: C:\>for /r "%ProgramFiles%\Python311" /d %d in (pip*) do @( More? if "%~nxd"=="pip" echo %d) C:\Program Files\Python311\Lib\site-packages\pip From list1 at tompassin.net Sat Jun 10 14:31:52 2023 From: list1 at tompassin.net (Thomas Passin) Date: Sat, 10 Jun 2023 14:31:52 -0400 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> <8d5a68c4-6bca-9a01-e443-6e57d178948b@tompassin.net> <557ca297-2fc4-57b8-0b52-ad3350b4c63e@tompassin.net> Message-ID: <10134763-feb8-078d-cf88-2837a953b102@tompassin.net> On 6/10/2023 12:32 PM, Eryk Sun wrote: > On 6/10/23, Thomas Passin via Python-list wrote: >> >> We can find pip.exe using good old-fashioned dir (we don't need any >> new-fangled Powershell): >> >> C:\Users\tom>dir AppData\Local\Programs\Python /Aa /S /W /B |find >> "pip"|find "Scripts" > > CMD's `dir` and `for` commands support simple wildcard matching. For > example, the following recursively searches for a file named > "pip*.exe" under "%ProgramFiles%\Python311": > > C:\>dir /b /s "%ProgramFiles%\Python311\pip*.exe" > C:\Program Files\Python311\Scripts\pip.exe > C:\Program Files\Python311\Scripts\pip3.11.exe > C:\Program Files\Python311\Scripts\pip3.exe > > C:\>for /r "%ProgramFiles%\Python311" %f in (pip*.exe) do @(echo %f) > C:\Program Files\Python311\Scripts\pip.exe > C:\Program Files\Python311\Scripts\pip3.11.exe > C:\Program Files\Python311\Scripts\pip3.exe > > The following recursively searches for a directory named "pip" under > "%ProgramFiles%\Python311: > > C:\>dir /ad /b /s "%ProgramFiles%\Python311\pip" > C:\Program Files\Python311\Lib\site-packages\pip > > Or search for a directory name that starts with "pip": > > C:\>dir /ad /b /s "%ProgramFiles%\Python311\pip*" > C:\Program Files\Python311\Lib\site-packages\pip > C:\Program Files\Python311\Lib\site-packages\pip-22.3.1.dist-info > C:\Program Files\Python311\Lib\site-packages\win32\Demos\pipes > > With a recursive `for /r path [/d]` loop, the strings in the set have > to include wildcard characters to actually check for an existing file > or directory, else each string in the set simply gets appended to the > directory names in the recursive walk. For example, the following > recursively searches for a directory (i.e. /d) named "pip*" under > "%ProgramFiles%\Python311": > > C:\>for /r "%ProgramFiles%\Python311" /d %d in (pip*) do @(echo %d) > C:\Program Files\Python311\Lib\site-packages\pip > C:\Program Files\Python311\Lib\site-packages\pip-22.3.1.dist-info > C:\Program Files\Python311\Lib\site-packages\win32\Demos\pipes > > To match a specific name, you can filter the matches using an `if` > statement to compare the base filename of the loop variable (i.e. > [n]ame + e[x]tension) with the required name. For example: > > C:\>for /r "%ProgramFiles%\Python311" /d %d in (pip*) do @( > More? if "%~nxd"=="pip" echo %d) > C:\Program Files\Python311\Lib\site-packages\pip Yes; I didn't want to get too esoteric with commands that are hard to figure out and remember, because then why not use Powershell, whose commands are hard to figure out and remember? From eryksun at gmail.com Sat Jun 10 15:20:01 2023 From: eryksun at gmail.com (Eryk Sun) Date: Sat, 10 Jun 2023 14:20:01 -0500 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: <10134763-feb8-078d-cf88-2837a953b102@tompassin.net> References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> <8d5a68c4-6bca-9a01-e443-6e57d178948b@tompassin.net> <557ca297-2fc4-57b8-0b52-ad3350b4c63e@tompassin.net> <10134763-feb8-078d-cf88-2837a953b102@tompassin.net> Message-ID: On 6/10/23, Thomas Passin via Python-list wrote: > > Yes; I didn't want to get too esoteric with commands that are hard to > figure out and remember, because then why not use Powershell, whose > commands are hard to figure out and remember? Using `dir /s [/ad] [/b] "[path\]pattern"` with a wildcard pattern is a simple way to recursively search for a filename or directory, without needing to pipe the output to a findstr/grep/awk command. It's also fast. Of course, CMD's wildcards aren't nearly as powerful as regular expressions. The examples I included with `for` loops in CMD were for completeness to show how to get the results in a loop variable for further processing in a batch script. Personally, I use `for` loops a lot even when working at the command prompt, but I'm a dinosaur in that regard. Using PowerShell really should be preferred nowadays. From list1 at tompassin.net Sat Jun 10 15:39:55 2023 From: list1 at tompassin.net (Thomas Passin) Date: Sat, 10 Jun 2023 15:39:55 -0400 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation In-Reply-To: References: <14a5d5f5-3065-0087-182c-c45c7ec3d4d3@mrabarnett.plus.com> <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> <8d5a68c4-6bca-9a01-e443-6e57d178948b@tompassin.net> <557ca297-2fc4-57b8-0b52-ad3350b4c63e@tompassin.net> <10134763-feb8-078d-cf88-2837a953b102@tompassin.net> Message-ID: <1cad4aec-6707-56d7-ec37-5835fb4bf147@tompassin.net> On 6/10/2023 3:20 PM, Eryk Sun wrote: > On 6/10/23, Thomas Passin via Python-list wrote: >> >> Yes; I didn't want to get too esoteric with commands that are hard to >> figure out and remember, because then why not use Powershell, whose >> commands are hard to figure out and remember? > > Using `dir /s [/ad] [/b] "[path\]pattern"` with a wildcard pattern is > a simple way to recursively search for a filename or directory, > without needing to pipe the output to a findstr/grep/awk command. It's > also fast. Of course, CMD's wildcards aren't nearly as powerful as > regular expressions. I used find to reduce the number of unwanted hits, which was helpful and easy to understand even if not very powerful. > The examples I included with `for` loops in CMD were for completeness > to show how to get the results in a loop variable for further > processing in a batch script. Personally, I use `for` loops a lot even > when working at the command prompt, but I'm a dinosaur in that regard. > Using PowerShell really should be preferred nowadays. If one is doing them every day, and especially if it's for a script that will be reused, those loops expressions are valuable. For a one-shot use, and for the majority of users who (I'm sure) don't use them very often, they can be pretty obscure. PowerShell has some kind of repulsive field effect on me. Plus it has an ugly console appearance and seems slow. So I avoid it unless I find some particular case I really need it for, which is hardly ever. From wlfraed at ix.netcom.com Sat Jun 10 16:21:43 2023 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Sat, 10 Jun 2023 16:21:43 -0400 Subject: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation References: <65a13027-7202-53ee-fb7e-08ebaa5d3fa2@wichmann.us> <8d5a68c4-6bca-9a01-e443-6e57d178948b@tompassin.net> <557ca297-2fc4-57b8-0b52-ad3350b4c63e@tompassin.net> Message-ID: On Sat, 10 Jun 2023 11:32:53 -0500, Eryk Sun declaimed the following: >On 6/10/23, Thomas Passin via Python-list wrote: >> >> We can find pip.exe using good old-fashioned dir (we don't need any >> new-fangled Powershell): >> >> C:\Users\tom>dir AppData\Local\Programs\Python /Aa /S /W /B |find >> "pip"|find "Scripts" > >CMD's `dir` and `for` commands support simple wildcard matching. For >example, the following recursively searches for a file named >"pip*.exe" under "%ProgramFiles%\Python311": > So far we've had examples of Python installed for current user, and Python installed for all users /in Program Files/. My install is for all users, but is in a top-level directory of its own (Program Files causes problems when using pip and not remembering to open an Admin shell). > C:\>dir /b /s "%ProgramFiles%\Python311\pip*.exe" So... Here are the results on my machine searching ALL of C:\ C:\Users\Owner>dir /b /s c:\pip*.exe c:\Apps\ADW Software Modula-2\ASCII\pipedexec.exe c:\Apps\ADW Software Modula-2\Unicode\pipedexec.exe c:\GNAT\2019\share\gdb-8.3\python-2.7.16\Scripts\pip.exe c:\GNAT\2019\share\gdb-8.3\python-2.7.16\Scripts\pip2.7.exe c:\GNAT\2019\share\gdb-8.3\python-2.7.16\Scripts\pip2.exe c:\Program Files (x86)\Common Files\Microsoft Shared\ink\pipanel.exe c:\ProgramData\{F87E77CE-BAA2-49E1-AAE3-1F6B2704ABAA}\OFFLINE\8AFA5EE\A9DCCED0\Pipe.exe c:\Users\All Users\{F87E77CE-BAA2-49E1-AAE3-1F6B2704ABAA}\OFFLINE\8AFA5EE\A9DCCED0\Pipe.exe c:\Users\Owner\AppData\Local\python\mu\mu_venv-38-20230331-155858\Scripts\pip-3.8.exe c:\Users\Owner\AppData\Local\python\mu\mu_venv-38-20230331-155858\Scripts\pip.exe c:\Users\Owner\AppData\Local\python\mu\mu_venv-38-20230331-155858\Scripts\pip3.8.exe c:\Users\Owner\AppData\Local\python\mu\mu_venv-38-20230331-155858\Scripts\pip3.exe c:\Users\Public\Programs\mblock\resources\app\mlink-v2\exec\python-env\win\Scripts\pip.exe c:\Users\Public\Programs\mblock\resources\app\mlink-v2\exec\python-env\win\Scripts\pip3.6.exe c:\Users\Public\Programs\mblock\resources\app\mlink-v2\exec\python-env\win\Scripts\pip3.exe c:\Windows\WinSxS\wow64_microsoft-windows-t..acyinkingcomponents_31bf3856ad364e35_10.0.19041.1_none_023783a15d5391a7\pipanel.exe C:\Users\Owner> GNAT was the last AdaCore/Libre build that included the GPS IDE (I believe AdaCore still does periodic source code releases of GPS to Linux, putting the effort to get it working on the Linux distributions -- but that doesn't help for Windows). Mu is an overly simplistic Python editor pushed by AdaFruit as it is CircuitPython board-aware. MBlock is a graphical (drag&drop code templates, fill in any parameters) which I have for an Arduino-powered robot vehicle. NO pip*.exe anywhere for Python 3.10 -- and as I stated earlier in the thread, I even ran the Python Org installer python-3.10.11-amd64.exe in /repair/ mode; though if that just spawns off ensurepip the result does not repair anything, as ensurepip finds the library module valid. (Maybe I should rename the module to junk, and try again? *) C:\Users\Owner>dir c:\p* Volume in drive C is Sys_OS Volume Serial Number is B650-6F92 Directory of c:\ 12/07/2019 05:14 AM PerfLogs 05/16/2023 04:37 PM Program Files 05/16/2023 04:37 PM Program Files (x86) 04/26/2023 03:16 PM ProgramData 01/01/2017 04:28 PM PSFONTS 02/11/2020 02:50 PM PSFONTS_Converted 06/08/2023 03:01 PM Python310 0 File(s) 0 bytes 7 Dir(s) 1,881,417,326,592 bytes free ***************************** * What a pain... Just renaming Lib\site-packages\pip => Lib\site-packages\pip-junk (and similar for the dist-info file) still had ensurepip locating it. I had to /delete/ those files completely before ensurepip would do any processing. C:\Users\Owner>python -m ensurepip Looking in links: c:\Users\Owner\AppData\Local\Temp\tmpfof5ikfr Requirement already satisfied: setuptools in c:\python310\lib\site-packages (67.6.1) Requirement already satisfied: pip in c:\python310\lib\site-packages (junk) C:\Users\Owner>python -m ensurepip Looking in links: c:\Users\Owner\AppData\Local\Temp\tmpwtielpq_ Requirement already satisfied: setuptools in c:\python310\lib\site-packages (67.6.1) Processing c:\users\owner\appdata\local\temp\tmpwtielpq_\pip-23.0.1-py3-none-any.whl Installing collected packages: pip Successfully installed pip-23.0.1 That finally installed C:\Users\Owner>where pip* C:\Python310\Scripts\pip3.10.exe C:\Python310\Scripts\pip3.exe (NO pip.exe, however). From sakasaraajnr at gmail.com Mon Jun 12 05:26:54 2023 From: sakasaraajnr at gmail.com (Real Live FootBall Tv) Date: Mon, 12 Jun 2023 10:26:54 +0100 Subject: AUTO EDITOR DIDN'T WORK Message-ID: I recently Installed and Uninstalled Python, hence the system was trying to get why I UNINSTALLED python. I did it because I was going to use it with another application, A VIDEO EDITING APP, Auto EDITOR but it didn't work for some reasons unknown to me. Seeing, therefore, that the app didn't work, I thought it was of no use keeping it occupying space within my system, hence I took it off by UNINSTALLATION. If there is anything I can do to make it work, I won't mind getting the tips from you guys, thanks. From list1 at tompassin.net Mon Jun 12 14:58:16 2023 From: list1 at tompassin.net (Thomas Passin) Date: Mon, 12 Jun 2023 14:58:16 -0400 Subject: AUTO EDITOR DIDN'T WORK In-Reply-To: References: Message-ID: <32b46ea5-d381-8ad0-9599-4a95505df18e@tompassin.net> On 6/12/2023 5:26 AM, Real Live FootBall Tv via Python-list wrote: > I recently Installed and Uninstalled Python, hence the system was trying > to get why I UNINSTALLED python. > I did it because I was going to use it with another application, A VIDEO > EDITING APP, Auto EDITOR but it didn't work for some reasons unknown to me. > Seeing, therefore, that the app didn't work, I thought it was of no use > keeping it occupying space within my system, hence I took it off by > UNINSTALLATION. > If there is anything I can do to make it work, I won't mind getting the > tips from you guys, thanks. It will be hard to impossible to help without some specific information. Like - what happened to cause you to say "it didn't work", what version of what operating system and Python you use, how you installed the Auto Editor package, and why you are asking for help after uninstalling Python. You sure won't get it working by uninstalling Python. The home page for the app is, according to PyPi, https://auto-editor.com. Have you gone through everything there before giving up? From learn2program at gmail.com Mon Jun 12 18:30:31 2023 From: learn2program at gmail.com (Alan Gauld) Date: Mon, 12 Jun 2023 23:30:31 +0100 Subject: Fwd: Re: AUTO EDITOR DIDN'T WORK Message-ID: <528ab20e-e3b2-e252-cd83-5de3e24957e1@yahoo.co.uk> On 12/06/2023 10:26, Real Live FootBall Tv via Python-list wrote: > I did it because I was going to use it with another application, A VIDEO > EDITING APP, Auto EDITOR but it didn't work for some reasons unknown to me. You need to define "didn't work" Did it work as a python interpreter? ie. Did you get a >>> prompt in a terminal? and without involvement from your video editor? If so, what did you do to link it to the video editor? And what was the result? Or did Python not even start? How did you try to use it? What OS are you on? Did the installer run OK? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos From rosuav at gmail.com Mon Jun 12 18:58:25 2023 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 13 Jun 2023 08:58:25 +1000 Subject: [Python-ideas] yield functionality to match that of await In-Reply-To: <4E314809-5EB1-404C-989F-9E7A434053F2@gmail.com> References: <83CACFA7-7FE8-4F58-ABAC-85767D9ED6F2@gmail.com> <4E314809-5EB1-404C-989F-9E7A434053F2@gmail.com> Message-ID: On Tue, 13 Jun 2023 at 08:29, Dom Grigonis wrote: > > I don't know if there's a full explanation written down, but one > > important reason is that you can refactor async functions without > > worrying about suddenly changing their behaviour unintentionally. If > > you happen to refactor out the last "yield" from a generator, suddenly > > it's not a generator any more, and you'll have a weird time trying to > > figure out what happened; but an async function is an async function > > even if it doesn't (currently) have any await points in it. > > For that it would have been easier to introduce one extra keyword like `ydef` or `gdef` as opposed to a completely new subset of a language. I think that was discussed, but the benefits were ONLY that one point, with the downside that there'd be these confusing distinctions between "functions defined this way" and "functions defined that way" that only occasionally crop up. Not a good thing. > > Another reason is that you can have asynchronous generator functions, > > which use both await AND yield. It's not easy to create a two-layer > > yielding system on top of yield alone. > > Well for that could just create a some sort of efficient standard iterator class if one wants a generator that is not triggered by coroutine loop. And set it to be the default constructor for generator comprehensions. I suppose so, but that seems a bit awkward. And "default constructor for generator comprehensions" isn't really a thing so I'm not sure how that would be implemented. > As you seem to know this topic reasonably well, hope you don?t mind me explaining the thought process I am having. > > I am currently just trying to choose my toolkit and I am having big doubts about asyc/await frameworks. I have done some benchmarking and `gevent` library is faster than all of them with one exception: asyncio with uvloop. Correct me if I am wrong, but the main selling point for all that hassle with coroutines is speed. If that is so, then the overhead that async/await libraries have introduced is hardly cutting. So I was just thinking if there were any reasons of not extending already existing keywords and functionality, which at least as it stands now has much lower overhead. > > Maybe you know any good benchmarks/materials that could provide me some sense in all this? > Hmm, I'd say coroutines aren't really about speed, they're about throughput. Let's take a TCP socket server as an example (this could be a web server, a MUD server, an IRC server, anything else). You want a basic architecture like this: def handle_client(sock): while True: line = get_line(sock) # buffered read, blah blah if line == "quit": break sock.send("blah blah") sock.close() def run_server(): mainsock = socket.socket() mainsock.bind(...) mainsock.listen(5) while sock := mainsock.accept(): print("Got a connection!", sock.getpeername()) handle_client(sock) (If I've messed something up, apologies, this is hastily whipped up from memory. Do not use this as a template for actual socket servers, it's probably buggy and definitely incomplete. Anyhow.) Now, obviously this version kinda sucks. It has to handle one client completely before going on to the next, which is utterly terrible for a long-running protocol like TELNET, and pretty poor even for HTTP 0.9. So what are the options for concurrency? 1) Spawn a subprocess for every client. Maximum overhead, maximum isolation. 2) Spin off a new thread for every client. Much much less overhead but still notable. 3) Run an event loop using select.select() or equivalent, managing everything manually. 4) Use an asyncio event loop. Individual processes scales abysmally, although occasionally the isolation is of value (FTP servers come to mind). Threads is a lot better, and I've run plenty of threaded servers in the past, but you'll run into thread limits before you run into socket limits, so at some point, threads will restrict your throughput. A lightweight event loop is by far the lowest overhead. This MIGHT be measured as higher performance, but it's usually more visible in throughput (for example, "100 transactions per second" vs "1000 transactions per second"). However, doing this manually can be a bit of a pain, as you basically have to implement your own state machine. Not too bad for some types of server, but annoying for anything that's at all stateful. So that's where asyncio comes in. It's approximately the same runtime overhead as an event loop, but with way WAY less coding overhead. In fact, the code looks basically the same as threaded or forking code - you just say "here, go run this thing in a separate task" instead of juggling all the separate state machines. "All that hassle" is, of course, a relative term. So my first question is: what are you comparing against? If you're comparing against running your own select.select() loop, it's way *less* hassle, but compared to using threads, I'd say it's pretty comparable - definitely some additional hassle (since you have to use nonblocking calls everywhere), but ideally, not too much structural change. In my opinion, asyncio is best compared against threads, although with upcoming Python versions, there may be an additional option to compare against, which is threads that run separate subinterpreters (see PEP 554 and PEP 684 for details). In the ideal situation (both PEPs accepted and implemented, and each client getting a thread with a dedicated subinterpreter), this could sit nicely between threads and processes, giving an in-between level of isolation, performance, overhead, and throughput. ChrisA From tschweikle at bfs.de Tue Jun 13 03:01:37 2023 From: tschweikle at bfs.de (Thomas Schweikle) Date: Tue, 13 Jun 2023 07:01:37 +0000 Subject: Compiling python on windows with vs Message-ID: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Hi! Trying to compile python on windows leads to following error: _testimportmultiple.vcxproj -> C:\Users\sct-muc\Documents\Projekte\cpython\PCbuild\amd64\_testimportmultiple.pyd _testmultiphase.c Bibliothek "C:\Users\sct-muc\Documents\Projekte\cpython\PCbuild\amd64\_testmultiphase.lib" und Objekt "C:\Users\sct-muc\Docume nts\Projekte\cpython\PCbuild\amd64\_testmultiphase.exp" werden erstellt. Code wird generiert. Codegenerierung ist abgeschlossen. _testmultiphase.vcxproj -> C:\Users\sct-muc\Documents\Projekte\cpython\PCbuild\amd64\_testmultiphase.pyd _testconsole.c C:\Users\sct-muc\Documents\Projekte\cpython\PC\_testconsole.c(13,10): fatal error C1083: Datei (Include) kann nicht ge?ffnet werde n: "..\modules\_io\_iomodule.h": No such file or directory [C:\Users\sct-muc\Documents\Projekte\cpython\PCbuild\_testconsole.vcxpro j] Fehler beim Buildvorgang. if I rename "Modules" to "modules" it will find "..\modules\_io\_iomodule.h" but wont find "..\Modules\..." Since Git enables Windows NTFS case sensitivity while checking out sources ... is it a bug or a "feature"? And: is there a simple workaround available besides disabling case sensitivity (which will break others)? -- Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 321 bytes Desc: OpenPGP digital signature URL: From jschwar at sbcglobal.net Tue Jun 13 13:20:38 2023 From: jschwar at sbcglobal.net (Jim Schwartz) Date: Tue, 13 Jun 2023 12:20:38 -0500 Subject: Compiling python on windows with vs In-Reply-To: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Message-ID: What version of visual studio are you using? What version of python? I?ve had success with using the cython package in python and cl from visual studio, but I haven?t tried visual studio alone. Sent from my iPhone > On Jun 13, 2023, at 11:59 AM, Thomas Schweikle via Python-list wrote: > > Fehler beim Buildvorgang From tschweikle at bfs.de Tue Jun 13 14:12:25 2023 From: tschweikle at bfs.de (Thomas Schweikle) Date: Tue, 13 Jun 2023 18:12:25 +0000 Subject: Compiling python on windows with vs In-Reply-To: References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Message-ID: <16c745d2-80fb-7cb7-4ef0-08a50f915012@bfs.de> Am Di., 13.Juni.2023 um 19:20:38 schrieb Jim Schwartz: > What version of visual studio are you using? Visual Studio 2022, aka 17.6.2. > What version of python? python 3.10.11 or 3.11.4 > I?ve had success with using the cython package in python and cl from visual studio, but I haven?t tried visual studio alone. Same problem at the same place: directory "../modules/..." not found, Renaming it from "Modules" to "modules" it is found, but then fails to find "Modules". Looks like it awaits, compiling in Windows an filesystem only case aware, not case sensitive -- I'm assuming this a bug now. Building within cygwin (or MSYS, Ubuntu) this works as expected. But there it does not search for "modules" once and "Modules" at an other place. >> On Jun 13, 2023, at 11:59 AM, Thomas Schweikle via Python-list wrote: >> >> Fehler beim Buildvorgang -- Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 321 bytes Desc: OpenPGP digital signature URL: From mats at wichmann.us Tue Jun 13 14:36:17 2023 From: mats at wichmann.us (Mats Wichmann) Date: Tue, 13 Jun 2023 12:36:17 -0600 Subject: Compiling python on windows with vs In-Reply-To: <16c745d2-80fb-7cb7-4ef0-08a50f915012@bfs.de> References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> <16c745d2-80fb-7cb7-4ef0-08a50f915012@bfs.de> Message-ID: <69a0e193-fd4b-1b5e-8724-d1ba672bb3a1@wichmann.us> On 6/13/23 12:12, Thomas Schweikle via Python-list wrote: > > > Am Di., 13.Juni.2023 um 19:20:38 schrieb Jim Schwartz: >> What version of visual studio are you using? > > Visual Studio 2022, aka 17.6.2. > >> What version of python? > > python 3.10.11 or 3.11.4 > >> I?ve had success with using the cython package in python and cl from >> visual studio, but I haven?t tried visual studio alone. > > Same problem at the same place: directory "../modules/..." not found, > Renaming it from "Modules" to "modules" it is found, but then fails to > find "Modules". > > Looks like it awaits, compiling in Windows an filesystem only case > aware, not case sensitive -- I'm assuming this a bug now. Building > within cygwin (or MSYS, Ubuntu) this works as expected. But there it > does not search for "modules" once and "Modules" at an other place. I just did this build the other day for the first time even from a git checkout (so VS22, and not a versioned release but top of main branch), and there was no such problem - did you follow the instructions at https://devguide.python.org/getting-started/setup-building/index.html? From jschwar at sbcglobal.net Tue Jun 13 14:42:50 2023 From: jschwar at sbcglobal.net (Jim Schwartz) Date: Tue, 13 Jun 2023 13:42:50 -0500 Subject: Compiling python on windows with vs In-Reply-To: <16c745d2-80fb-7cb7-4ef0-08a50f915012@bfs.de> References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> <16c745d2-80fb-7cb7-4ef0-08a50f915012@bfs.de> Message-ID: <013401d99e26$db8da7e0$92a8f7a0$@sbcglobal.net> One expert told me to do the following when compiling via cython and cl: cython -3 --embed -o c_file_name python_file_name Then, assuming python is installed in your apps directory and not your program files directory: set "PYTHON_DIR=%LocalAppData%\Programs\Python\Python311" or whatever directory you put python in. cl /O2 /I"%PYTHON_DIR%\Include" c_file_name /link /libpath:"%PYTHON_DIR%\libs" If that doesn't work, that's all I have. Sorry. -----Original Message----- From: Python-list On Behalf Of Thomas Schweikle via Python-list Sent: Tuesday, June 13, 2023 1:12 PM To: Python Cc: Thomas Schweikle Subject: Re: Compiling python on windows with vs Am Di., 13.Juni.2023 um 19:20:38 schrieb Jim Schwartz: > What version of visual studio are you using? Visual Studio 2022, aka 17.6.2. > What version of python? python 3.10.11 or 3.11.4 > I?ve had success with using the cython package in python and cl from visual studio, but I haven?t tried visual studio alone. Same problem at the same place: directory "../modules/..." not found, Renaming it from "Modules" to "modules" it is found, but then fails to find "Modules". Looks like it awaits, compiling in Windows an filesystem only case aware, not case sensitive -- I'm assuming this a bug now. Building within cygwin (or MSYS, Ubuntu) this works as expected. But there it does not search for "modules" once and "Modules" at an other place. >> On Jun 13, 2023, at 11:59 AM, Thomas Schweikle via Python-list wrote: >> >> Fehler beim Buildvorgang -- Thomas From eryksun at gmail.com Tue Jun 13 14:53:24 2023 From: eryksun at gmail.com (Eryk Sun) Date: Tue, 13 Jun 2023 13:53:24 -0500 Subject: Compiling python on windows with vs In-Reply-To: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Message-ID: On 6/13/23, Thomas Schweikle via Python-list wrote: > > Since Git enables Windows NTFS case sensitivity while checking out > sources ... is it a bug or a "feature"? And: is there a simple AFAIK the Windows version of Git (you're not using the Linux version of Git via WSL, right?) does not automatically enable NTFS case sensitivity. But a newly created directory does inherit the case sensitivity of its parent directory. Make sure to clone the CPython repo in a directory that has case sensitivity disabled. > _testconsole.c > C:\Users\sct-muc\Documents\Projekte\cpython\PC\_testconsole.c(13,10): > fatal error C1083: Datei (Include) kann nicht ge?ffnet werde > n: "..\modules\_io\_iomodule.h": No such file or directory > [C:\Users\sct-muc\Documents\Projekte\cpython\PCbuild\_testconsole.vcxpro > j] I just built the main branch in a case sensitive tree. I had no problem building "_testconsole.c". However, building the _decimal extension module raised a couple of serious warnings. In "PCbuild/_decimal.vcxproj", there's an include for "..\Modules\_decimal\libmpdec\vcdiv64.asm". However, MSBuild resolved this relative path with all lower-case names, i.e. "modules" instead of the correct name "Modules", and it incorrectly tried to output "vcdiv64.obj" in a subdirectory of "pcbuild" instead of the correct name "PCbuild". This appears to be a bug in MSBuild. A lot of Windows programs don't handle case-sensitive directories well, including Python's standard library. It's understandable when comparing paths, but the behavior in this case is inexcusably bad. From tschweikle at bfs.de Tue Jun 13 15:32:32 2023 From: tschweikle at bfs.de (Thomas Schweikle) Date: Tue, 13 Jun 2023 19:32:32 +0000 Subject: Compiling python on windows with vs In-Reply-To: <69a0e193-fd4b-1b5e-8724-d1ba672bb3a1@wichmann.us> References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> <16c745d2-80fb-7cb7-4ef0-08a50f915012@bfs.de> <69a0e193-fd4b-1b5e-8724-d1ba672bb3a1@wichmann.us> Message-ID: Am Di., 13.Juni.2023 um 20:36:17 schrieb Mats Wichmann via Python-list: > On 6/13/23 12:12, Thomas Schweikle via Python-list wrote: >> >> >> Am Di., 13.Juni.2023 um 19:20:38 schrieb Jim Schwartz: >>> What version of visual studio are you using? >> >> Visual Studio 2022, aka 17.6.2. >> >>> What version of python? >> >> python 3.10.11 or 3.11.4 >> >>> I?ve had success with using the cython package in python and cl from >>> visual studio, but I haven?t tried visual studio alone. >> >> Same problem at the same place: directory "../modules/..." not found, >> Renaming it from "Modules" to "modules" it is found, but then fails to >> find "Modules". >> >> Looks like it awaits, compiling in Windows an filesystem only case >> aware, not case sensitive -- I'm assuming this a bug now. Building >> within cygwin (or MSYS, Ubuntu) this works as expected. But there it >> does not search for "modules" once and "Modules" at an other place. > > I just did this build the other day for the first time even from a git > checkout (so VS22, and not a versioned release but top of main branch), > and there was no such problem - did you follow the instructions at > https://devguide.python.org/getting-started/setup-building/index.html? Yes. Had git installed (2.41.0.windows.1), did "git clone https://github.com/python/cpython.git", then checked out the branch I wanted: "git checkout 3.10.12" (or 3.11.4, 3.12.0b2). Python was already installed and in path: "python --version" gives back: "Python 3.11.4" Changed into cpython directory, then called: ".\PCbuild\build.bat" (".\pcbuild\build.bat" will, within cmd.exe, throw an error: File not found -- remember directory cpython and all beyond are case sensitive, not only case aware -- git sets case sensitiveness for checked out directories). It compiles until it does not find "modules", because the directory is named "Modules" (all posix file systems behave this way and NTFS can be forced to behave this way too. It is easy and any user can do it: "fsutil.exe file SetCaseSensitiveInfo enable" You may query this with: "fsutil.exe file queryCaseSensitiveInfo " In my case: ~/Documents/Projekte/cpython> fsutil.exe file queryCaseSensitiveInfo . Das Attribut f?r Gro?-/Kleinschreibung f?r das Verzeichnis ^ "C:\Users\user\Documents\Projekte\cpython" ist aktiviert. Or: the directory we're in is case sensitive and distinguishes between "Modules", "modules" and "MODULES" and you can have them all: C:\Users\user\Documents\Projekte\cpython>dir Datentr?ger in Laufwerk C: ist Windows Volumeseriennummer: BC5E-F466 Verzeichnis von C:\Users\user\Documents\Projekte\cpython Di, 13.Jun.2023 21:23 . Di, 13.Jun.2023 21:23 .. [...] Di, 13.Jun.2023 21:23 MODULES Mo, 12.Jun.2023 22:13 Modules Di, 13.Jun.2023 21:23 modules [...] 16 Datei(en), 1.320.340 Bytes 21 Verzeichnis(se), 134.699.622.400 Bytes frei Since case sensitivity is necessary for a variety of projects normally only used with *nix-OS I've configured git to create directories with case sensitivity set enabled (its default meanwhile if git is installed on windows). -- Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 321 bytes Desc: OpenPGP digital signature URL: From learn2program at gmail.com Tue Jun 13 17:32:25 2023 From: learn2program at gmail.com (Alan Gauld) Date: Tue, 13 Jun 2023 22:32:25 +0100 Subject: Fwd: AUTO EDITOR DIDN'T WORK In-Reply-To: References: Message-ID: Forwarding to list Okay thanks. Meanwhile, I am not tech savvy so I may not say much here. I followed all the commands as given on the website to install auto editor standing it on python but after rendering the XML file, I couldn't open it with my Davinci Resolve 18. I uninstalled and reinstalled about twice and still no success hence I uninstalled it. On Mon, 12 Jun 2023, 23:33 Alan Gauld via Python-list, > wrote: On 12/06/2023 10:26, Real Live FootBall Tv via Python-list wrote: > I did it because I was going to use it with another application, A VIDEO > EDITING APP, Auto EDITOR but it didn't work for some reasons unknown to me. You need to define "didn't work" Did it work as a python interpreter? ie. Did you get a >>> prompt in a terminal? and without involvement from your video editor? If so, what did you do to link it to the video editor? And what was the result? Or did Python not even start? How did you try to use it? What OS are you on? Did the installer run OK? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list From list1 at tompassin.net Tue Jun 13 19:06:39 2023 From: list1 at tompassin.net (Thomas Passin) Date: Tue, 13 Jun 2023 19:06:39 -0400 Subject: Fwd: AUTO EDITOR DIDN'T WORK In-Reply-To: References: Message-ID: <161f10de-a96f-54c3-ccad-cfe557f6a51c@tompassin.net> On 6/13/2023 5:32 PM, Alan Gauld via Python-list wrote: > Okay thanks. Meanwhile, I am not tech savvy so I may not say much here. > I followed all the commands as given on the website to install auto > editor standing it on python but after rendering the XML file, I > couldn't open it with my Davinci Resolve 18. I uninstalled and > reinstalled about twice and still no success hence I uninstalled it. I don't understand when you talk about an "XML file". Auto-editor works on video files, or at least .mp4 files, which are not XML files. Davinci Resolve does have some ability to interoperate with other editors using XML in some way (according to Wikipedia, https://en.wikipedia.org/wiki/DaVinci_Resolve) but that's a different thing completely. I also don't know what you mean by "after rendering the XML file" since from what I can see auto-edit doesn't render anything. The simplest thing that auto-editor can do is to cut out long periods of dead space, e.g., from an mp4 file. Their documentation shows how to do it. If it were me, I would run the example command line on a sample mp4 file, then see what it looked like in Davinci. Is that what you did? It should be the same video but with some dead space removed. (Note that I'm speaking from a place of no experience with either of these software packages; just looking at what auto-edit claims to do). From gheskett at shentel.net Tue Jun 13 21:43:28 2023 From: gheskett at shentel.net (gene heskett) Date: Tue, 13 Jun 2023 21:43:28 -0400 Subject: Fwd: AUTO EDITOR DIDN'T WORK In-Reply-To: <161f10de-a96f-54c3-ccad-cfe557f6a51c@tompassin.net> References: <161f10de-a96f-54c3-ccad-cfe557f6a51c@tompassin.net> Message-ID: <88d72509-8c47-d87e-cee3-f18c250f21f6@shentel.net> On 6/13/23 19:10, Thomas Passin via Python-list wrote: > On 6/13/2023 5:32 PM, Alan Gauld via Python-list wrote: >> Okay thanks. Meanwhile, I am not tech savvy so I may not say much here. >> I followed all the commands as given on the website to install auto >> editor standing it on python but after rendering the XML file, I >> couldn't open it with my Davinci Resolve 18. I uninstalled and >> reinstalled about twice and still no success hence I uninstalled it. > > I don't understand when you talk about an "XML file". Auto-editor works > on video files, or at least .mp4 files, which are not XML files. Davinci > Resolve does have some ability to interoperate with other editors using > XML in some way (according to Wikipedia, > https://en.wikipedia.org/wiki/DaVinci_Resolve) but that's a different > thing completely. > > I also don't know what you mean by "after rendering the XML file" since > from what I can see auto-edit doesn't render anything. > > The simplest thing that auto-editor can do is to cut out long periods of > dead space, e.g., from an mp4 file.? Their documentation shows how to do > it.? If it were me, I would run the example command line on a sample mp4 > file, then see what it looked like in Davinci.? Is that what you did? It > should be the same video but with some dead space removed. > > (Note that I'm speaking from a place of no experience with either of > these software packages; just looking at what auto-edit claims to do). > > > auto-edit? Never heard of it. xml? I've written hundred of kilobytes of it in plain old geany. I didn't know there was a special editor for xml. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page From list1 at tompassin.net Tue Jun 13 22:17:45 2023 From: list1 at tompassin.net (Thomas Passin) Date: Tue, 13 Jun 2023 22:17:45 -0400 Subject: Fwd: AUTO EDITOR DIDN'T WORK In-Reply-To: <88d72509-8c47-d87e-cee3-f18c250f21f6@shentel.net> References: <161f10de-a96f-54c3-ccad-cfe557f6a51c@tompassin.net> <88d72509-8c47-d87e-cee3-f18c250f21f6@shentel.net> Message-ID: <71651087-50a9-7222-10be-4408b8614a5e@tompassin.net> On 6/13/2023 9:43 PM, gene heskett via Python-list wrote: > On 6/13/23 19:10, Thomas Passin via Python-list wrote: >> On 6/13/2023 5:32 PM, Alan Gauld via Python-list wrote: >>> Okay thanks. Meanwhile, I am not tech savvy so I may not say much here. >>> I followed all the commands as given on the website to install auto >>> editor standing it on python but after rendering the XML file, I >>> couldn't open it with my Davinci Resolve 18. I uninstalled and >>> reinstalled about twice and still no success hence I uninstalled it. >> >> I don't understand when you talk about an "XML file". Auto-editor >> works on video files, or at least .mp4 files, which are not XML files. >> Davinci Resolve does have some ability to interoperate with other >> editors using XML in some way (according to Wikipedia, >> https://en.wikipedia.org/wiki/DaVinci_Resolve) but that's a different >> thing completely. >> >> I also don't know what you mean by "after rendering the XML file" >> since from what I can see auto-edit doesn't render anything. >> >> The simplest thing that auto-editor can do is to cut out long periods >> of dead space, e.g., from an mp4 file.? Their documentation shows how >> to do it.? If it were me, I would run the example command line on a >> sample mp4 file, then see what it looked like in Davinci.? Is that >> what you did? It should be the same video but with some dead space >> removed. >> >> (Note that I'm speaking from a place of no experience with either of >> these software packages; just looking at what auto-edit claims to do). >> >> >> > auto-edit? Never heard of it. xml? I've written hundred of kilobytes of > it in plain old geany. I didn't know there was a special editor for xml. Oh, there are, there are - mostly intended for document authoring, I think. From avi.e.gross at gmail.com Tue Jun 13 23:49:14 2023 From: avi.e.gross at gmail.com (avi.e.gross at gmail.com) Date: Tue, 13 Jun 2023 23:49:14 -0400 Subject: Fwd: AUTO EDITOR DIDN'T WORK In-Reply-To: <71651087-50a9-7222-10be-4408b8614a5e@tompassin.net> References: <161f10de-a96f-54c3-ccad-cfe557f6a51c@tompassin.net> <88d72509-8c47-d87e-cee3-f18c250f21f6@shentel.net> <71651087-50a9-7222-10be-4408b8614a5e@tompassin.net> Message-ID: <018201d99e73$301c29c0$90547d40$@gmail.com> I think it is time to ask this topic to go find some other place to talk to itself. I have seen NO reason to think any question about problems with Python has been asked. Not properly. It sounds like someone messed up an installation, perhaps of other programs like an editor and some unspecified thing does not work. I suggest they start over and be careful so that if some specific version of Python is needed, it gets installed in the right place and so on. We here cannot be expected to have much idea about programs that perhaps we do not use. Python can be used to build an editor, or parts it runs when needed, and it can be used to create or consume XML, or do things with audio formats. So can many other languages. If it was needed here and the setup was wrong or sabotaged, that is not something easily handled here. Or did I miss something? If so, I know others here also missed it too. If there is a more specific problem like some lines of actual python code not doing what was expected, please share that specifically with enough detail. -----Original Message----- From: Python-list On Behalf Of Thomas Passin via Python-list Sent: Tuesday, June 13, 2023 10:18 PM To: python-list at python.org Subject: Re: Fwd: AUTO EDITOR DIDN'T WORK On 6/13/2023 9:43 PM, gene heskett via Python-list wrote: > On 6/13/23 19:10, Thomas Passin via Python-list wrote: >> On 6/13/2023 5:32 PM, Alan Gauld via Python-list wrote: >>> Okay thanks. Meanwhile, I am not tech savvy so I may not say much here. >>> I followed all the commands as given on the website to install auto >>> editor standing it on python but after rendering the XML file, I >>> couldn't open it with my Davinci Resolve 18. I uninstalled and >>> reinstalled about twice and still no success hence I uninstalled it. >> >> I don't understand when you talk about an "XML file". Auto-editor >> works on video files, or at least .mp4 files, which are not XML files. >> Davinci Resolve does have some ability to interoperate with other >> editors using XML in some way (according to Wikipedia, >> https://en.wikipedia.org/wiki/DaVinci_Resolve) but that's a different >> thing completely. >> >> I also don't know what you mean by "after rendering the XML file" >> since from what I can see auto-edit doesn't render anything. >> >> The simplest thing that auto-editor can do is to cut out long periods >> of dead space, e.g., from an mp4 file. Their documentation shows how >> to do it. If it were me, I would run the example command line on a >> sample mp4 file, then see what it looked like in Davinci. Is that >> what you did? It should be the same video but with some dead space >> removed. >> >> (Note that I'm speaking from a place of no experience with either of >> these software packages; just looking at what auto-edit claims to do). >> >> >> > auto-edit? Never heard of it. xml? I've written hundred of kilobytes of > it in plain old geany. I didn't know there was a special editor for xml. Oh, there are, there are - mostly intended for document authoring, I think. -- https://mail.python.org/mailman/listinfo/python-list From songofacandy at gmail.com Wed Jun 14 01:33:04 2023 From: songofacandy at gmail.com (Inada Naoki) Date: Wed, 14 Jun 2023 14:33:04 +0900 Subject: Compiling python on windows with vs In-Reply-To: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Message-ID: > Since Git enables Windows NTFS case sensitivity while checking out sources I didn't know that. Would you give us a link to this feature? As far as I know, `git config core.ignorecase` doesn't mean NTFS case sensitive. On Wed, Jun 14, 2023 at 1:57?AM Thomas Schweikle via Python-list < python-list at python.org> wrote: > Hi! > > Trying to compile python on windows leads to following error: > > _testimportmultiple.vcxproj -> > > C:\Users\sct-muc\Documents\Projekte\cpython\PCbuild\amd64\_testimportmultiple.pyd > _testmultiphase.c > Bibliothek > "C:\Users\sct-muc\Documents\Projekte\cpython\PCbuild\amd64\_testmultiphase.lib" > > und Objekt "C:\Users\sct-muc\Docume > nts\Projekte\cpython\PCbuild\amd64\_testmultiphase.exp" werden erstellt. > Code wird generiert. > Codegenerierung ist abgeschlossen. > _testmultiphase.vcxproj -> > > C:\Users\sct-muc\Documents\Projekte\cpython\PCbuild\amd64\_testmultiphase.pyd > _testconsole.c > C:\Users\sct-muc\Documents\Projekte\cpython\PC\_testconsole.c(13,10): > fatal error C1083: Datei (Include) kann nicht ge?ffnet werde > n: "..\modules\_io\_iomodule.h": No such file or directory > [C:\Users\sct-muc\Documents\Projekte\cpython\PCbuild\_testconsole.vcxpro > j] > > Fehler beim Buildvorgang. > > if I rename "Modules" to "modules" it will find > "..\modules\_io\_iomodule.h" but wont find "..\Modules\..." > > Since Git enables Windows NTFS case sensitivity while checking out > sources ... is it a bug or a "feature"? And: is there a simple > workaround available besides disabling case sensitivity (which will > break others)? > -- > Thomas > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Inada Naoki From eryksun at gmail.com Wed Jun 14 09:10:50 2023 From: eryksun at gmail.com (Eryk Sun) Date: Wed, 14 Jun 2023 08:10:50 -0500 Subject: Compiling python on windows with vs In-Reply-To: References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Message-ID: On 6/14/23, Inada Naoki via Python-list wrote: >> Since Git enables Windows NTFS case sensitivity while checking out sources > > I didn't know that. Would you give us a link to this feature? > As far as I know, `git config core.ignorecase` doesn't mean NTFS case > sensitive. If a repo is cloned into a case-insensitive directory, then core.ignorecase should be enabled automatically. If a repo is cloned into a case-sensitive directory, then core.ignorecase should not be enabled automatically. I searched through relevant issues on the Git for Windows repo on GitHub, and I found nothing to indicate that a capability to automatically enable NTFS case sensitivity has been added. I searched through the source of Git and Git for Windows, and I didn't find any references to WinAPI SetFileInformationByHandle: FileCaseSensitiveInfo or NTAPI NtSetInformationFile: FileCaseSensitiveInformation, nor the use of fsutil file setCaseSensitiveInfo. From sakasaraajnr at gmail.com Thu Jun 15 03:58:57 2023 From: sakasaraajnr at gmail.com (Real Live FootBall Tv) Date: Thu, 15 Jun 2023 08:58:57 +0100 Subject: Fwd: AUTO EDITOR DIDN'T WORK In-Reply-To: <018201d99e73$301c29c0$90547d40$@gmail.com> References: <161f10de-a96f-54c3-ccad-cfe557f6a51c@tompassin.net> <88d72509-8c47-d87e-cee3-f18c250f21f6@shentel.net> <71651087-50a9-7222-10be-4408b8614a5e@tompassin.net> <018201d99e73$301c29c0$90547d40$@gmail.com> Message-ID: I have followed the instructions given on how to install the app. What I needed was an application to cut of silence from my video and I saw auto editor demonstrated as one of the applications that could do that. It does cut the silent areas of an MP4 format video for instance but would save it as a XML file which in turn would be exported to the video editor that supports the output from the auto editor app. The one who demonstrated it in a video used Davinci Resolve to import the XML file, I followed same process but I couldn't get same result. Thanks for all your contributions. On Wed, 14 Jun 2023, 04:52 AVI GROSS via Python-list, < python-list at python.org> wrote: > > I think it is time to ask this topic to go find some other place to talk > to itself. > > I have seen NO reason to think any question about problems with Python has > been asked. Not properly. > > It sounds like someone messed up an installation, perhaps of other > programs like an editor and some unspecified thing does not work. I suggest > they start over and be careful so that if some specific version of Python > is needed, it gets installed in the right place and so on. We here cannot > be expected to have much idea about programs that perhaps we do not use. > > Python can be used to build an editor, or parts it runs when needed, and > it can be used to create or consume XML, or do things with audio formats. > So can many other languages. If it was needed here and the setup was wrong > or sabotaged, that is not something easily handled here. > > Or did I miss something? If so, I know others here also missed it too. > > If there is a more specific problem like some lines of actual python code > not doing what was expected, please share that specifically with enough > detail. > > > -----Original Message----- > From: Python-list > On Behalf Of Thomas Passin via Python-list > Sent: Tuesday, June 13, 2023 10:18 PM > To: python-list at python.org > Subject: Re: Fwd: AUTO EDITOR DIDN'T WORK > > On 6/13/2023 9:43 PM, gene heskett via Python-list wrote: > > On 6/13/23 19:10, Thomas Passin via Python-list wrote: > >> On 6/13/2023 5:32 PM, Alan Gauld via Python-list wrote: > >>> Okay thanks. Meanwhile, I am not tech savvy so I may not say much here. > >>> I followed all the commands as given on the website to install auto > >>> editor standing it on python but after rendering the XML file, I > >>> couldn't open it with my Davinci Resolve 18. I uninstalled and > >>> reinstalled about twice and still no success hence I uninstalled it. > >> > >> I don't understand when you talk about an "XML file". Auto-editor > >> works on video files, or at least .mp4 files, which are not XML files. > >> Davinci Resolve does have some ability to interoperate with other > >> editors using XML in some way (according to Wikipedia, > >> https://en.wikipedia.org/wiki/DaVinci_Resolve) but that's a different > >> thing completely. > >> > >> I also don't know what you mean by "after rendering the XML file" > >> since from what I can see auto-edit doesn't render anything. > >> > >> The simplest thing that auto-editor can do is to cut out long periods > >> of dead space, e.g., from an mp4 file. Their documentation shows how > >> to do it. If it were me, I would run the example command line on a > >> sample mp4 file, then see what it looked like in Davinci. Is that > >> what you did? It should be the same video but with some dead space > >> removed. > >> > >> (Note that I'm speaking from a place of no experience with either of > >> these software packages; just looking at what auto-edit claims to do). > >> > >> > >> > > auto-edit? Never heard of it. xml? I've written hundred of kilobytes of > > it in plain old geany. I didn't know there was a special editor for xml. > > Oh, there are, there are - mostly intended for document authoring, I think. > > -- > https://mail.python.org/mailman/listinfo/python-list > > -- > https://mail.python.org/mailman/listinfo/python-list > From learn2program at gmail.com Thu Jun 15 05:25:24 2023 From: learn2program at gmail.com (Alan Gauld) Date: Thu, 15 Jun 2023 10:25:24 +0100 Subject: Fwd: AUTO EDITOR DIDN'T WORK In-Reply-To: References: <161f10de-a96f-54c3-ccad-cfe557f6a51c@tompassin.net> <88d72509-8c47-d87e-cee3-f18c250f21f6@shentel.net> <71651087-50a9-7222-10be-4408b8614a5e@tompassin.net> <018201d99e73$301c29c0$90547d40$@gmail.com> Message-ID: <300d7c2e-81ff-2e0d-2979-e4a237e8de1d@yahoo.co.uk> On 15/06/2023 08:58, Real Live FootBall Tv via Python-list wrote: > I have followed the instructions given on how to install the app. What I > needed was an application to cut of silence from my video and I saw auto > editor demonstrated as one of the applications that could do that. It does > cut the silent areas of an MP4 format video for instance but would save it > as a XML file which in turn would be exported to the video editor that > supports the output from the auto editor app. The one who demonstrated it > in a video used Davinci Resolve to import the XML file, I followed same > process but I couldn't get same result. It looks like you have three parts to this puzzle: - auto-editor - resolve - Python It's not clear which part isn't working but you can at least test Python is working after you install it by running the interpreter in a console/terminal window by typing python at the command prompt. If you get the Python prompt: >>> Then Python is installed OK. After that it's back into auto-editor and resolve and this is not the best place to get answers for those. Resolve at least has an active support forum, so I'd start there(assuming python works!) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos From tschweikle at bfs.de Thu Jun 15 08:05:35 2023 From: tschweikle at bfs.de (Thomas Schweikle) Date: Thu, 15 Jun 2023 12:05:35 +0000 Subject: Compiling python on windows with vs In-Reply-To: References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Message-ID: Am Mi., 14.Juni.2023 um 15:10:50 schrieb Eryk Sun: > On 6/14/23, Inada Naoki via Python-list wrote: >>> Since Git enables Windows NTFS case sensitivity while checking out sources >> >> I didn't know that. Would you give us a link to this feature? >> As far as I know, `git config core.ignorecase` doesn't mean NTFS case >> sensitive. > > If a repo is cloned into a case-insensitive directory, then > core.ignorecase should be enabled automatically. If a repo is cloned > into a case-sensitive directory, then core.ignorecase should not be > enabled automatically. > > I searched through relevant issues on the Git for Windows repo on > GitHub, and I found nothing to indicate that a capability to > automatically enable NTFS case sensitivity has been added. I searched > through the source of Git and Git for Windows, and I didn't find any > references to WinAPI SetFileInformationByHandle: FileCaseSensitiveInfo > or NTAPI NtSetInformationFile: FileCaseSensitiveInformation, nor the > use of fsutil file setCaseSensitiveInfo. In this case: not sure what is going on. In a git-shell on Windows: If caseSensitiveInfo is disabled: user at host MINGW64 ~/K $ fsutil file queryCaseSensitiveInfo . Das Attribut f?r Gro?-/Kleinschreibung f?r das Verzeichnis "C:\Users\user\K" ist deaktiviert. $ git config --global -l core.ignorecase=true $ git clone https://github.com/python/cpython.git Cloning into 'cpython'... remote: Enumerating objects: 956870, done. remote: Counting objects: 100% (1304/1304), done. remote: Compressing objects: 100% (801/801), done. Receiving objects: 100% (956870/956870), 557.02 MiB | 9.75 MiB/s, done.55566 Resolving deltas: 100% (760802/760802), done. Updating files: 100% (4488/4488), done. $ find . -type d -exec fsutil.exe file queryCaseSensitiveInfo {} \; does not show any directory having caseSensitiveInfo enabled. If caseSesitiveInfo is enabled: user at host MINGW64 ~/K $ fsutil file queryCaseSensitiveInfo . Das Attribut f?r Gro?-/Kleinschreibung f?r das Verzeichnis "C:\Users\user\K" ist aktiviert. $ git config --global -l core.ignorecase=true $ git clone https://github.com/python/cpython.git Cloning into 'cpython'... remote: Enumerating objects: 956870, done. remote: Counting objects: 100% (1304/1304), done. remote: Compressing objects: 100% (801/801), done. Receiving objects: 100% (956870/956870), 557.02 MiB | 9.75 MiB/s, done.55566 Resolving deltas: 100% (760802/760802), done. Updating files: 100% (4488/4488), done. $ find . -type d -exec fsutil.exe file queryCaseSensitiveInfo {} \; All directories created by git have caseSensitiveInfo enabled. core.ignorecase is not regarded in any way. It does not mater if it is set or not. -- Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 321 bytes Desc: OpenPGP digital signature URL: From songofacandy at gmail.com Thu Jun 15 09:44:42 2023 From: songofacandy at gmail.com (Inada Naoki) Date: Thu, 15 Jun 2023 22:44:42 +0900 Subject: Compiling python on windows with vs In-Reply-To: References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Message-ID: Then, git doesn't enable Windows NTFS case sensitivity. You enabled NTFS case sensitivity on "C:\Users\user\K". And Windows enabled case sensitivity for all new directories under the directory. Since it is not default and minor setting, it is not a bug that current Python doesn't support building on case sensitive directory. But I think it is a nice improvement if next Python supports it. Regards, -- Inada Naoki From eryksun at gmail.com Thu Jun 15 10:28:21 2023 From: eryksun at gmail.com (Eryk Sun) Date: Thu, 15 Jun 2023 09:28:21 -0500 Subject: Compiling python on windows with vs In-Reply-To: References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Message-ID: On 6/15/23, Thomas Schweikle via Python-list wrote: > > In this case: not sure what is going on. Possibly you have a setting configured that affects the behavior of Git via the MinGW-w64 runtime, such that calling mkdir() ends up calling NtSetInformationFile() to set the FileCaseSensitiveInformation for the directory. Does the mkdir command in Git bash create a case-sensitive directory? It doesn't for me. I have to manually enable case sensitivity via `chattr +C`. What do you get for `which git` and `git --version`? $ which git /mingw64/bin/git $ git --version git version 2.41.0.windows.1 > $ fsutil file queryCaseSensitiveInfo . The MSYS2 environment includes lsattr and chattr commands, with the case-sensitive flag mapped to "C". It's probably more convenient than typing `fsutil file queryCaseSensitiveInfo` or `fsutil file setCaseSensitiveInfo`. $ lsattr -d test ------------ test $ chattr +C test $ lsattr -d test -----------C test > core.ignorecase is not regarded in any way. It does not mater if it is > set or not. Git tests the case-sensitivity of the target directory to configure core.ignorecase when cloning a repo. If it's case insensitive, then core.ignorecase is enabled. This overrides the global value. AFAIK, the ignorecase setting is unrelated to actually setting the case sensitivity of created directories; it just affects how Git behaves on a case-insensitive filesystem. From tschweikle at bfs.de Thu Jun 15 11:32:22 2023 From: tschweikle at bfs.de (Thomas Schweikle) Date: Thu, 15 Jun 2023 15:32:22 +0000 Subject: Compiling python on windows with vs In-Reply-To: References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Message-ID: Am Do., 15.Juni.2023 um 15:44:42 schrieb Inada Naoki: > Then, git doesn't enable Windows NTFS case sensitivity. > > You enabled NTFS case sensitivity on "C:\Users\user\K". > And Windows enabled case sensitivity for all new directories under the > directory. No. This flag is not inherited. Someone has to set it for created directories. It is easy to confirm: take a directory not under MSYS or cygwin control (because it is mounted by MSYS or cygwin), set the flag, then create directories. They all will have caseSensitivInfo disabled. > Since it is not default and minor setting, it is not a bug that > current Python doesn't support building on case sensitive directory. > But I think it is a nice improvement if next Python supports it. Python itself isn't the problem here. It is MSBuild.exe. For some reason this tool lowercases sometimes whole paths to files included. This does not matter if case sensitivity is disabled. It matters if case sensitivity is enabled! There is no reason MSBUild.exe does it. But it is done for some paths (as someone else pointed out). > > Regards, > > -- > Inada Naoki -- Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 321 bytes Desc: OpenPGP digital signature URL: From tschweikle at bfs.de Thu Jun 15 11:55:28 2023 From: tschweikle at bfs.de (Thomas Schweikle) Date: Thu, 15 Jun 2023 15:55:28 +0000 Subject: Compiling python on windows with vs In-Reply-To: References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Message-ID: <00f773ff-3ae5-522c-42af-d2b90e2b2606@bfs.de> Am Do., 15.Juni.2023 um 16:28:21 schrieb Eryk Sun: > On 6/15/23, Thomas Schweikle via Python-list wrote: >> >> In this case: not sure what is going on. > > Possibly you have a setting configured that affects the behavior of > Git via the MinGW-w64 runtime, such that calling mkdir() ends up > calling NtSetInformationFile() to set the FileCaseSensitiveInformation > for the directory. It is a mount option for MSYS or cygwin controlled parts of the file system. posix=1 switches case sensitivity on, posix=0 switches it off. MSYS or cygwin are then make caseSensitiveInfo "inheritated" by setting this flag for all newly created directories. This is a feature of the latest cygwin-dll. It might not be seen on older variants. > Does the mkdir command in Git bash create a case-sensitive directory? > It doesn't for me. I have to manually enable case sensitivity via > `chattr +C`. > > What do you get for `which git` and `git --version`? > > $ which git > /mingw64/bin/git > > $ git --version > git version 2.41.0.windows.1 the same: $ which git /mingw64/bin/git $ git --version git version 2.41.0.windows.1 And in cmd.exe: +>where git C:\Program Files\Git\bin\git.exe +>git --version git version 2.41.0.windows.1 >> $ fsutil file queryCaseSensitiveInfo . > > The MSYS2 environment includes lsattr and chattr commands, with the > case-sensitive flag mapped to "C". It's probably more convenient than > typing `fsutil file queryCaseSensitiveInfo` or `fsutil file > setCaseSensitiveInfo`. > > $ lsattr -d test > ------------ test > $ chattr +C test > $ lsattr -d test > -----------C test True. But if you frequently change between environments fsutil is the command working in cmd.exe as in git-shell. >> core.ignorecase is not regarded in any way. It does not mater if it is >> set or not. > > Git tests the case-sensitivity of the target directory to configure > core.ignorecase when cloning a repo. If it's case insensitive, then > core.ignorecase is enabled. This overrides the global value. AFAIK, > the ignorecase setting is unrelated to actually setting the case > sensitivity of created directories; it just affects how Git behaves on > a case-insensitive filesystem. -- Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature Type: application/pgp-signature Size: 321 bytes Desc: OpenPGP digital signature URL: From eryksun at gmail.com Thu Jun 15 12:35:46 2023 From: eryksun at gmail.com (Eryk Sun) Date: Thu, 15 Jun 2023 11:35:46 -0500 Subject: Compiling python on windows with vs In-Reply-To: References: <6047921e-7201-c9fd-3917-555c23b41cf7@bfs.de> Message-ID: On 6/15/23, Thomas Schweikle via Python-list wrote: > > No. This flag is not inherited. Someone has to set it for created > directories. It is easy to confirm: take a directory not under MSYS or > cygwin control (because it is mounted by MSYS or cygwin), set the flag, > then create directories. They all will have caseSensitivInfo disabled. That was how the attribute was implemented initially in Windows 10, but subsequently it was made inheritable. For example: C:\Temp\test>mkdir spam C:\Temp\test>fsutil file setCaseSensitiveInfo spam enable Error: Access is denied. Setting the case-sensitive attribute requires the right to add files and directories (i.e. "WD" = "write data" / "add file"; "AD" = "append data" / "add subdirectory") and the right to remove files and directories (i.e. "DC" = "delete child"). The owner of a directory doesn't necessarily inherit these rights from the parent directory (which is my case here), but the owner of any object usually has the implicit right to modify discretionary security. Let's simply grant the owner (i.e. "OW" = "owner rights") full control of the directory (i.e. "F"), inheritable to child directories (i.e. "CI" = "container inherit"). C:\Temp\test>icacls spam /grant *OW:(CI)(F) processed file: spam Successfully processed 1 files; Failed processing 0 files C:\Temp\test>fsutil file setCaseSensitiveInfo spam enable Case sensitive attribute on directory C:\Temp\test\spam is enabled. Now, create a child directory and confirm that it inherits the case-sensitive flag. C:\Temp\test>mkdir spam\eggs C:\Temp\test>fsutil file queryCaseSensitiveInfo spam\eggs Case sensitive attribute on directory C:\Temp\test\spam\eggs is enabled. > Python itself isn't the problem here. It is MSBuild.exe. For some reason > this tool lowercases sometimes whole paths to files included. This does > not matter if case sensitivity is disabled. It matters if case > sensitivity is enabled! There is no reason MSBUild.exe does it. But it > is done for some paths (as someone else pointed out). For the specific problem you had when building 3.10 and 3.11, it's actually a bug in Python's source code, which is no longer present in 3.12+. It can be fixed in 3.11, but 3.10 no longer gets bug fixes. Here's the link to the issue on GitHub: https://github.com/python/cpython/issues/105737 I encountered a different bug when building the main branch. Building the _decimal extension module includes an .asm file. The relative path in the project file has the correct case, but the build system resolved the fully-qualified path as all lower case. This problem only occurred for this single file, out of hundreds of relative paths in the project files, so it's not like the build system is completely broken when working in case-sensitive directories. There are probably a few such bugs that need to be fixed in msbuild, the compiler, and linker. After all, these tools have been developed and tested for decades on only case-insensitive filesystems. But you don't have to be on the bleeding edge. There's no reason to make directories case-sensitive for repositories that are intended for use on Windows, such as CPython. From PythonList at DancesWithMice.info Fri Jun 16 01:40:10 2023 From: PythonList at DancesWithMice.info (dn) Date: Fri, 16 Jun 2023 17:40:10 +1200 Subject: Enum + new in 3.11 Message-ID: <3aaa63cd-2108-46d0-7fa5-295843703b1a@DancesWithMice.info> Have you figured-out a use for the @enum.member and @enum.nonmember decorators (new in Python 3.11)? "What's New" says: Added the member() and nonmember() decorators, to ensure the decorated object is/is not converted to an enum member. The PSL docs say: @enum.member A decorator for use in enums: its target will become a member. also: enum members have names and values (the name of Color.RED is RED, the value of Color.BLUE is 3, etc.) Whereas the "Utilities and Decorators" section is slightly confusing because class decorators are mixed with others, so one has to read more-carefully. "Curiosity killed the cat" and other cautionary tales/tails... Have added the following decorated staticmethod to a basic enum. It is indeed recognised as a member of the enum, but its value is the method-object. To gain the value the method-object represents (property-like behavior) one has to call the method/enum-value as a function:- from enum import Enum, member class MenuOptions( Enum ): """ Legal menu-choices. """ N = "NewGame" L = "LoadGame" # ... @member @staticmethod def extra_member()->str: return "QuitGame" def print_demo( enum_chosen:MenuOptions )->None: """ Illustrative printing. """ print( "Name:", enum_chosen, enum_chosen.name ) if isinstance( enum_chosen, MenuOptions ): print( "Value:", enum_chosen.value ) print( MenuOptions.__members__ ) # {'N': , 'L': , 'extra_member': )>>} print_demo( MenuOptions[ "L" ] ) # Name: MenuOptions.L L # Value: LoadGame print_demo( MenuOptions.extra_member ) # Name: MenuOptions.extra_member extra_member # Value: )> print( MenuOptions.extra_member.value() ) # QuitGame Therefore, like an @property decorator applied to a method in a custom-class, it could be used to only evaluate some 'expensive' computation if/when it is needed. Similarly, it could use the other values within the enum in order to present some 'combination'. Weirdly (given that enums are considered immutable) I imagine that if the 'extra_member' were to call some external function with varying output, the value could be considered mutable when it is eventually called. Other?better ideas... -- Regards, =dn From list1 at tompassin.net Fri Jun 16 07:47:42 2023 From: list1 at tompassin.net (Thomas Passin) Date: Fri, 16 Jun 2023 07:47:42 -0400 Subject: Enum + new in 3.11 In-Reply-To: <3aaa63cd-2108-46d0-7fa5-295843703b1a@DancesWithMice.info> References: <3aaa63cd-2108-46d0-7fa5-295843703b1a@DancesWithMice.info> Message-ID: <4d5f1ee0-4270-a232-1007-013dee43f794@tompassin.net> On 6/16/2023 1:40 AM, dn via Python-list wrote: > Have you figured-out a use for the @enum.member and @enum.nonmember > decorators (new in Python 3.11)? > > > "What's New" says: > Added the member() and nonmember() decorators, to ensure the decorated > object is/is not converted to an enum member. > > The PSL docs say: > @enum.member > ??? A decorator for use in enums: its target will become a member. > > also: > enum members have names and values (the name of Color.RED is RED, the > value of Color.BLUE is 3, etc.) > > Whereas the "Utilities and Decorators" section is slightly confusing > because class decorators are mixed with others, so one has to read > more-carefully. > > > "Curiosity killed the cat" and other cautionary tales/tails... > > Have added the following decorated staticmethod to a basic enum. It is > indeed recognised as a member of the enum, but its value is the > method-object. To gain the value the method-object represents > (property-like behavior) one has to call the method/enum-value as a > function:- > > > from enum import Enum, member > > > class MenuOptions( Enum ): > ??? """ Legal menu-choices. """ > ??? N = "NewGame" > ??? L = "LoadGame" > ??? # ... > > ??? @member > ??? @staticmethod > ??? def extra_member()->str: > ??????? return "QuitGame" > > > def print_demo( enum_chosen:MenuOptions )->None: > ??? """ Illustrative printing. """ > ??? print( "Name:", enum_chosen, enum_chosen.name ) > ??? if isinstance( enum_chosen, MenuOptions ): > ??????? print( "Value:", enum_chosen.value ) > > > print( MenuOptions.__members__ ) > # {'N': , 'L': , > 'extra_member': MenuOptions.extra_member at 0x7f0802128860>)>>} > > print_demo( MenuOptions[ "L" ] ) > # Name: MenuOptions.L L > # Value: LoadGame > > print_demo( MenuOptions.extra_member ) > # Name: MenuOptions.extra_member extra_member > # Value: 0x7f0802128860>)> > > print( MenuOptions.extra_member.value() ) > # QuitGame > > > Therefore, like an @property decorator applied to a method in a > custom-class, it could be used to only evaluate some 'expensive' > computation if/when it is needed. Similarly, it could use the other > values within the enum in order to present some 'combination'. > > Weirdly (given that enums are considered immutable) I imagine that if > the 'extra_member' were to call some external function with varying > output, the value could be considered mutable when it is eventually called. > > Other?better ideas... mypy is having trouble with 3.11 enums: "There are 83 open Enum mypy issues at the the time of this writing. Getting the Enum datatype to work with mypy is becoming impossible as I find myself having to use cast() in at least every other line." (see https://github.com/python/mypy/issues/12841) There have also been other changes to enum in 3.11 - here is a useful rundown: https://www.andy-pearce.com/blog/posts/2023/Jan/whats-new-in-python-311-new-and-improved-modules/#enum I had no idea.... From sakasaraajnr at gmail.com Fri Jun 16 15:30:00 2023 From: sakasaraajnr at gmail.com (Real Live FootBall Tv) Date: Fri, 16 Jun 2023 20:30:00 +0100 Subject: Fwd: AUTO EDITOR DIDN'T WORK In-Reply-To: <300d7c2e-81ff-2e0d-2979-e4a237e8de1d@yahoo.co.uk> References: <161f10de-a96f-54c3-ccad-cfe557f6a51c@tompassin.net> <88d72509-8c47-d87e-cee3-f18c250f21f6@shentel.net> <71651087-50a9-7222-10be-4408b8614a5e@tompassin.net> <018201d99e73$301c29c0$90547d40$@gmail.com> <300d7c2e-81ff-2e0d-2979-e4a237e8de1d@yahoo.co.uk> Message-ID: Thanks, I'll look into it. On Thu, 15 Jun 2023 at 10:25, Alan Gauld wrote: > On 15/06/2023 08:58, Real Live FootBall Tv via Python-list wrote: > > I have followed the instructions given on how to install the app. What I > > needed was an application to cut of silence from my video and I saw auto > > editor demonstrated as one of the applications that could do that. It > does > > cut the silent areas of an MP4 format video for instance but would save > it > > as a XML file which in turn would be exported to the video editor that > > supports the output from the auto editor app. The one who demonstrated it > > in a video used Davinci Resolve to import the XML file, I followed same > > process but I couldn't get same result. > > It looks like you have three parts to this puzzle: > - auto-editor > - resolve > - Python > > It's not clear which part isn't working but you can at > least test Python is working after you install it > by running the interpreter in a console/terminal > window by typing python at the command prompt. > > If you get the Python prompt: > > >>> > > Then Python is installed OK. > > After that it's back into auto-editor and resolve and this is > not the best place to get answers for those. Resolve at least > has an active support forum, so I'd start there(assuming > python works!) > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > From PythonList at DancesWithMice.info Fri Jun 16 19:37:35 2023 From: PythonList at DancesWithMice.info (dn) Date: Sat, 17 Jun 2023 11:37:35 +1200 Subject: Enum + new in 3.11 In-Reply-To: <4d5f1ee0-4270-a232-1007-013dee43f794@tompassin.net> References: <3aaa63cd-2108-46d0-7fa5-295843703b1a@DancesWithMice.info> <4d5f1ee0-4270-a232-1007-013dee43f794@tompassin.net> Message-ID: <561e7ff9-c484-efc8-0bfc-577dc457cdb9@DancesWithMice.info> On 16/06/2023 23.47, Thomas Passin via Python-list wrote: > On 6/16/2023 1:40 AM, dn via Python-list wrote: >> Have you figured-out a use for the @enum.member and @enum.nonmember >> decorators (new in Python 3.11)? >> >> > mypy is having trouble with 3.11 enums: > > "There are 83 open Enum mypy issues at the the time of this writing. > > Getting the Enum datatype to work with mypy is becoming impossible as I > find myself having to use cast() in at least every other line." > > (see https://gi thub.com/python/mypy/issues/12841) > > There have also been other changes to enum? in 3.11 - here is a useful > rundown: > > https://www.andy-pearce.com/blog/posts/2023/Jan/whats-new-in-python-311-new-and-improved-modules/#enum > > I had no idea.... Sorry to hear about mypy. PyCharm has its own mechanism - if there's something like mypy underneath, I don't know [which]. TBH I haven't noticed any such difficulties, BUT haven't tried using more than a defined sub-class of Enum - and using such as a class. Thus: class MenuOptions( Enum ): """ Legal menu-choices. """ N = "NewGame" L = "LoadGame" .... if __name__ == "__main__": n:MenuOptions = MenuOptions.N print( n, type( n ) ) # MenuOptions.N works correctly, but strikes me as pedantry. (any (mypy) problematic code you'd like me to try (in PyCharm) as a comparison? Perhaps off-list - could summarise any pertinent discoveries later...) I tried messing with the enum-members, eg N:str; but realised that although this worked/was passed silently, the name of a member is not actually a string anyway. So, backed that out. Had noted the first web.ref but deemed it unimportant (to me - as above). The second I had not found, and enjoyed reading (many thanks!). ?I?ll be honest, I struggled to think of concrete cases where this would be useful, since I don?t tend to pile additional functionality into my enumerations ? they?re almost always just bare classes which are members of another class or module which provides the related functionality. But I think it?s good to broaden your horizons...? The last being the same view as led me to this point, and the first, the motivation for this post! As said, I tend to only use enums in a fairly mechanistic fashion. However, I have been playing-around with his "additional functionality". For example, adding the idea of a default-value if an enquiry attempts to use a 'key' which is not present (which seems 'natural', but equally goes against (my understanding of) the ethos of an enum). Next, (see earlier comment about having to invoke the @member-target as a function) was the idea that if one is using an enum as a collection of the correct choices/responses in a menu (per code snippet), making the member.value into a function* attempts to reproduce the idiom of using a dict[ionary] to simulate a case/select construct - which combines the idea of an API's constants with making a decision as to which functionality should be invoked. * function here (cf "method") because unlikely to locate such functionality within the enum. However, am also experimenting with classes (cue OOP-mumblings, eg "polymorphism", "inversion", ...) All the fun of the fair! BTW when I reach the point of making comparisons, I expect the enum will be 'cheaper' in storage; but that the dict-construct will be 'faster' - pure speculation(!) Repeating: curious cats, etc... -- Regards, =dn From list1 at tompassin.net Fri Jun 16 21:53:19 2023 From: list1 at tompassin.net (Thomas Passin) Date: Fri, 16 Jun 2023 21:53:19 -0400 Subject: Enum + new in 3.11 In-Reply-To: <561e7ff9-c484-efc8-0bfc-577dc457cdb9@DancesWithMice.info> References: <3aaa63cd-2108-46d0-7fa5-295843703b1a@DancesWithMice.info> <4d5f1ee0-4270-a232-1007-013dee43f794@tompassin.net> <561e7ff9-c484-efc8-0bfc-577dc457cdb9@DancesWithMice.info> Message-ID: <69f318fa-a241-5f1c-baad-0d210ae0425e@tompassin.net> On 6/16/2023 7:37 PM, dn via Python-list wrote: > On 16/06/2023 23.47, Thomas Passin via Python-list wrote: >> On 6/16/2023 1:40 AM, dn via Python-list wrote: >>> Have you figured-out a use for the @enum.member and @enum.nonmember >>> decorators (new in Python 3.11)? >>> >>> >> mypy is having trouble with 3.11 enums: >> >> "There are 83 open Enum mypy issues at the the time of this writing. >> >> Getting the Enum datatype to work with mypy is becoming impossible as >> I find myself having to use cast() in at least every other line." >> >> (see https://gi > > thub.com/python/mypy/issues/12841) >> >> There have also been other changes to enum? in 3.11 - here is a useful >> rundown: >> >> https://www.andy-pearce.com/blog/posts/2023/Jan/whats-new-in-python-311-new-and-improved-modules/#enum >> >> I had no idea.... > > > Sorry to hear about mypy. PyCharm has its own mechanism - if there's > something like mypy underneath, I don't know [which]. > > TBH I haven't noticed any such difficulties, BUT haven't tried using > more than a defined sub-class of Enum - and using such as a class. Thus: > > class MenuOptions( Enum ): > ??? """ Legal menu-choices. """ > ??? N = "NewGame" > ??? L = "LoadGame" > ??? .... > > > if __name__ == "__main__": > ??? n:MenuOptions = MenuOptions.N > ??? print( n, type( n ) ) > ??? # MenuOptions.N > > works correctly, but strikes me as pedantry. > (any (mypy) problematic code you'd like me to try (in PyCharm) as a > comparison? Perhaps off-list - could summarise any pertinent discoveries > later...) > > > I tried messing with the enum-members, eg N:str; but realised that > although this worked/was passed silently, the name of a member is not > actually a string anyway. So, backed that out. > > > Had noted the first web.ref but deemed it unimportant (to me - as > above). The second I had not found, and enjoyed reading (many thanks!). > > ?I?ll be honest, I struggled to think of concrete cases where this would > be useful, since I don?t tend to pile additional functionality into my > enumerations ? they?re almost always just bare classes which are members > of another class or module which provides the related functionality. But > I think it?s good to broaden your horizons...? > > The last being the same view as led me to this point, and the first, the > motivation for this post! As said, I tend to only use enums in a fairly > mechanistic fashion. > > However, I have been playing-around with his "additional functionality". > For example, adding the idea of a default-value if an enquiry attempts > to use a 'key' which is not present (which seems 'natural', but equally > goes against (my understanding of) the ethos of an enum). Next, (see > earlier comment about having to invoke the @member-target as a function) > was the idea that if one is using an enum as a collection of the correct > choices/responses in a menu (per code snippet), making the member.value > into a function* attempts to reproduce the idiom of using a dict[ionary] > to simulate a case/select construct - which combines the idea of an > API's constants with making a decision as to which functionality should > be invoked. > > * function here (cf "method") because unlikely to locate such > functionality within the enum. However, am also experimenting with > classes (cue OOP-mumblings, eg "polymorphism", "inversion", ...) > > All the fun of the fair! > > BTW when I reach the point of making comparisons, I expect the enum will > be 'cheaper' in storage; but that the dict-construct will be 'faster' - > pure speculation(!) Repeating: curious cats, etc... > From reading the references, especially the second one, it seems to me that these new features are mostly intended to handle weird cases involving subclasses of enums. I plan to master these features by avoiding them - and hope I never need to understand someone else's code that uses them. From peter.slizik at gmail.com Mon Jun 19 04:43:38 2023 From: peter.slizik at gmail.com (=?UTF-8?B?UGV0ZXIgU2zDrcW+aWs=?=) Date: Mon, 19 Jun 2023 10:43:38 +0200 Subject: File system path annotations Message-ID: Hello, what is the preferred way of annotating file system paths? This StackOverflow answer (and a few others) recommend using the str | os.PathLike union. However, byte arrays can be used as paths too, and including them would make the annotation quite long. I also believe that str confirms to the PathLike definition. Please, correct me if I'm wrong. And finally - using paths in Python programs is so common, that one would expect to have a special type (or type alias) in typing. Am I missing something? My apologies if I'm asking the obvious, but after some googling I came to the conclusion that information on this topic is surprisingly limited to a few StackOverflow questions. Best regards, Peter From roel at roelschroeven.net Mon Jun 19 05:09:36 2023 From: roel at roelschroeven.net (Roel Schroeven) Date: Mon, 19 Jun 2023 11:09:36 +0200 Subject: File system path annotations In-Reply-To: References: Message-ID: <283236db-95a3-f4cd-cf98-87792b369e52@roelschroeven.net> Op 19/06/2023 om 10:43 schreef Peter Sl??ik via Python-list: > Hello, > > what is the preferred way of annotating file system paths? > > This StackOverflow answer > (and a few others) recommend using the > > str | os.PathLike > > union. > > However, byte arrays can be used as paths too, and including them > would make the annotation quite long. You don't have to type out the whole thing every time. Define it somewhere: PathLike = str | bytes | os.PathLike and then you can use PathLike everywhere. > I also believe that str confirms to the PathLike definition. Please, > correct me if I'm wrong. I don't think so: os.PathLike instances must have a __fspath__() method, which str and bytes don't have. > And finally - using paths in Python programs is so common, that one > would expect to have a special type (or type alias) in typing. Am I > missing something? I agree there should be something like that. This StackOverflow answer (https://stackoverflow.com/a/68027757/59122) talks about something like that: _typeshed.AnyPath. It is used in the standard library, but apparently it doesn't exist at runtime and you need a trick to make it work. I would expect something better to exist, but as far as I can find out there isn't. PEP 519 has a little section on the topic (https://peps.python.org/pep-0519/#provide-specific-type-hinting-support): > Provide specific type hinting support > > There was some consideration to providing a generic typing.PathLike class which would allow for e.g. typing.PathLike[str] to specify a type hint for a path object which returned a string representation. > While potentially beneficial, the usefulness was deemed too small to bother adding the type hint class. > > This also removed any desire to have a class in the typing module which represented the union of all acceptable path-representing types as that can be represented with typing.Union[str, bytes, > os.PathLike] easily enough and the hope is users will slowly gravitate to path objects only. -- "This planet has - or rather had - a problem, which was this: most of the people living on it were unhappy for pretty much of the time. Many solutions were suggested for this problem, but most of these were largely concerned with the movement of small green pieces of paper, which was odd because on the whole it wasn't the small green pieces of paper that were unhappy." -- Douglas Adams From peter.slizik at gmail.com Mon Jun 19 05:44:23 2023 From: peter.slizik at gmail.com (=?UTF-8?B?UGV0ZXIgU2zDrcW+aWs=?=) Date: Mon, 19 Jun 2023 11:44:23 +0200 Subject: File system path annotations In-Reply-To: <283236db-95a3-f4cd-cf98-87792b369e52@roelschroeven.net> References: <283236db-95a3-f4cd-cf98-87792b369e52@roelschroeven.net> Message-ID: Thank you, Roel. You've answered all my questions. > [PEP 519]: ...as that can be represented with typing.Union[str, bytes, os.PathLike] easily enough and the hope is users > will slowly gravitate to path objects only. I read a lot on Python and, frankly, I don't see this happening. People on the Internet keep using *str* as their path representation choice. Presumably, programmers don't feel the need to bother with a complex solution if the simplest option works just fine. Peter From roel at roelschroeven.net Mon Jun 19 10:04:16 2023 From: roel at roelschroeven.net (Roel Schroeven) Date: Mon, 19 Jun 2023 16:04:16 +0200 Subject: File system path annotations In-Reply-To: References: <283236db-95a3-f4cd-cf98-87792b369e52@roelschroeven.net> Message-ID: <53d53373-ec18-496e-1d98-10f654990f95@roelschroeven.net> Op 19/06/2023 om 11:44 schreef Peter Sl??ik: > Thank you, Roel. You've answered all my questions. > > > [PEP 519]: ...as that can be represented with typing.Union[str, > bytes, os.PathLike] easily enough and the hope is users > > will slowly gravitate to path objects only. > > I read a lot on Python and, frankly, I don't see this happening. > People on the Internet keep using /str/ as their path representation > choice. Presumably, programmers don't feel the need to bother with a > complex solution if the simplest option works just fine. I agree, I don't see that happening either. I often find myself using str for paths: often simple filenames are all that's needed, and then I don't see much point in importing pathlib and wrapping the filenames in Path() constructors. I do tend to switch to path objects when I start needing to do operations on the paths, though. -- "Your scientists were so preoccupied with whether they could, they didn't stop to think if they should" -- Dr. Ian Malcolm From list1 at tompassin.net Mon Jun 19 11:23:00 2023 From: list1 at tompassin.net (Thomas Passin) Date: Mon, 19 Jun 2023 11:23:00 -0400 Subject: File system path annotations In-Reply-To: <53d53373-ec18-496e-1d98-10f654990f95@roelschroeven.net> References: <283236db-95a3-f4cd-cf98-87792b369e52@roelschroeven.net> <53d53373-ec18-496e-1d98-10f654990f95@roelschroeven.net> Message-ID: On 6/19/2023 10:04 AM, Roel Schroeven via Python-list wrote: > Op 19/06/2023 om 11:44 schreef Peter Sl??ik: >> Thank you, Roel. You've answered all my questions. >> >> > [PEP 519]: ...as that can be represented with typing.Union[str, >> bytes, os.PathLike] easily enough and the hope is users >> > will slowly gravitate to path objects only. >> >> I read a lot on Python and, frankly, I don't see this happening. >> People on the Internet keep using /str/ as their path representation >> choice. Presumably, programmers don't feel the need to bother with a >> complex solution if the simplest option works just fine. > I agree, I don't see that happening either. I often find myself using > str for paths: often simple filenames are all that's needed, and then I > don't see much point in importing pathlib and wrapping the filenames in > Path() constructors. I do tend to switch to path objects when I start > needing to do operations on the paths, though. If you are writing code that will run on both Windows and Linux/Mac, pathlib objects are very useful since the path separators will come out right with no extra effort. Also, the syntax for composing a path seems very natural (e.g., Path('a') / 'b' / 'c'), so that's a bonus. From bonapeti at gmail.com Mon Jun 19 07:49:53 2023 From: bonapeti at gmail.com (Peter Bona) Date: Mon, 19 Jun 2023 04:49:53 -0700 (PDT) Subject: Should NoneType be iterable? Message-ID: Hi I am wondering if there has been any discussion why NoneType is not iterable My feeling is that it should be. Sometimes I am using API calls which return None. If there is a return value (which is iterable) I am using a for loop to iterate. Now I am getting 'TypeError: 'NoneType' object is not iterable'. (Examples are taken from here https://rollbar.com/blog/python-typeerror-nonetype-object-is-not-iterable/) Example 1: mylist = None for x in mylist: print(x) <== will raise TypeError: 'NoneType' object is not iterable Solution: extra If statement if mylist is not None: for x in mylist: print(x) I think Python should handle this case gracefully: if a code would iterate over None: it should not run any step. but proceed the next statement. Has this been discussed or proposed? Thanks Peter From jon+usenet at unequivocal.eu Mon Jun 19 10:55:04 2023 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Mon, 19 Jun 2023 14:55:04 -0000 (UTC) Subject: Bug in io.TextIOWrapper? Message-ID: io.TextIOWrapper() wraps a binary stream so you can write text to it. It takes an 'encoding' parameter, which it uses to look up the codec in the codecs registry, and then it uses the IncrementalEncoder and IncrementalDecoder classes for the appropriate codec. The IncrementalEncoder.encode() function is given the object to encode of course, and also an optional second parameter which indicates if this is the final output. The bug is that TextIOWrapper() never sets the second parameter to indicate that the output is complete - not even if you call close(). Example: >>> import io >>> buffer = io.BytesIO() >>> stream = io.TextIOWrapper(buffer, encoding='idna') >>> stream.write('abc.example.com') 15 >>> stream.flush() >>> buffer.getvalue() b'abc.example.' Obviously using the 'idna' wrapper as an encoding on a stream is a bit unlikely, but nevertheless any other codec which cares about the 'final' parameter will also have this problem. From rosuav at gmail.com Mon Jun 19 12:39:19 2023 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 20 Jun 2023 02:39:19 +1000 Subject: Should NoneType be iterable? In-Reply-To: References: Message-ID: On Tue, 20 Jun 2023 at 02:37, Peter Bona via Python-list wrote: > > Hi > > I am wondering if there has been any discussion why NoneType is not iterable My feeling is that it should be. > Sometimes I am using API calls which return None. > If there is a return value (which is iterable) I am using a for loop to iterate. > > Now I am getting 'TypeError: 'NoneType' object is not iterable'. > > (Examples are taken from here https://rollbar.com/blog/python-typeerror-nonetype-object-is-not-iterable/) > Example 1: > mylist = None > for x in mylist: > print(x) <== will raise TypeError: 'NoneType' object is not iterable > Solution: extra If statement > if mylist is not None: > for x in mylist: > print(x) > > > I think Python should handle this case gracefully: if a code would iterate over None: it should not run any step. but proceed the next statement. > > Has this been discussed or proposed? > Try this instead: for x in mylist or (): Now a None list will skip iteration entirely, allowing you to get the effect you want :) ChrisA From songofacandy at gmail.com Mon Jun 19 13:15:00 2023 From: songofacandy at gmail.com (Inada Naoki) Date: Tue, 20 Jun 2023 02:15:00 +0900 Subject: Bug in io.TextIOWrapper? In-Reply-To: References: Message-ID: stream.flush() doesn't mean final output. Try stream.close() 2023?6?20?(?) 1:40 Jon Ribbens via Python-list : > io.TextIOWrapper() wraps a binary stream so you can write text to it. > It takes an 'encoding' parameter, which it uses to look up the codec > in the codecs registry, and then it uses the IncrementalEncoder and > IncrementalDecoder classes for the appropriate codec. > > The IncrementalEncoder.encode() function is given the object to encode > of course, and also an optional second parameter which indicates if > this is the final output. > > The bug is that TextIOWrapper() never sets the second parameter to > indicate that the output is complete - not even if you call close(). > > Example: > > >>> import io > >>> buffer = io.BytesIO() > >>> stream = io.TextIOWrapper(buffer, encoding='idna') > >>> stream.write('abc.example.com') > 15 > >>> stream.flush() > >>> buffer.getvalue() > b'abc.example.' > > Obviously using the 'idna' wrapper as an encoding on a stream is a bit > unlikely, but nevertheless any other codec which cares about the 'final' > parameter will also have this problem. > -- > https://mail.python.org/mailman/listinfo/python-list > From hjp-python at hjp.at Mon Jun 19 13:56:10 2023 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 19 Jun 2023 19:56:10 +0200 Subject: Bug in io.TextIOWrapper? In-Reply-To: References: Message-ID: <20230619175610.mtmmepkhw5p5wb36@hjp.at> On 2023-06-20 02:15:00 +0900, Inada Naoki via Python-list wrote: > stream.flush() doesn't mean final output. > Try stream.close() After close() the value isn't available any more: Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import io >>> buffer = io.BytesIO() >>> stream = io.TextIOWrapper(buffer, encoding='idna') >>> stream.write('abc.example.com') 15 >>> stream.close() >>> buffer.getvalue() Traceback (most recent call last): File "", line 1, in ValueError: I/O operation on closed file. 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 songofacandy at gmail.com Mon Jun 19 14:19:48 2023 From: songofacandy at gmail.com (Inada Naoki) Date: Tue, 20 Jun 2023 03:19:48 +0900 Subject: Bug in io.TextIOWrapper? In-Reply-To: <20230619175610.mtmmepkhw5p5wb36@hjp.at> References: <20230619175610.mtmmepkhw5p5wb36@hjp.at> Message-ID: You can use file instead of BytesIO 2023?6?20?(?) 3:05 Peter J. Holzer via Python-list : > On 2023-06-20 02:15:00 +0900, Inada Naoki via Python-list wrote: > > stream.flush() doesn't mean final output. > > Try stream.close() > > After close() the value isn't available any more: > > Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import io > >>> buffer = io.BytesIO() > >>> stream = io.TextIOWrapper(buffer, encoding='idna') > >>> stream.write('abc.example.com') > 15 > >>> stream.close() > >>> buffer.getvalue() > Traceback (most recent call last): > File "", line 1, in > ValueError: I/O operation on closed file. > > hp > > -- > _ | Peter J. Holzer | Story must make more sense than reality. > |_|_) | | > | | | hjp at hjp.at | -- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!" > -- > https://mail.python.org/mailman/listinfo/python-list > From songofacandy at gmail.com Mon Jun 19 14:46:38 2023 From: songofacandy at gmail.com (Inada Naoki) Date: Tue, 20 Jun 2023 03:46:38 +0900 Subject: Bug in io.TextIOWrapper? In-Reply-To: References: <20230619175610.mtmmepkhw5p5wb36@hjp.at> Message-ID: I checked TextIOWrapper source code and confirmed that it doesn't call encoder.write(text, finish=True) on close. Since TextIOWrapper allows random access, it is difficult to call it automatically. So please think it as just limitation rather than bug. Please use codec and binary file manually for now. From ndbecker2 at gmail.com Mon Jun 19 14:12:54 2023 From: ndbecker2 at gmail.com (Neal Becker) Date: Mon, 19 Jun 2023 14:12:54 -0400 Subject: Should NoneType be iterable? In-Reply-To: References: Message-ID: On Mon, Jun 19, 2023 at 12:42?PM Chris Angelico via Python-list < python-list at python.org> wrote: > On Tue, 20 Jun 2023 at 02:37, Peter Bona via Python-list > wrote: > > > > Hi > > > > I am wondering if there has been any discussion why NoneType is not > iterable My feeling is that it should be. > > Sometimes I am using API calls which return None. > > If there is a return value (which is iterable) I am using a for loop to > iterate. > > > > Now I am getting 'TypeError: 'NoneType' object is not iterable'. > > > > (Examples are taken from here > https://rollbar.com/blog/python-typeerror-nonetype-object-is-not-iterable/ > ) > > Example 1: > > mylist = None > > for x in mylist: > > print(x) <== will raise TypeError: 'NoneType' object is not iterable > > Solution: extra If statement > > if mylist is not None: > > for x in mylist: > > print(x) > > > > > > I think Python should handle this case gracefully: if a code would > iterate over None: it should not run any step. but proceed the next > statement. > > > > Has this been discussed or proposed? > > > > Try this instead: > > for x in mylist or (): > > Now a None list will skip iteration entirely, allowing you to get the > effect you want :) > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > I prefer iteration of None to be an error, as in my usage it usually indicates a mistake that I'd want to catch From PythonList at DancesWithMice.info Mon Jun 19 15:57:39 2023 From: PythonList at DancesWithMice.info (dn) Date: Tue, 20 Jun 2023 07:57:39 +1200 Subject: Should NoneType be iterable? In-Reply-To: References: Message-ID: <13b73d35-30cf-cac2-952a-56f994ae2e6f@DancesWithMice.info> On 20/06/2023 06.12, Neal Becker via Python-list wrote: > On Mon, Jun 19, 2023 at 12:42?PM Chris Angelico via Python-list < > python-list at python.org> wrote: > >> On Tue, 20 Jun 2023 at 02:37, Peter Bona via Python-list >> wrote: >>> >>> Hi >>> >>> I am wondering if there has been any discussion why NoneType is not >> iterable My feeling is that it should be. >>> Sometimes I am using API calls which return None. >>> If there is a return value (which is iterable) I am using a for loop to >> iterate. >>> >>> Now I am getting 'TypeError: 'NoneType' object is not iterable'. >>> >>> (Examples are taken from here >> https://rollbar.com/blog/python-typeerror-nonetype-object-is-not-iterable/ >> ) >>> Example 1: >>> mylist = None >>> for x in mylist: >>> print(x) <== will raise TypeError: 'NoneType' object is not iterable >>> Solution: extra If statement >>> if mylist is not None: >>> for x in mylist: >>> print(x) >>> >>> >>> I think Python should handle this case gracefully: if a code would >> iterate over None: it should not run any step. but proceed the next >> statement. >>> >>> Has this been discussed or proposed? >>> >> >> Try this instead: >> >> for x in mylist or (): >> >> Now a None list will skip iteration entirely, allowing you to get the >> effect you want :) >> >> ChrisA >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > I prefer iteration of None to be an error, as in my usage it usually > indicates a mistake that I'd want to catch Agreed! A better approach is that the API return (perhaps a tuple of) both "status" and "return_value", rather than overloading the latter. That said, apparently the OP use-case is for when there is no interest in status/catch, eg where a 'nothing' answer is THE answer. -- Regards, =dn From jon+usenet at unequivocal.eu Mon Jun 19 16:15:32 2023 From: jon+usenet at unequivocal.eu (Jon Ribbens) Date: Mon, 19 Jun 2023 20:15:32 -0000 (UTC) Subject: Bug in io.TextIOWrapper? References: <20230619175610.mtmmepkhw5p5wb36@hjp.at> Message-ID: On 2023-06-19, Inada Naoki wrote: > I checked TextIOWrapper source code and confirmed that it doesn't call > encoder.write(text, finish=True) on close. > Since TextIOWrapper allows random access, it is difficult to call it > automatically. So please think it as just limitation rather than bug. > Please use codec and binary file manually for now. It could call it on seek() or flush(). It seems like a definite bug to me, in that its behaviour appears clearly incorrect - it's just that there isn't an entirely obvious "100% correct" behaviour to choose. From nntp.mbourne at spamgourmet.com Mon Jun 19 16:48:12 2023 From: nntp.mbourne at spamgourmet.com (Mark Bourne) Date: Mon, 19 Jun 2023 21:48:12 +0100 Subject: Attaching a mock function to another mock breaks reset_mock() Message-ID: I've came across an issue with attaching a mock function to another mock object. It looks like this might be a bug in unittest.mock, but it's possible I'm misunderstanding or doing something wrong. I'm currently using Python 3.8.10, which is the default installed on Ubuntu 20.04. I don't have time to install and try other versions right now but from a quick look at the source at , it looks like the same issue would still occur with the latest. I have a workaround, but would still like to know if I'm doing something wrong which I can correct, or should report this as a bug. The class I'm testing (let's call it A) is given an instance of another class (let's call it B). In normal operation, some other code adds a callback function as an attribute to B before passing it to A, and A calls that callback at certain points. I agree this isn't particularly nice; I didn't write the code and don't have time to sort out all the structural issues at the moment. So, in setting up the mock B, I need to attach a mock callback function to it. I'd like the mock function to raise an exception if it's called with the wrong arguments. I can create such a mock function with, for example: ``` mock_callback = mock.create_autospec(lambda a, b, c: None) ``` Calls like mock_callback(1,2,3) or mock_callback(a=1,b=2,c=3) are fine, and the test can later check the exact values passed in, while mock_callback(1,2) or mock_callback(1,2,3,x=9) raise an exception at the time of the call - exactly what I want. However, when I attach this mock callback to the mock instance of B, the reset_mock() method breaks. For example, using object in place of B, since the rest of its implementation is irrelevant to the issue: ``` mock_callback = mock.create_autospec(lambda a, b, c: None) mock_b = mock.create_autospec(object, spec_set=False, instance=True) mock_b.attach_mock(mock_callback, 'some_callback') mock_b.reset_mock() ``` The call to reset_mock() results in: ``` Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.8/unittest/mock.py", line 603, in reset_mock child.reset_mock(visited) TypeError: reset_mock() takes 0 positional arguments but 1 was given ``` This seems to occur because, when creating a mock of a function or method, create_autospec calls _setup_func (via _set_signature), which sets the mock callback's reset_mock method to a function which doesn't accept any arguments. When mock_b.reset_mock() is called, that recursively calls reset_mock() on all the child mocks (including the mock callback), passing a number of arguments - which causes the above exception. I thought I might be able to just assign the mock callback to an attribute of the mock B, rather than using attach_mock, and avoid the recursive call to its reset_mock(): ``` mock_b.some_callback = mock_callback ``` But mock_b.reset_mock() still raises that exception. I think some magic in the mocks automatically attaches mock_callback as a child of mock_b even in that case. My current workaround is to just use ``` mock_callback = mock.Mock(spec_set=lambda: None) ``` instead. While using spec_set there prevents incorrect use of things like mock_b.some_callback.random_attribute, it doesn't enforce the arguments that the function can be called with, even if I do include them in the lambda (as in the first example). Is there something I'm doing wrong here? Or does this seem like a bug in unittest.mock that I should report? Perhaps this is something that's not often done, so the issue hasn't been noticed before. Trying to search for information generally leads back to the unittest.mock documentation, and general tutorials on using create_autospec, attach_mock, etc. without anything specific about this case. -- Mark. From greg.ewing at canterbury.ac.nz Mon Jun 19 20:50:36 2023 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Tue, 20 Jun 2023 12:50:36 +1200 Subject: Should NoneType be iterable? In-Reply-To: References: Message-ID: I would question the wisdom of designing an API that can return either a sequence or None. If it normally returns a sequence, and there are no items to return, it should return an empty sequence. -- Greg From barry at barrys-emacs.org Tue Jun 20 03:36:36 2023 From: barry at barrys-emacs.org (Barry) Date: Tue, 20 Jun 2023 08:36:36 +0100 Subject: Should NoneType be iterable? In-Reply-To: References: Message-ID: <0E5A4D68-B328-4FD3-A88B-EDD33A5EBDAA@barrys-emacs.org> > On 20 Jun 2023, at 01:57, Greg Ewing via Python-list wrote: > > I would question the wisdom of designing an API that > can return either a sequence or None. I have some APIs that do return None or a list. The None says that a list is not available and that the caller is responsible with dealing in a application-domain specific with with that situation. In other cases I have API that returns a default list, often []. It all depends on the design needs. Barry From greg.ewing at canterbury.ac.nz Tue Jun 20 11:01:00 2023 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Wed, 21 Jun 2023 03:01:00 +1200 Subject: Should NoneType be iterable? In-Reply-To: References: <0E5A4D68-B328-4FD3-A88B-EDD33A5EBDAA@barrys-emacs.org> Message-ID: On 20/06/23 7:36 pm, Barry wrote: > I have some APIs that do return None or a list. > The None says that a list is not available and that the caller is > responsible with dealing in a application-domain specific with > with that situation. In that case, the caller should probably be checking for None rather than blindly trying to iterate over the result. -- Greg From thomas at python.org Tue Jun 20 12:16:13 2023 From: thomas at python.org (Thomas Wouters) Date: Tue, 20 Jun 2023 18:16:13 +0200 Subject: [RELEASE] Python 3.12.0 beta 3 released Message-ID: We?re getting close! 3.12.0 beta 3 has been released: https://www.python.org/downloads/release/python-3120b3/ *This is a beta preview of Python 3.12* Python 3.12 is still in development. This release, 3.12.0b3, is the third of four beta release previews of 3.12. Beta release previews are intended to give the wider community the opportunity to test new features and bug fixes and to prepare their projects to support the new feature release. We *strongly encourage* maintainers of third-party Python projects to* test with 3.12* during the beta phase and report issues found to [the Python bug tracker (https://github.com/python/cpython/issues) as soon as possible. While the release is planned to be feature complete entering the beta phase, it is possible that features may be modified or, in rare cases, deleted up until the start of the release candidate phase (Monday, 2023-07-31). Our goal is to have no ABI changes after beta 4 and as few code changes as possible after 3.12.0rc1, the first release candidate. To achieve that, it will be *extremely important* to get as much exposure for 3.12 as possible during the beta phase. 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.12 series, compared to 3.11* Some of the new major new features and changes in Python 3.12 are: - New type annotation syntax for generic classes (PEP 695 ). - More flexible f-string parsing, allowing many things previously disallowed (PEP 701 ). - Even more improved error messages. More exceptions potentially caused by typos now make suggestions to the user. - Many large and small performance improvements (like PEP 709 ). - Support for the Linux perf profiler to report Python function names in traces. - The deprecated wstr and wstr_length members of the C implementation of unicode objects were removed, per PEP 623 . - In the unittest module, a number of long deprecated methods and classes were removed. (They had been deprecated since Python 3.1 or 3.2). - The deprecated smtpd and distutils modules have been removed (see PEP 594 and PEP 632 . The setuptools package continues to provide the distutils module. - A number of other old, broken and deprecated functions, classes and methods have been removed. - Invalid backslash escape sequences in strings now warn with SyntaxWarning instead of DeprecationWarning, making them more visible. (They will become syntax errors in the future.) - The internal representation of integers has changed in preparation for performance enhancements. (This should not affect most users as it is an internal detail, but it may cause problems for Cython-generated code.) - (Hey, fellow core developer, if a feature you find important is missing from this list, let Thomas know .) For more details on the changes to Python 3.12, see What's new in Python 3.12 . The next pre-release of Python 3.12 will be 3.12.0b4, the last beta release, currently scheduled for 2023-07-10. *More resources*Online Documentation . PEP 693 , the Python 3.12 Release Schedule. Report bugs via GitHub Issues . Help fund Python and its community . *We hope you enjoy the new releases!* Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation. Regards from a suddenly very stormy Amsterdam, Thomas Wouters Your release team, Ned Deily Steve Dower ?ukasz Langa -- Thomas Wouters From estates at hestates.org Tue Jun 20 12:30:15 2023 From: estates at hestates.org (Fulian Wang) Date: Tue, 20 Jun 2023 16:30:15 +0000 Subject: [RELEASE] Python 3.12.0 beta 3 released In-Reply-To: References: Message-ID: I am a beginner to design my website, please check the website code. I already run it local ,but want to make it richer and more variety. I need add a pdf b log to temporals and other logo pictures to decorate it. Thank you: import wsgiref.simple_server import wsgiref.simple_server ' '.join(map(str,list(range(10)))) import random random.choice(list(range(10))) def application(environ, start_response): headers = [('Content-Type', 'text/html; charset=utf-8')] start_response('200 OK', headers) path = environ['PATH_INFO'] hestates = '' if path == '/home': hestates = ''' hestates Title

The Church of Jesus Christ of Latter-day Saints

??????????

Service Area????Temporals????Contact Us????


In the temple of THE CHURCH of JESUS CHRIST of LATTER-DAY SAINTS, there is a sealing room to seal eternal marriage and family.The Doctrine of Eternal life, Marriage and Family is from Doctrine and Covenants 49:15?17; 131:1?4; and 132:1?24. Adults can receive temple endowment as a gift from God which is addressed in Doctrine and Covenants 132:24 " This is eternal lives?to know the only wise and true God, and Jesus Christ, whom he hath sent. I am he. Receive ye, therefore, my law." As a member of THE CHURCH of JESUS CHRIST of LATTER-DAY SAINTS, Fulian believes that memories,heart, might,mind, strength,and soul are human being's precious estates. As an agent of real estate, Fulian prefers clients to buy or sell real estates with effective and positive communication

???????????????????????????????????????????????????????????49:15?17; 131:1?4; ? 132:1?24. ????????????????????????????????????????132?24 "?????????????????????????????????????????????????" ????????????????????????????, ???????????????.????????????????????????????????????????????????

You are on hestates Home??????

''' elif path == '/Service': hestates = ''' hestates Title

The Church of Jesus Christ of Latter-day Saints

??????????

Home?? Temporals????Contact Us????

You are on Service Area????????

WELLCOME CASH ,CHECK, EPAY, GIFT CARD OR THANKSGIVING

You are welcome to ask any appropriate and legal help.

????Hestates.org.???? ??????????????????.

Website Design ???? First, find someone around you can help you in this service. If there is no appropriate service, Then talk ???????????????????????????

Website Hosting Service ????Safe and effective service at multiple states in USA and China ?????????2???????????????????????

Personal Assistant ????? Any appropriate and legal help, for example: Website domain service,Travel.The art of traveling is opening your imagination box and expands memories, mind,might,heart, strength and soul. Help to plan your vacation and guidance your trip, reserve hotel, and flight package. Suggestion of the tours, cars and activities.

?????????????????????????????.?????????????????.????????????????,???????????????????????????????Hestates ???????? ???????????????????????????????????????

''' elif path == '/Temporals': hestates = ''' hestates Title

The Church of Jesus Christ of Latter-day Saints

??????????

Home?? Service Area????Contact Us????

You are on Temporals????????

You are on hestates 3

Goodbye

Go to hestates 1

''' elif path == '/Contact': hestates = ''' hestates Title

The Church of Jesus Christ of Latter-day Saints

??????????

Home?? Service Area????Temporals????

You are on Contact Us????????

We are always here to serve you when you need

???????????

please visit, call, text, and mail

????????????

Meet (832)208-3196estates at Hestates.org

What is it that feed you? What is the meaning of life? Hestates.org values every unique and precious person.Please enjoy, rest, learn, share and help Hestates.org better.

???????????????????????Hestates.org ????????????????????????Hestates.org???????????????????????????Hestates.org??!

''' return [hestates.encode()] httpd = wsgiref.simple_server.make_server('', 8000, application) httpd.serve_forever() Sent from Mail for Windows Get Outlook for iOS ________________________________ From: Python-list on behalf of Thomas Wouters via Python-list Sent: Tuesday, June 20, 2023 11:16:13 AM To: python-list at python.org ; python-announce at python.org ; Python-Dev Subject: [RELEASE] Python 3.12.0 beta 3 released We?re getting close! 3.12.0 beta 3 has been released: https://www.python.org/downloads/release/python-3120b3/ *This is a beta preview of Python 3.12* Python 3.12 is still in development. This release, 3.12.0b3, is the third of four beta release previews of 3.12. Beta release previews are intended to give the wider community the opportunity to test new features and bug fixes and to prepare their projects to support the new feature release. We *strongly encourage* maintainers of third-party Python projects to* test with 3.12* during the beta phase and report issues found to [the Python bug tracker (https://github.com/python/cpython/issues) as soon as possible. While the release is planned to be feature complete entering the beta phase, it is possible that features may be modified or, in rare cases, deleted up until the start of the release candidate phase (Monday, 2023-07-31). Our goal is to have no ABI changes after beta 4 and as few code changes as possible after 3.12.0rc1, the first release candidate. To achieve that, it will be *extremely important* to get as much exposure for 3.12 as possible during the beta phase. 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.12 series, compared to 3.11* Some of the new major new features and changes in Python 3.12 are: - New type annotation syntax for generic classes (PEP 695 ). - More flexible f-string parsing, allowing many things previously disallowed (PEP 701 ). - Even more improved error messages. More exceptions potentially caused by typos now make suggestions to the user. - Many large and small performance improvements (like PEP 709 ). - Support for the Linux perf profiler to report Python function names in traces. - The deprecated wstr and wstr_length members of the C implementation of unicode objects were removed, per PEP 623 . - In the unittest module, a number of long deprecated methods and classes were removed. (They had been deprecated since Python 3.1 or 3.2). - The deprecated smtpd and distutils modules have been removed (see PEP 594 and PEP 632 . The setuptools package continues to provide the distutils module. - A number of other old, broken and deprecated functions, classes and methods have been removed. - Invalid backslash escape sequences in strings now warn with SyntaxWarning instead of DeprecationWarning, making them more visible. (They will become syntax errors in the future.) - The internal representation of integers has changed in preparation for performance enhancements. (This should not affect most users as it is an internal detail, but it may cause problems for Cython-generated code.) - (Hey, fellow core developer, if a feature you find important is missing from this list, let Thomas know .) For more details on the changes to Python 3.12, see What's new in Python 3.12 . The next pre-release of Python 3.12 will be 3.12.0b4, the last beta release, currently scheduled for 2023-07-10. *More resources*Online Documentation . PEP 693 , the Python 3.12 Release Schedule. Report bugs via GitHub Issues . Help fund Python and its community . *We hope you enjoy the new releases!* Thanks to all of the many volunteers who help make Python Development and these releases possible! Please consider supporting our efforts by volunteering yourself or through organization contributions to the Python Software Foundation. Regards from a suddenly very stormy Amsterdam, Thomas Wouters Your release team, Ned Deily Steve Dower ?ukasz Langa -- Thomas Wouters -- https://mail.python.org/mailman/listinfo/python-list From codewizard at gmail.com Mon Jun 19 20:18:50 2023 From: codewizard at gmail.com (Igor Berger) Date: Mon, 19 Jun 2023 17:18:50 -0700 (PDT) Subject: Should NoneType be iterable? In-Reply-To: References: <13b73d35-30cf-cac2-952a-56f994ae2e6f@DancesWithMice.info> Message-ID: <70a2a5e4-75c3-40f3-981e-8bcf33443486n@googlegroups.com> On Monday, June 19, 2023 at 4:11:15?PM UTC-4, Julio Di Egidio wrote: > On Monday, 19 June 2023 at 21:58:21 UTC+2, dn wrote: > > On 20/06/2023 06.12, Neal Becker via Python-list wrote: > > > > I prefer iteration of None to be an error, as in my usage it usually > > > indicates a mistake that I'd want to catch > > > > Agreed! > That is a *bad practice* with potentially disastrous consequences, > as I have explained. You too, like Angelico, can't even read? > > [snip] > > Julio Julio, Most of the regulars in this list/group read the posts using the mailing list and have declared that they explicitly filter out anything posted on Google Groups. I've seen it multiple times with your posts. You respond to something and others post parallel to you. It looks like you're being ignored. However, they simply don't see your posts. Neither they'll see my response. Regards, Igor. From roel at roelschroeven.net Tue Jun 20 03:30:37 2023 From: roel at roelschroeven.net (Roel Schroeven) Date: Tue, 20 Jun 2023 09:30:37 +0200 Subject: Should NoneType be iterable? In-Reply-To: References: Message-ID: Op 20/06/2023 om 2:50 schreef Greg Ewing via Python-list: > I would question the wisdom of designing an API that > can return either a sequence or None. If it normally > returns a sequence, and there are no items to return, > it should return an empty sequence. I guess it depends on the reason why there are no items. If it is simply because there are no items, then yes, I agree it should return an empty sequence. But if it is because of some kind of error condition, I don't think it should. But in that case I don't think the API should return None either: I feel it should raise an exception. -- "Je ne suis pas d?accord avec ce que vous dites, mais je me battrai jusqu?? la mort pour que vous ayez le droit de le dire." -- Attribu? ? Voltaire "I disapprove of what you say, but I will defend to the death your right to say it." -- Attributed to Voltaire "Ik ben het niet eens met wat je zegt, maar ik zal je recht om het te zeggen tot de dood toe verdedigen" -- Toegeschreven aan Voltaire From jhasonam05 at gmail.com Tue Jun 20 03:49:21 2023 From: jhasonam05 at gmail.com (sonam Kumari) Date: Tue, 20 Jun 2023 00:49:21 -0700 (PDT) Subject: How to add CC and BCC while sending mails using python In-Reply-To: References: <46da4e770809300727j368a27b8qc570a8451a53e470@mail.gmail.com> Message-ID: On Friday, November 30, 2012 at 7:00:27?AM UTC+5:30, ake... at gmail.com wrote: > On Tuesday, September 30, 2008 8:00:16 AM UTC-8, Bernhard Walle wrote: > > Hi, > > > > * cindy jones [2008-09-30 19:57]: > > > > > > Can someone tel me how to add cc's and bcc's while sending mails using > > > python > > > > Following (tested) snippet should help: > > > > ------------------ 8< ------------------------------ > > from smtplib import SMTP > > from email.mime.image import MIMEImage > > from email.mime.text import MIMEText > > from email.mime.multipart import MIMEMultipart > > > > to = 'to_ad... at example.invalid' > > cc = 'cc_ad... at example.invalid' > > bcc = 'bcc_a... at example.invalid' > > > > msg = MIMEMultipart() > > msg['To'] = to > > msg['Cc'] = cc > > msg['From'] = 'bern... at bwalle.de' > > msg['Subject'] = 'Test' > > text = MIMEText('Das ist ein Test') > > text.add_header("Content-Disposition", "inline") > > msg.attach(text) > > > > s = SMTP('test.smtp.relay') > > s.sendmail(msg['From'], [to, cc, bcc], msg.as_string()) > > s.quit() > > ------------------ >8 ------------------------------ > > > > > > Regards, > > Bernhard > Hello Bernhard, > > I've tried the above code and the bcc address does not receive the message, on the To & CC addresses receive it. > > Here are snippets from my code, perhaps something will stand out to you? > > to = 'e... at domain.gov' > cc = 'e... at gmailmail.com' > bcc = 'e... at home.net' > msg = MIMEMultipart() > msg['To'] = to > msg['Cc'] = cc > msg['Subject'] = 'My Subject text here' > msg['From'] = 'eds... at domain.gov' > > smtp = SMTP("smtpserver") > smtp.ehlo() > smtp.sendmail(msg['From'], [to, cc, bcc], msg.as_string()) > > Thanks in advance..hope you're still out there!! > ~Ed I tried this but my mail gets sent only in to but not in cc. Can anyone help? From rosuav at gmail.com Tue Jun 20 14:12:39 2023 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 21 Jun 2023 04:12:39 +1000 Subject: Should NoneType be iterable? In-Reply-To: <70a2a5e4-75c3-40f3-981e-8bcf33443486n@googlegroups.com> References: <13b73d35-30cf-cac2-952a-56f994ae2e6f@DancesWithMice.info> <70a2a5e4-75c3-40f3-981e-8bcf33443486n@googlegroups.com> Message-ID: On Wed, 21 Jun 2023 at 03:46, Igor Berger via Python-list wrote: > Most of the regulars in this list/group read the posts using the mailing list and > have declared that they explicitly filter out anything posted on Google Groups. > > I've seen it multiple times with your posts. You respond to something and others post parallel to you. > It looks like you're being ignored. However, they simply don't see your posts. > > Neither they'll see my response. > I don't filter out Google Groups. However, the mailing list admins have banned certain users, and their posts do not make it across the gateway. So for those particular people, NONE of us see their posts. If you post on Google Groups and it seems like almost nobody is reading your posts, check whether you've been consistently violating the Python Code of Conduct. Maybe the problem isn't with everyone else. ChrisA From roel at roelschroeven.net Tue Jun 20 15:16:03 2023 From: roel at roelschroeven.net (Roel Schroeven) Date: Tue, 20 Jun 2023 21:16:03 +0200 Subject: How to add CC and BCC while sending mails using python In-Reply-To: References: <46da4e770809300727j368a27b8qc570a8451a53e470@mail.gmail.com> Message-ID: <24afc44d-98e7-57c0-4502-0dc46dcb2bf9@roelschroeven.net> sonam Kumari via Python-list schreef op 20/06/2023 om 9:49: > > > > I've tried the above code and the bcc address does not receive the message, on the To & CC addresses receive it. > > > > Here are snippets from my code, perhaps something will stand out to you? > > > > to = 'e... at domain.gov' > > cc = 'e... at gmailmail.com' > > bcc = 'e... at home.net' > > msg = MIMEMultipart() > > msg['To'] = to > > msg['Cc'] = cc > > msg['Subject'] = 'My Subject text here' > > msg['From'] = 'eds... at domain.gov' > > > > smtp = SMTP("smtpserver") > > smtp.ehlo() > > smtp.sendmail(msg['From'], [to, cc, bcc], msg.as_string()) > > > > Thanks in advance..hope you're still out there!! > > ~Ed > > > I tried this but my mail gets sent only in to but not in cc. Can anyone help? That looks like it should work. In fact I typed in your code, with some email addresses of mine and another smtp server, and it does work. That's to say, I can see in the logs of my smtp server that three mails are sent out, and I see the mails arriving at the to-address and the cc-address. The bcc-addres doesn't seem to receive the mail reliably: sometimes not at all, sometimes in the spam folder. It looks like mail systems don't like bcc very much. As far as I can see the code is correct, and there is a good chance the problem is caused by a mail server not accepting one or more of the messages for some reason. I added some content to the mail, and that seemed to work better. So, some suggestions: - Do you have access to the smtp server to check its logs and see what is sent, what is not sent, and any possible error messages? - Try adding some content to the email, something which looks nothing like spam. -- "Met een spitsvondig citaat bewijs je niets." -- Voltaire From cs at cskk.id.au Tue Jun 20 19:47:46 2023 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 21 Jun 2023 09:47:46 +1000 Subject: Should NoneType be iterable? In-Reply-To: References: Message-ID: On 21Jun2023 03:01, Greg Ewing wrote: >On 20/06/23 7:36 pm, Barry wrote: >>I have some APIs that do return None or a list. >>The None says that a list is not available and that the caller is >>responsible with dealing in a application-domain specific with >>with that situation. > >In that case, the caller should probably be checking for >None rather than blindly trying to iterate over the result. I wasted some time the other evening on an API which returned a string or None. My own API, and the pain it caused tells me that that API design choice isn't good (it's an automatic attribute based on a tag, returning None if the tag isn't there). My experience so far is that it _looks_ handy so that you can safely say "foo.bar" all the time, but as soon a you do something with the value you're in for a world of None-checking. I'm rethinking that choice right now. Just the other day I removed a setting in a related class which provided an automatic default value because, again, while handy for careless use it caused hard to debug problems because the default would flow out the call chain until it was unsuitable, making the cause hard to trace. And of course I'm very -1 on None acquiring iteration or other features. Fail early, fail often! Cheers, Cameron Simpson From rosuav at gmail.com Tue Jun 20 20:09:18 2023 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 21 Jun 2023 10:09:18 +1000 Subject: Should NoneType be iterable? In-Reply-To: References: Message-ID: On Wed, 21 Jun 2023 at 09:59, Cameron Simpson via Python-list wrote: > I wasted some time the other evening on an API which returned a string > or None. My own API, and the pain it caused tells me that that API > design choice isn't good (it's an automatic attribute based on a tag, > returning None if the tag isn't there). My experience so far is that it > _looks_ handy so that you can safely say "foo.bar" all the time, but as > soon a you do something with the value you're in for a world of > None-checking. > https://peps.python.org/pep-0505/ ChrisA From cs at cskk.id.au Tue Jun 20 20:44:52 2023 From: cs at cskk.id.au (Cameron Simpson) Date: Wed, 21 Jun 2023 10:44:52 +1000 Subject: Should NoneType be iterable? In-Reply-To: References: Message-ID: On 21Jun2023 10:09, Chris Angelico wrote: >On Wed, 21 Jun 2023 at 09:59, Cameron Simpson via Python-list > wrote: >> I wasted some time the other evening on an API which returned a >> string >> or None. My own API, and the pain it caused tells me that that API >> design choice isn't good (it's an automatic attribute based on a tag, >> returning None if the tag isn't there). My experience so far is that it >> _looks_ handy so that you can safely say "foo.bar" all the time, but as >> soon a you do something with the value you're in for a world of >> None-checking. >> >https://peps.python.org/pep-0505/ Hmm. Thanks. - Cameron Simpson From dankolis at gmail.com Wed Jun 21 09:37:47 2023 From: dankolis at gmail.com (Dan Kolis) Date: Wed, 21 Jun 2023 06:37:47 -0700 (PDT) Subject: What is this TEST BANK stuff ? Message-ID: <3dcfc5c1-bf00-44df-aea7-cc1a9e7b0e6fn@googlegroups.com> Why do we tolerate this spam ? this seems most likely a way to inject viruses into people's workflow. That wiped out usenet. Ahh without an explaination; ( and it woudl have to be a good one ); what is the purpsoe of this, why is it here ? Can it be eliminated ? Regards, Dan From dankolis at gmail.com Wed Jun 21 09:47:56 2023 From: dankolis at gmail.com (Dan Kolis) Date: Wed, 21 Jun 2023 06:47:56 -0700 (PDT) Subject: TKinter in Python - advanced notions Message-ID: <95ce080b-eb2d-4fbf-b20a-8589c8bd57f4n@googlegroups.com> Hi, I've write a huge biotech program ( an IDE for synthetic biology ), and am slowly outgrowing TKINTER. Has anybody out there merged a little bit of TCL direct calls from Python 3.X to get more freedom then TKINTER for just some Windows ? How about bold stories of successes ( yours, not mine ) on porting to stupid MS Windows from linux ? Adding threading makes TKinter hard ( but not impossible ) to manage. Also, a little bit here and there obviously exceeds TKINTERs goals. I wish it looked better, but its 'ok'. I believe X11 IO is considerably superior for serious work the HTML. I mean 'serious' work. with lots of multi media windows. I am not talking about fb "Oh ! There is a window it opened inthe corner !"... trivial functionality. Must be a uber expert out there. Is it you ? As attached. and little code. Coloring text makes me realise; some of this is pretty indirect, though this is quite well thought out, like all of TKINTER. Regards, Daniel B. Kolis """ An important worked example of text color and other look dynamic changes. This is the righ way to do this for fast changes ! 20 Jun 2023 22:11 """ import tkinter as tk from tkinter.font import Font class Pad( tk.Frame ): def __init__( self, parent, *args, **kwargs ): tk.Frame.__init__( self, parent, *args, **kwargs ) self.toolbar = tk.Frame( self, bg="#eee" ) self.toolbar.pack( side="top", fill="x" ) self.bold_btn = tk.Button( self.toolbar, text="CHANGE highlighted", command=self.make_Change_Highlighted ) self.bold_btn.pack( side="left" ) self.bold_btn = tk.Button( self.toolbar, text="CHANGE H.B.", command=self.make_Change_Hb ) self.bold_btn.pack( side="left" ) self.bold_btn = tk.Button( self.toolbar, text="Delete a char", command=self.make_Change_Delete ) self.bold_btn.pack( side="left" ) self.clear_btn = tk.Button( self.toolbar, text="Clear", command=self.clear_Some ) self.clear_btn.pack( side="left" ) # Applies this font self.bold_font = Font( family="Helvetica", size=14, weight="bold" ) self.da_Text = tk.Text( self ) self.da_Text.insert( "end", "Selectable parts of text is fun.\nSo is a happy birthday, right ?" ) self.da_Text.focus( ) self.da_Text.pack( fill="both", expand=True ) # configuring a tag called dingo-something self.da_Text.tag_configure( "reddingo", font=self.bold_font, foreground = "Red" ) self.da_Text.tag_configure( "bluedingo", font=self.bold_font, background = "Yellow", foreground = "Blue" ) # Button CB def make_Change_Delete( self ): self.da_Text.delete( '1.0', '1.1' ) # Button CB def make_Change_Highlighted( self ): # tk.TclError exception is raised if not text is selected try: self.da_Text.tag_add( "reddingo", "sel.first", "sel.last" ) except tk.TclError: tttttt = 569 # Button CB def make_Change_Hb( self ): try: lin_Idx = 2; col_Idx = 8 self.da_Text.tag_add( "bluedingo", f"{ lin_Idx }.{ col_Idx }", f"{ lin_Idx }.{ col_Idx + len( 'happy birthday' ) }" ) except: gggggg = 457 # Button CB def clear_Some( self ): self.da_Text.tag_remove( "reddingo", "1.0", 'end' ) self.da_Text.tag_remove( "bluedingo", "1.0", 'end' ) # Main body really def is_Main(): root = tk.Tk() Pad( root ).pack( expand=1, fill="both" ) root.mainloop() # Go if __name__ == "__main__": is_Main() Document end my ref: 21 Jun 2023, https://groups.google.com/g/comp.lang.python, Daniel B. Kolis, nafl From skap127891011 at gmail.com Wed Jun 21 11:28:59 2023 From: skap127891011 at gmail.com (Pickle Pork) Date: Wed, 21 Jun 2023 11:28:59 -0400 Subject: Python Issue Message-ID: Python is unable to open. Exit Code: 1 From rosuav at gmail.com Wed Jun 21 12:59:28 2023 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 22 Jun 2023 02:59:28 +1000 Subject: What is this TEST BANK stuff ? In-Reply-To: <3dcfc5c1-bf00-44df-aea7-cc1a9e7b0e6fn@googlegroups.com> References: <3dcfc5c1-bf00-44df-aea7-cc1a9e7b0e6fn@googlegroups.com> Message-ID: On Thu, 22 Jun 2023 at 02:54, Dan Kolis via Python-list wrote: > > Why do we tolerate this spam ? > > this seems most likely a way to inject viruses into people's workflow. > > That wiped out usenet. Ahh without an explaination; ( and it woudl have to be a good one ); what is the purpsoe of this, why is it here ? > > Can it be eliminated ? > Yes, follow the mailing list instead of the newsgroup. Most spam doesn't reach us over here at the list. Sign up here: https://mail.python.org/mailman/listinfo/python-list ChrisA From PythonList at DancesWithMice.info Wed Jun 21 13:30:15 2023 From: PythonList at DancesWithMice.info (dn) Date: Thu, 22 Jun 2023 05:30:15 +1200 Subject: Python Issue In-Reply-To: References: Message-ID: <8e968d21-8243-2361-06cb-ab04e7bd5118@DancesWithMice.info> On 22/06/2023 03.28, Pickle Pork via Python-list wrote: > Python is unable to open. Exit Code: 1 This is not good. Please give some useful information: - from where did you download Python? - which operating system? - how do you "open" Python? etc. -- Regards, =dn From grant.b.edwards at gmail.com Wed Jun 21 14:08:06 2023 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Wed, 21 Jun 2023 11:08:06 -0700 (PDT) Subject: What is this TEST BANK stuff ? References: <3dcfc5c1-bf00-44df-aea7-cc1a9e7b0e6fn@googlegroups.com> Message-ID: <64933c86.020a0220.9470f.272a@mx.google.com> On 2023-06-21, Chris Angelico via Python-list wrote: > On Thu, 22 Jun 2023 at 02:54, Dan Kolis via Python-list > wrote: >> >> Why do we tolerate this spam ? >> >> this seems most likely a way to inject viruses into people's workflow. >> >> That wiped out usenet. Ahh without an explaination; ( and it woudl have to be a good one ); what is the purpsoe of this, why is it here ? >> >> Can it be eliminated ? >> > > Yes, follow the mailing list instead of the newsgroup. Most spam > doesn't reach us over here at the list. > > Sign up here: https://mail.python.org/mailman/listinfo/python-list If you want to stick with NNTP as your access protocol, you can follow the list on gmane: nntp://news.gmane.io/gmane.comp.python.general However, the list recently stopped accepting posts via gmane, so you'll need to configure your nntp client to e-mail posts to that group. From aapost at idontexist.club Wed Jun 21 16:10:11 2023 From: aapost at idontexist.club (aapost) Date: Wed, 21 Jun 2023 16:10:11 -0400 Subject: TKinter in Python - advanced notions In-Reply-To: <95ce080b-eb2d-4fbf-b20a-8589c8bd57f4n@googlegroups.com> References: <95ce080b-eb2d-4fbf-b20a-8589c8bd57f4n@googlegroups.com> Message-ID: On 6/21/23 09:47, Dan Kolis wrote: > I've write a huge biotech program ( an IDE for synthetic biology ), and am slowly outgrowing TKINTER. > > Has anybody out there merged a little bit of TCL direct calls from Python 3.X to get more freedom then TKINTER for just some Windows ? > I wish it looked better, but its 'ok'. I believe X11 IO is considerably superior for serious work the HTML. I mean 'serious' work. with lots of multi media windows. I am not talking about fb "Oh ! There is a window it opened inthe corner !"... trivial functionality. I don't know if it would help, but you can extend/add tcl/tk packages I don't remember the full instructions right off, but quickly reverse engineering my old stuff I think you just need to drop them in /usr/share/tcltk/ or equivalent. (I needed to do that to replace the terrible looking default file dialog for unix/linux with fsdialog.) then running something like the following from your Tk object self.eval('package require fsdialog') (reverse engineering the python tkinter source you can likely find other ways of doing more tcl direct stuff) I have not researched if there are some better, more featured (non-buggy) Text widgets implemented in tcl that can be dropped in, (I know several of the tcl drop in widgets I tried were lacking in refinement). From what I can tell, once upon a time there were better, more interesting projects and tutorials on extending tkinter, such as WCK (tkinter3000), but the only remnants of those remain publicly available are outdated unmaintained archives. You might also consider looking at the Grail browser source for research purposes, as it does some interesting things with some of the widgets, (parsing html and such), even though it is 20 years old now (and written in python 1). The update attempts from 10+ years ago have disappeared. (it's license is considered questionable from what I understand, so not sure if that is an aspect of it, the other being one of it's main features, python applets, is unsafe and was not easily fixable) You might already be beyond some of these things though. I know what you mean as far is feeling like the little bit extra you need pushes beyond what tkinter can do / makes you feel like you have outgrown the module. (I had to take a break from one of my projects and send it to development hell until my UI knowledge/skills improve after I found myself considering using xml schema appinfo annotations to store json formatted widget specific information, lol.) I have felt that sense of lack with most of the UI modules I have tried though. I don't know of a clear better python-only solution though that fits my personal needs. So I have to lean toward improving my tcl / C in hopes that it might help steer me toward that extra (which seems to be in the spirit of what tcl/tk's intent is to begin with). That will be a while for me though if I get there. From dankolis at gmail.com Wed Jun 21 17:07:23 2023 From: dankolis at gmail.com (Dan Kolis) Date: Wed, 21 Jun 2023 14:07:23 -0700 (PDT) Subject: TKinter in Python - advanced notions - III - Grail, a browser in Python In-Reply-To: References: <95ce080b-eb2d-4fbf-b20a-8589c8bd57f4n@googlegroups.com> Message-ID: <8bd8a28c-04f9-445b-8610-4f2635da7506n@googlegroups.com> Thanks for the notions. As you predicted, not much of what you said is new to me: except: https://dbpedia.org/page/Grail_(web_browser) However, that one line item is quite helpful. Looking at that may help me with various ideas, etc. Thank you, Dan From cebtenzzre at gmail.com Wed Jun 21 17:45:53 2023 From: cebtenzzre at gmail.com (Cebtenzzre) Date: Wed, 21 Jun 2023 17:45:53 -0400 Subject: pip install -e does not build shared libraries Message-ID: When I try to use `pip install -e .` with llama-cpp-python or bitsandbytes, it doesn't build the shared libraries like `pip install .` does. In the case of llama-cpp-python, there is no _skbuild folder generated at all, just llama_cpp_python.egg-info. This results in an error when I try to import it, e.g. "FileNotFoundError: Shared library with base name 'llama' not found". In this case, `python setup.py develop` also works. In the case of bitsandbytes, there is no build folder generated at all, just bitsandbytes.egg-info. This results in an error when I try to import it, e.g. "CUDA SETUP: Required library version not found: libbitsandbytes_cuda121_nocublaslt.so. Maybe you need to compile it from source?". In this case, `python setup.py develop` does not seem to work either. Is this something that can be fixed in the projects' setup.py or pyproject.toml, or is it an issue with pip or setuptools? Thanks, Cebtenzzre From cebtenzzre at gmail.com Wed Jun 21 22:40:13 2023 From: cebtenzzre at gmail.com (Cebtenzzre) Date: Wed, 21 Jun 2023 22:40:13 -0400 Subject: pip install -e does not build shared libraries In-Reply-To: References: Message-ID: On Wed, Jun 21, 2023 at 5:45?PM Cebtenzzre wrote: > In the case of bitsandbytes, there is no build folder generated at > all, just bitsandbytes.egg-info. This results in an error when I try > to import it, e.g. "CUDA SETUP: Required library version not found: > libbitsandbytes_cuda121_nocublaslt.so. Maybe you need to compile it > from source?". In this case, `python setup.py develop` does not seem > to work either. Correction: `make` must be run manually to build bitsandbytes. I made a mistake while testing. `make clean` doesn't work correctly, so I had to use `git clean` to get repeatable results. From cebtenzzre at gmail.com Thu Jun 22 11:59:19 2023 From: cebtenzzre at gmail.com (Cebtenzzre) Date: Thu, 22 Jun 2023 11:59:19 -0400 Subject: pip install -e does not build shared libraries In-Reply-To: References: Message-ID: It turns out that this is a scikit-build issue: https://github.com/scikit-build/scikit-build/issues/740 https://github.com/scikit-build/scikit-build/issues/939 https://github.com/scikit-build/scikit-build/issues/981 From estates at hestates.org Thu Jun 22 13:39:21 2023 From: estates at hestates.org (Fulian Wang) Date: Thu, 22 Jun 2023 17:39:21 +0000 Subject: Email list and part of website code In-Reply-To: References: Message-ID: A little confused about that I got the email list different. Sometimes has names and email address displayed on it, sometimes not . If I don??t follow the new list, just type python-list at pythone.org It's another different one with different name on it. that confuse me to know which one is new one. Anyone has other email list problems ? Get Outlook for iOS ________________________________ From: Fulian Wang Sent: Thursday, June 22, 2023 12:35:20 PM To: Cebtenzzre ; python-list at python.org Subject: Email list and part of website code For technical knowledge, hestates.org is not available for the past 1-2 days. Now it should be available worldwide. I apologize for the inconvenience that I cannot attach document of the code .py in the email . I want to, but failed on my devices . Anyone is welcome to visit me , call me or mail me about website design .Please check it if you are available to see the text code : I am a beginner to design my website, please help to check the website code. I already run it local successfully ,but want to make it richer and more variety. I need add a pdf document which was a published blog to temporals and other logo pictures to decorate it. Thank you import wsgiref.simple_server def application(environ, start_response): headers = [('Content-Type', 'text/html; charset=utf-8')] start_response('200 OK', headers) path = environ['PATH_INFO'] hestates = '' if path == '/home': hestates = ''' hestates Title

The Church of Jesus Christ of Latter-day Saints

???d?????????}??????

Service Area?????^??Temporals????????Contact Us????????


In the temple of THE CHURCH of JESUS CHRIST of LATTER-DAY SAINTS, there is a sealing room to seal eternal marriage and family.The Doctrine of Eternal life, Marriage and Family is from Doctrine and Covenants 49:15?C17; 131:1?C4; and 132:1?C24. Adults can receive temple endowment as a gift from God which is addressed in Doctrine and Covenants 132:24 " This is eternal lives??to know the only wise and true God, and Jesus Christ, whom he hath sent. I am he. Receive ye, therefore, my law." As a member of THE CHURCH of JESUS CHRIST of LATTER-DAY SAINTS, Fulian believes that memories,heart, might,mind, strength,and soul are human being's precious estates. As an agent of real estate, Fulian prefers clients to buy or sell real estates with effective and positive communication

?????d?????????}?????????}???Y???????????C?????g?????C?????????s???????????????????????s???????????x?????????x???}?s??49:15?C17; 131:1?C4;??132:1?C24.???????????????}???????T???x???????????????????????n???????????w???????x???}?s??132??24 "?@???????????T???????????????????????????????????????d????????????????????????????????????????????"???????d?????????}???????????T???????J?????????????????S,?????????????`?????????F???Y?a.???????????I???a???o?????????A???????e?O?????????????????????????????????I?????N?????????????a??

You are on hestates Home????????????

''' elif path == '/Service': hestates = ''' hestates Title

The Church of Jesus Christ of Latter-day Saints

???d?????????}??????

Home????Temporals????????Contact Us????????

You are on Service Area?????????^??????

WELLCOME CASH ,CHECK, EPAY, GIFT CARD OR THANKSGIVING

You are welcome to ask any appropriate and legal help.

????????Hestates.org.????????????????????????????????????????????.

Website Design???u?W?? First, find someone around you can help you in this service. If there is no appropriate service, Then talk???????h?????????????????????????????????]????????????

Website Hosting Service?W??????Safe and effective service at multiple states in USA and China??????????????????2???????????????????????????????????????r??????

Personal Assistant?????????? Any appropriate and legal help, for example: Website domain service,Travel.The art of traveling is opening your imagination box and expands memories, mind,might,heart, strength and soul. Help to plan your vacation and guidance your trip, reserve hotel, and flight package. Suggestion of the tours, cars and activities.

?????????????????????????????????????W????????????????????.?W???????????????????????????????x.?????????g???????????????C???U??,?K?U?????????????????????????????????????????????S???????`????Hestates???????????????????o?????????????????????????A???e?^???C?????f?????A?x????????????????????????

''' elif path == '/Temporals': hestates = ''' hestates Title

The Church of Jesus Christ of Latter-day Saints

???d?????????}??????

Home????Service Area?????^??Contact Us????????

You are on Temporals????????????????

You are on hestates 3

Goodbye

Go to hestates 1

''' elif path == '/Contact': hestates = ''' hestates Title

The Church of Jesus Christ of Latter-day Saints

???d?????????}??????

Home????Service Area?????^??Temporals????????

You are on Contact Us????????????????

We are always here to serve you when you need

??????????????????????

please visit, call, text, and mail

?????????????????????]??

Meet(832)208-3196estates at Hestates.org

What is it that feed you? What is the meaning of life?Hestates.orgvalues every unique and precious person.Please enjoy, rest, learn, share and helpHestates.orgbetter.

?????P?]?????????L?????????????^?????????x????Hestates.org???????????????????o???????F?????w?????????????gHestates.org???K?????????W?????????????????g?????????????????K????Hestates.org????!

''' return [hestates.encode()] httpd = wsgiref.simple_server.make_server('', 8000, application) httpd.serve_forever() Sent fromMailfor Windows Get Outlook for iOS ________________________________ From:Python-list on behalf of Greg Ewing via Python-list Sent:Monday, June 19, 2023 7:50:36 PM To:python-list at python.org Subject:Re: Should NoneType be iterable? I would question the wisdom of designing an API that can return either a sequence or None. If it normally returns a sequence, and there are no items to return, it should return an empty sequence. -- Gre -- https://mail.python.org/mailman/listinfo/python-list Get Outlook for iOS ________________________________ From: Python-list on behalf of Cebtenzzre via Python-list Sent: Thursday, June 22, 2023 10:59:19 AM To: python-list at python.org Subject: Re: pip install -e does not build shared libraries It turns out that this is a scikit-build issue: https://github.com/scikit-build/scikit-build/issues/740 https://github.com/scikit-build/scikit-build/issues/939 https://github.com/scikit-build/scikit-build/issues/981 -- https://mail.python.org/mailman/listinfo/python-list From diegofpsouza at gmail.com Thu Jun 22 22:14:05 2023 From: diegofpsouza at gmail.com (Diego Souza) Date: Thu, 22 Jun 2023 23:14:05 -0300 Subject: TKinter in Python - advanced notions In-Reply-To: References: <95ce080b-eb2d-4fbf-b20a-8589c8bd57f4n@googlegroups.com> Message-ID: Have you considered improving the architecture itself, not your GUI library skills? I recommend you look at the Model View ViewModel (MVVM) concept and implement something similar (this is largely used in the Android framework nowadays). This would separate your program logic from the rendering and visualization. It would also make your program more reactive, decoupled, and easier to maintain. When you mentioned threads I immediately thought of this because it is much easier to implement parallel jobs and present results back in the GUI, as everything becomes reactive. This is overkill for a small project such as the code you showed, but I recommend it for larger projects. On Wed, Jun 21, 2023 at 7:20?PM aapost via Python-list < python-list at python.org> wrote: > On 6/21/23 09:47, Dan Kolis wrote: > > I've write a huge biotech program ( an IDE for synthetic biology ), and > am slowly outgrowing TKINTER. > > > > Has anybody out there merged a little bit of TCL direct calls from > Python 3.X to get more freedom then TKINTER for just some Windows ? > > > I wish it looked better, but its 'ok'. I believe X11 IO is considerably > superior for serious work the HTML. I mean 'serious' work. with lots of > multi media windows. I am not talking about fb "Oh ! There is a window it > opened inthe corner !"... trivial functionality. > > > I don't know if it would help, but you can extend/add tcl/tk packages > > I don't remember the full instructions right off, but quickly reverse > engineering my old stuff I think you just need to drop them in > /usr/share/tcltk/ or equivalent. > > (I needed to do that to replace the terrible looking default file dialog > for unix/linux with fsdialog.) > > then running something like the following from your Tk object > > self.eval('package require fsdialog') > > (reverse engineering the python tkinter source you can likely find other > ways of doing more tcl direct stuff) > > I have not researched if there are some better, more featured > (non-buggy) Text widgets implemented in tcl that can be dropped in, (I > know several of the tcl drop in widgets I tried were lacking in > refinement). > > From what I can tell, once upon a time there were better, more > interesting projects and tutorials on extending tkinter, such as WCK > (tkinter3000), but the only remnants of those remain publicly available > are outdated unmaintained archives. > > You might also consider looking at the Grail browser source for research > purposes, as it does some interesting things with some of the widgets, > (parsing html and such), even though it is 20 years old now (and written > in python 1). > The update attempts from 10+ years ago have disappeared. (it's license > is considered questionable from what I understand, so not sure if that > is an aspect of it, the other being one of it's main features, python > applets, is unsafe and was not easily fixable) > > You might already be beyond some of these things though. > > I know what you mean as far is feeling like the little bit extra you > need pushes beyond what tkinter can do / makes you feel like you have > outgrown the module. > > (I had to take a break from one of my projects and send it to > development hell until my UI knowledge/skills improve after I found > myself considering using xml schema appinfo annotations to store json > formatted widget specific information, lol.) > > I have felt that sense of lack with most of the UI modules I have tried > though. > > I don't know of a clear better python-only solution though that fits my > personal needs. > > So I have to lean toward improving my tcl / C in hopes that it might > help steer me toward that extra (which seems to be in the spirit of what > tcl/tk's intent is to begin with). That will be a while for me though if > I get there. > > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Diego Souza Wespa Intelligent Systems Rio de Janeiro - Brasil From akheckel at uni-bremen.de Fri Jun 23 04:16:31 2023 From: akheckel at uni-bremen.de (Andreas Heckel) Date: Fri, 23 Jun 2023 10:16:31 +0200 Subject: TKinter in Python - advanced notions In-Reply-To: References: <95ce080b-eb2d-4fbf-b20a-8589c8bd57f4n@googlegroups.com> Message-ID: <000801d9a5ab$047c5cb0$0d751610$@uni-bremen.de> Hi, Apologies for potentially mis-using this thread. But I have been struggling recently making exactly this leap from simple GUI examples to a more elaborate MVVM concept. Mainly I have been struggling finding nice example python code bases, that allow some understanding to the beginner, which I certainly still am, but also show enough complexity to see the concept in action. Any hints / links to github or similar highly welcome. If the list is not the appropriate place, I am happy if you email me directly. Cheers, Andreas > -----Original Message----- > From: Python-list > On Behalf Of Diego Souza via Python-list > Sent: Friday, June 23, 2023 4:14 AM > To: aapost > Cc: python-list > Subject: Re: TKinter in Python - advanced notions > > Have you considered improving the architecture itself, not your GUI library > skills? > > I recommend you look at the Model View ViewModel (MVVM) concept and > implement something similar (this is largely used in the Android framework > nowadays). This would separate your program logic from the rendering and > visualization. It would also make your program more reactive, decoupled, > and easier to maintain. When you mentioned threads I immediately thought of > this because it is much easier to implement parallel jobs and present > results back in the GUI, as everything becomes reactive. This is overkill > for a small project such as the code you showed, but I recommend it for > larger projects. > > > > > > On Wed, Jun 21, 2023 at 7:20?PM aapost via Python-list < > python-list at python.org> wrote: > > > On 6/21/23 09:47, Dan Kolis wrote: > > > I've write a huge biotech program ( an IDE for synthetic biology ), and > > am slowly outgrowing TKINTER. > > > > > > Has anybody out there merged a little bit of TCL direct calls from > > Python 3.X to get more freedom then TKINTER for just some Windows ? > > > > > I wish it looked better, but its 'ok'. I believe X11 IO is considerably > > superior for serious work the HTML. I mean 'serious' work. with lots of > > multi media windows. I am not talking about fb "Oh ! There is a window it > > opened inthe corner !"... trivial functionality. > > > > > > I don't know if it would help, but you can extend/add tcl/tk packages > > > > I don't remember the full instructions right off, but quickly reverse > > engineering my old stuff I think you just need to drop them in > > /usr/share/tcltk/ or equivalent. > > > > (I needed to do that to replace the terrible looking default file dialog > > for unix/linux with fsdialog.) > > > > then running something like the following from your Tk object > > > > self.eval('package require fsdialog') > > > > (reverse engineering the python tkinter source you can likely find other > > ways of doing more tcl direct stuff) > > > > I have not researched if there are some better, more featured > > (non-buggy) Text widgets implemented in tcl that can be dropped in, (I > > know several of the tcl drop in widgets I tried were lacking in > > refinement). > > > > From what I can tell, once upon a time there were better, more > > interesting projects and tutorials on extending tkinter, such as WCK > > (tkinter3000), but the only remnants of those remain publicly available > > are outdated unmaintained archives. > > > > You might also consider looking at the Grail browser source for research > > purposes, as it does some interesting things with some of the widgets, > > (parsing html and such), even though it is 20 years old now (and written > > in python 1). > > The update attempts from 10+ years ago have disappeared. (it's license > > is considered questionable from what I understand, so not sure if that > > is an aspect of it, the other being one of it's main features, python > > applets, is unsafe and was not easily fixable) > > > > You might already be beyond some of these things though. > > > > I know what you mean as far is feeling like the little bit extra you > > need pushes beyond what tkinter can do / makes you feel like you have > > outgrown the module. > > > > (I had to take a break from one of my projects and send it to > > development hell until my UI knowledge/skills improve after I found > > myself considering using xml schema appinfo annotations to store json > > formatted widget specific information, lol.) > > > > I have felt that sense of lack with most of the UI modules I have tried > > though. > > > > I don't know of a clear better python-only solution though that fits my > > personal needs. > > > > So I have to lean toward improving my tcl / C in hopes that it might > > help steer me toward that extra (which seems to be in the spirit of what > > tcl/tk's intent is to begin with). That will be a while for me though if > > I get there. > > > > > > > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > > -- > Diego Souza > Wespa Intelligent Systems > Rio de Janeiro - Brasil > -- > https://mail.python.org/mailman/listinfo/python-list From dankolis at gmail.com Fri Jun 23 18:15:34 2023 From: dankolis at gmail.com (Dan Kolis) Date: Fri, 23 Jun 2023 15:15:34 -0700 (PDT) Subject: TKinter in Python - advanced notions In-Reply-To: References: <95ce080b-eb2d-4fbf-b20a-8589c8bd57f4n@googlegroups.com> <000801d9a5ab$047c5cb0$0d751610$@uni-bremen.de> Message-ID: If you have a problem,. ask a super specific question, here. If I can help, I will, but TKINTER knowledge is pretty spread around. Many others migth jump in, too. Its works, its slightly quirky, has no licencing hangups. X11 makes fine fine programs ! Keep hacking,Dan From dankolis at gmail.com Fri Jun 23 18:21:41 2023 From: dankolis at gmail.com (Dan Kolis) Date: Fri, 23 Jun 2023 15:21:41 -0700 (PDT) Subject: TKinter in Python - advanced notions - reactive In-Reply-To: References: <95ce080b-eb2d-4fbf-b20a-8589c8bd57f4n@googlegroups.com> <000801d9a5ab$047c5cb0$0d751610$@uni-bremen.de> Message-ID: <7ca2e928-3712-44cf-839c-2f2fe2b686d6n@googlegroups.com> I am not specifically having any problems implementing what I want to make work. Callbacks etc make it fairly easy to make TKinter react to things without any specific fancy plan for it. Add callbacks for real time changes early in any new notion, after it looks right go to the IO part make it react. Regards, thanks, Dan From list1 at tompassin.net Fri Jun 23 23:34:56 2023 From: list1 at tompassin.net (Thomas Passin) Date: Fri, 23 Jun 2023 23:34:56 -0400 Subject: TKinter in Python - advanced notions In-Reply-To: <000801d9a5ab$047c5cb0$0d751610$@uni-bremen.de> References: <95ce080b-eb2d-4fbf-b20a-8589c8bd57f4n@googlegroups.com> <000801d9a5ab$047c5cb0$0d751610$@uni-bremen.de> Message-ID: On 6/23/2023 4:16 AM, Andreas Heckel via Python-list wrote: > Hi, > > Apologies for potentially mis-using this thread. But I have been struggling recently making exactly this leap from simple GUI examples to a more elaborate MVVM concept. Mainly I have been struggling finding nice example python code bases, that allow some understanding to the beginner, which I certainly still am, but also show enough complexity to see the concept in action. > Any hints / links to github or similar highly welcome. If the list is not the appropriate place, I am happy if you email me directly. > > Cheers, > Andreas > >> -----Original Message----- >> From: Python-list >> On Behalf Of Diego Souza via Python-list >> Sent: Friday, June 23, 2023 4:14 AM >> To: aapost >> Cc: python-list >> Subject: Re: TKinter in Python - advanced notions >> >> Have you considered improving the architecture itself, not your GUI library >> skills? >> >> I recommend you look at the Model View ViewModel (MVVM) concept and >> implement something similar (this is largely used in the Android framework >> nowadays). This would separate your program logic from the rendering and >> visualization. It would also make your program more reactive, decoupled, >> and easier to maintain. When you mentioned threads I immediately thought of >> this because it is much easier to implement parallel jobs and present >> results back in the GUI, as everything becomes reactive. This is overkill >> for a small project such as the code you showed, but I recommend it for >> larger projects. As a general comment (and I have not done anything tricky or complex with Tk), MVC or the other approaches in a similar vein, though good, can lead you into more complexity than you need, because of the extra abstractions involved. Yes, for sure the GUI should not be doing domain or business logic. Yes, it's good to keep database access separate from the other parts of your program. But you may not need all the classes and layers that you think you might. It all depends on what you need to do, of course. Another useful design thought is to try to keep as much of the GUI logic separate from Tk itself as possible. Basically, you would write a more abstract (and simpler) GUI API, and then write an adapter that knows how to make Tk do those things. One advantage is that this approach makes it easier to change to another GUI toolkit later (say PyQt, for example). Another is that it helps you avoid getting sucked into too many Tk details that aren't needed for the program concept. Here is a simple (or simple-minded :) ) example: class AbstractApi: """An abstract class for standardizing access to a display widget.""" def __init__(self, parent): self.parent = parent self.client = None def registerClient(self, client): self.client = client def loadPanel(self, panel_name, html): """Load html into display panel.""" pass def focusPanel(self, panel_name): """Select a named display panel.""" pass def handleSearchText(self): pass def writeStatusBar(self, msg): pass def handleLinkClicked(self, uri, source): """Handle a link clicked in the "source" display panel.""" pass These (let us say for the purposes of illustration) are the only things you need from the GUI. You can write a Tk-specific version of this, and the rest of your program doesn't need to know that Tk is even involved. If you want to change to say GTK, this class is the only thing that would need to change. Even if this approach turns out to be too simple for a really complicated UI, the closer you can come to realizing it the better. >> >> On Wed, Jun 21, 2023 at 7:20?PM aapost via Python-list < >> python-list at python.org> wrote: >> >>> On 6/21/23 09:47, Dan Kolis wrote: >>>> I've write a huge biotech program ( an IDE for synthetic biology ), and >>> am slowly outgrowing TKINTER. >>>> >>>> Has anybody out there merged a little bit of TCL direct calls from >>> Python 3.X to get more freedom then TKINTER for just some Windows ? >>> >>>> I wish it looked better, but its 'ok'. I believe X11 IO is considerably >>> superior for serious work the HTML. I mean 'serious' work. with lots of >>> multi media windows. I am not talking about fb "Oh ! There is a window it >>> opened inthe corner !"... trivial functionality. >>> >>> >>> I don't know if it would help, but you can extend/add tcl/tk packages >>> >>> I don't remember the full instructions right off, but quickly reverse >>> engineering my old stuff I think you just need to drop them in >>> /usr/share/tcltk/ or equivalent. >>> >>> (I needed to do that to replace the terrible looking default file dialog >>> for unix/linux with fsdialog.) >>> >>> then running something like the following from your Tk object >>> >>> self.eval('package require fsdialog') >>> >>> (reverse engineering the python tkinter source you can likely find other >>> ways of doing more tcl direct stuff) >>> >>> I have not researched if there are some better, more featured >>> (non-buggy) Text widgets implemented in tcl that can be dropped in, (I >>> know several of the tcl drop in widgets I tried were lacking in >>> refinement). >>> >>> From what I can tell, once upon a time there were better, more >>> interesting projects and tutorials on extending tkinter, such as WCK >>> (tkinter3000), but the only remnants of those remain publicly available >>> are outdated unmaintained archives. >>> >>> You might also consider looking at the Grail browser source for research >>> purposes, as it does some interesting things with some of the widgets, >>> (parsing html and such), even though it is 20 years old now (and written >>> in python 1). >>> The update attempts from 10+ years ago have disappeared. (it's license >>> is considered questionable from what I understand, so not sure if that >>> is an aspect of it, the other being one of it's main features, python >>> applets, is unsafe and was not easily fixable) >>> >>> You might already be beyond some of these things though. >>> >>> I know what you mean as far is feeling like the little bit extra you >>> need pushes beyond what tkinter can do / makes you feel like you have >>> outgrown the module. >>> >>> (I had to take a break from one of my projects and send it to >>> development hell until my UI knowledge/skills improve after I found >>> myself considering using xml schema appinfo annotations to store json >>> formatted widget specific information, lol.) >>> >>> I have felt that sense of lack with most of the UI modules I have tried >>> though. >>> >>> I don't know of a clear better python-only solution though that fits my >>> personal needs. >>> >>> So I have to lean toward improving my tcl / C in hopes that it might >>> help steer me toward that extra (which seems to be in the spirit of what >>> tcl/tk's intent is to begin with). That will be a while for me though if >>> I get there. >>> >>> >>> >>> >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >>> >> >> >> -- >> Diego Souza >> Wespa Intelligent Systems >> Rio de Janeiro - Brasil >> -- >> https://mail.python.org/mailman/listinfo/python-list > From rosuav at gmail.com Sat Jun 24 02:43:09 2023 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 24 Jun 2023 16:43:09 +1000 Subject: TKinter in Python - advanced notions In-Reply-To: References: <95ce080b-eb2d-4fbf-b20a-8589c8bd57f4n@googlegroups.com> <000801d9a5ab$047c5cb0$0d751610$@uni-bremen.de> Message-ID: On Sat, 24 Jun 2023 at 15:57, Thomas Passin via Python-list wrote: > As a general comment (and I have not done anything tricky or complex > with Tk), MVC or the other approaches in a similar vein, though good, > can lead you into more complexity than you need, because of the extra > abstractions involved. Yes, for sure the GUI should not be doing domain > or business logic. Yes, it's good to keep database access separate from > the other parts of your program. But you may not need all the classes > and layers that you think you might. It all depends on what you need to > do, of course. > > Another useful design thought is to try to keep as much of the GUI logic > separate from Tk itself as possible. Basically, you would write a more > abstract (and simpler) GUI API, and then write an adapter that knows how > to make Tk do those things. One advantage is that this approach makes > it easier to change to another GUI toolkit later (say PyQt, for > example). Another is that it helps you avoid getting sucked into too > many Tk details that aren't needed for the program concept. I'd agree, although what I would call this is a GUI *skeleton*. It's not usually worth trying to isolate that from the actual GUI once you reach production, but it's a great first step as you're building. MVC and other such design patterns are excellent tools for learning and conceptualizing, but I agree, it's not something you have to feel locked into. When talking with students, I'll ask them to show me whether something is part of the model, the view, or the controller, but only to make sure they know what their code is doing. It's not like I would ask them to make three separate files (usually - maybe I'd pitch that to a struggling student as a teaching tool, but not in prod). ChrisA From jsf80238 at gmail.com Sat Jun 24 12:18:29 2023 From: jsf80238 at gmail.com (Jason Friedman) Date: Sat, 24 Jun 2023 10:18:29 -0600 Subject: Trouble with defaults and timeout decorator Message-ID: I'm writing a database connectivity module to be used by other modules and leveraging the jaydebeapi module. >From what I can tell jaydebeapi contains no built-in timeout capability, so then I turned to https://pypi.org/project/timeout-decorator/. My goal is to have a default timeout of, say, 10 seconds, which can be overridden by the caller. import jaydebeapi from timeout_decorator import timeout class Database: database_connection = None database_name, user_name, password, host, port = stuff timeout = None def __init__(self, timeout=10): self.timeout = timeout @timeout(self.timeout) def get_connection(self): if not self.database_connection: self.database_connection = jaydebeapi.connect(some_args) return self.database_connection The trouble occurs on line 12 with: NameError: name 'self' is not defined From python at mrabarnett.plus.com Sat Jun 24 15:03:34 2023 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 24 Jun 2023 20:03:34 +0100 Subject: Trouble with defaults and timeout decorator In-Reply-To: References: Message-ID: On 2023-06-24 17:18, Jason Friedman via Python-list wrote: > I'm writing a database connectivity module to be used by other modules and > leveraging the jaydebeapi module. > From what I can tell jaydebeapi contains no built-in timeout capability, so > then I turned to https://pypi.org/project/timeout-decorator/. > My goal is to have a default timeout of, say, 10 seconds, which can be > overridden by the caller. > > > import jaydebeapi > from timeout_decorator import timeout > > class Database: > database_connection = None > database_name, user_name, password, host, port = stuff > timeout = None > > def __init__(self, timeout=10): > self.timeout = timeout > > @timeout(self.timeout) > def get_connection(self): > if not self.database_connection: > self.database_connection = jaydebeapi.connect(some_args) > return self.database_connection > > > The trouble occurs on line 12 with: > NameError: name 'self' is not defined The decorator is applied when the class is defined, but 'self' exists only in 'Database.__init__' and 'Database.get_connection' when they are called. Have you tried applying the decorator "manually" in 'Database.__init__'? def __init__(self, timeout=10): self.timeout = timeout self.get_connection = timeout(self.timeout)(self.get_connection) From dave.ohlsson at gmail.com Sat Jun 24 13:29:54 2023 From: dave.ohlsson at gmail.com (Dave Ohlsson) Date: Sat, 24 Jun 2023 20:29:54 +0300 Subject: unable to run the basic Embedded Python example Message-ID: I cannot get the simple program https://docs.python.org/3/extending/embedding.html#very-high-level-embedding to work. My environment: * Windows 10 * Microsoft Visual Studio 2019 * Qt Creator 10.0.1 (only as an IDE) * Python not installed This is what I did: 1. I downloaded https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tgz 2. I extracted Python-3.11.4.tgz into C:\temp\Python-3.11.4 3. I opened the "x64 Native Tools Command Prompt for VS 2019" which comes with Microsoft Visual Studio 2019 4. In "x64 Native Tools Command Prompt for VS 2019": ********************************************************************** ** Visual Studio 2019 Developer Command Prompt v16.11.26 ** Copyright (c) 2021 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cd C:\temp\Python-3.11.4\PCbuild C:\temp\Python-3.11.4\PCbuild>build.bat -d // <= option '-d' means "debug" Downloading nuget... [many lines omitted] Build succeeded. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(578,5): warning MSB3073: The command ""C:\Program Files\Git\cmd\git.exe" name-rev --name-only HEAD > "C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gitbranch.txt"" exited with code 128. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(578,5): warning MSB4181: The "Exec" task returned false but did not log an error. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(579,5): warning MSB3073: The command ""C:\Program Files\Git\cmd\git.exe" rev-parse --short HEAD > "C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gitversion.txt"" exited with code 128. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(579,5): warning MSB4181: The "Exec" task returned false but did not log an error. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(580,5): warning MSB3073: The command ""C:\Program Files\Git\cmd\git.exe" describe --all --always --dirty > "C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gittag.txt"" exited with code 128. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(580,5): warning MSB4181: The "Exec" task returned false but did not log an error. 6 Warning(s) 0 Error(s) Time Elapsed 00:00:34.87 C:\temp\Python-3.11.4\PCbuild> 5. I copied the example https://docs.python.org/3/extending/embedding.html#very-high-level-embedding, unchanged, to 'C:\temp\embedded_python\main.c'. 6. I created Qt Creator project file 'C:\temp\embedded_python\ embedded_python.pro': TEMPLATE = app TARGET = embedded_python SOURCES += main.c PYTHON_DIR = C:/temp/Python-3.11.4 INCLUDEPATH += $${PYTHON_DIR}/Include INCLUDEPATH += $${PYTHON_DIR}/PC LIBS += $${PYTHON_DIR}/PCbuild/amd64/python311_d.lib 7. I built the project: 20:02:38: Running steps for project embedded_python... 20:02:38: Starting: "C:\Qt\6.1.3\msvc2019_64\bin\qmake.exe" C:\temp\embedded_python\embedded_python.pro -spec win32-msvc "CONFIG+=debug" "CONFIG-=qml_debug" "CONFIG-=qtquickcompiler" Info: creating stash file C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\.qmake.stash 20:02:38: The process "C:\Qt\6.1.3\msvc2019_64\bin\qmake.exe" exited normally. 20:02:38: Starting: "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" -f C:/temp/build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug/Makefile qmake_all jom 1.1.3 - empower your cores 20:02:38: The process "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited normally. 20:02:38: Starting: "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" C:\Qt\Tools\QtCreator\bin\jom\jom.exe -f Makefile.Debug cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zi -MDd -utf-8 -W3 -w44456 -w44457 -w44458 /Fddebug\embedded_python.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_GUI_LIB -DQT_CORE_LIB -I..\embedded_python -I. -I..\Python-3.11.4\Include -I..\Python-3.11.4\PC -I..\..\Qt\6.1.3\msvc2019_64\include -I..\..\Qt\6.1.3\msvc2019_64\include\QtGui -I..\..\Qt\6.1.3\msvc2019_64\include\QtCore -Idebug -IC:/VulkanSDK/ 1.0.51.0/Include -I..\..\Qt\6.1.3\msvc2019_64\mkspecs\win32-msvc -Fodebug\ @C:\Users\dave\AppData\Local\Temp\main.obj.21168.0.jom main.c ..\embedded_python\main.c(12): warning C4996: 'Py_SetProgramName': deprecated in 3.11 link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\embedded_python.exe @C:\Users\dave\AppData\Local\Temp\embedded_python.exe.21168.484.jom 20:02:39: The process "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited normally. 20:02:39: Elapsed time: 00:01. 8. So far, so good. Next, I tried to run embedded_python.exe. In order for the Python DLL to be available: 8a. I closed Qt Creator. 8b. In the Control Panel, "System", "Advanced system settings", tab "Advanced", "Environment Variables...", I added 'C:\temp\Python-3.11.4\PCbuild\amd64' to variable 'Path' under "User variables for dave". 8c. I restarted Qt Creator. 9. And now, when I ran embedded_python.exe: 20:14:06: Starting C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe... Could not find platform independent libraries Python path configuration: PYTHONHOME = (not set) PYTHONPATH = (not set) program name = 'C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe' isolated = 0 environment = 1 user site = 1 safe_path = 0 import site = 1 is in build tree = 0 stdlib dir = 'C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\Lib' Fatal Python error: failed to get the Python codec of the filesystem encoding sys._base_executable = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug\\embedded_python.exe' sys.base_prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.base_exec_prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.platlibdir = 'DLLs' sys.executable = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug\\embedded_python.exe' sys.prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.exec_prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.path = [ 'C:\\temp\\Python-3.11.4\\PCbuild\\amd64\\python311_d.zip', 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug', 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\Lib', 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings' Current thread 0x00004298 (most recent call first): 20:14:06: C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe exited with code 1 What am I doing wrong? From piergiorgio.sartor.this.should.not.be.used at nexgo.REMOVETHIS.de Sat Jun 24 13:36:55 2023 From: piergiorgio.sartor.this.should.not.be.used at nexgo.REMOVETHIS.de (Piergiorgio Sartor) Date: Sat, 24 Jun 2023 19:36:55 +0200 Subject: Trouble with defaults and timeout decorator In-Reply-To: References: Message-ID: On 24/06/2023 18.18, Jason Friedman wrote: > I'm writing a database connectivity module to be used by other modules and > leveraging the jaydebeapi module. >>From what I can tell jaydebeapi contains no built-in timeout capability, so > then I turned to https://pypi.org/project/timeout-decorator/. > My goal is to have a default timeout of, say, 10 seconds, which can be > overridden by the caller. > > > import jaydebeapi > from timeout_decorator import timeout > > class Database: > database_connection = None > database_name, user_name, password, host, port = stuff > timeout = None > > def __init__(self, timeout=10): > self.timeout = timeout > > @timeout(self.timeout) > def get_connection(self): > if not self.database_connection: > self.database_connection = jaydebeapi.connect(some_args) > return self.database_connection > > > The trouble occurs on line 12 with: > NameError: name 'self' is not defined A quick search would return that "self" is not available in the class body, only in the class methods. There are workarounds, but I guess not simple ones, expecially for "timeout". bye, -- piergiorgio From dankolis at gmail.com Sat Jun 24 15:26:33 2023 From: dankolis at gmail.com (Dan Kolis) Date: Sat, 24 Jun 2023 12:26:33 -0700 (PDT) Subject: TKinter in Python - advanced notions - ok In-Reply-To: References: <95ce080b-eb2d-4fbf-b20a-8589c8bd57f4n@googlegroups.com> <000801d9a5ab$047c5cb0$0d751610$@uni-bremen.de> Message-ID: <966c31b3-41a9-4e5d-9b21-13512ff170ecn@googlegroups.com> Well, its kind of obvious to make a skeleton, copy it in for some basic functionality and modularly ( is that a word ? ) manage each piece. That ( like your example ) is fine stuff. As a side note, I am sure large, large highly generalised programs are pretty hard to make. One thing I do is make each file have a null class like: # Empty object maker ( M T ) ... get it say it ! class MT(): pass # Hook point for this module generally mod = MT() Then, a category of symbols ( mostly 'variables ), grow under mod.(Whatever) # This window gets to exist, and it's exit via op sys clicks mod.ws = sb.make_Tk_Window( "seqdecodeshow" + str( a_Num ), gi.kCONFIGWIN ) This basic notion is that self.(stuff) is not quite multi class enough, yet 'global' is unpopular as a notation, due to name pollution. IN A BIG PROGRAM NOT A LITTLE WEENEY One YOU SCRATCH ON A BLACKBOARD SOMEPLACE !!!!!!!!!!!!!! Generally, The way I proceed is to try to avoid CLASSes in each module, but only a little. If you need it, you sure do. So early on ( like < 100 lines, if you avoided a class, roll back and add it ). Then, mod.(anything) is 'sort of' like self to class, but its politics is the filename that made it alone. If mod. is not used exactly in a class, roll it back to self. If its way more abstractley used, upgrade it to your concept of really global, which generally should be somewhat sparely used. All my TK calls are wrapped in a custom layer, it reduces the line count to 1/3. like so: sb.checkableBoole( cFrmL, 0, 0, gi.us, e_Txt, setting_ClickCb ) sb.textCmdLine( cFrmL, 1, 0, gi.us, 'Apply', applyThoseSelects ) sb.textCmdLine( cFrmL, 1, 1, gi.us, 'Reset', resetSelects ) sb.textCmdLine( cFrmL, 1, 2, gi.us, 'Select all', cbSelectAll ) cFrmL is the TK thing that contains these few text lines, with all the bg colors, whitepace, fonts, managed inside This calls 'grid' of course for placement. But all colors, and callbacks for changes are entirely in called pieces, which have been tested like 150% crazy. sb is import screenBuilder1 as sb # Screen maker for TKinter and TKinter ++ windows If you want to use my 'screenbuilder'... talk to me, I suppose. this is a biology IDE, the screen part is just a little piece of a huge initiative. Obviously, the human being's ideas in there head matter so the TK stuff is important, to say the least Regs, Daniel B. Kolis my ref: 24 Jun 2023, https://groups.google.com/g/comp.lang.python/ From estates at hestates.org Sat Jun 24 20:43:56 2023 From: estates at hestates.org (Fulian Wang) Date: Sun, 25 Jun 2023 00:43:56 +0000 Subject: unable to run the basic Embedded Python example In-Reply-To: References: Message-ID: I study computer science in byu.edu, we choose the 3.4.3 vision. No matter which kind of computers or windows, I needed to download it from Microsoft store. Now I can download it directly from python.org Get Outlook for iOS ________________________________ From: Python-list on behalf of Dave Ohlsson via Python-list Sent: Saturday, June 24, 2023 15:35 To: python-list at python.org Subject: unable to run the basic Embedded Python example I cannot get the simple program https://docs.python.org/3/extending/embedding.html#very-high-level-embedding to work. My environment: * Windows 10 * Microsoft Visual Studio 2019 * Qt Creator 10.0.1 (only as an IDE) * Python not installed This is what I did: 1. I downloaded https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tgz 2. I extracted Python-3.11.4.tgz into C:\temp\Python-3.11.4 3. I opened the "x64 Native Tools Command Prompt for VS 2019" which comes with Microsoft Visual Studio 2019 4. In "x64 Native Tools Command Prompt for VS 2019": ********************************************************************** ** Visual Studio 2019 Developer Command Prompt v16.11.26 ** Copyright (c) 2021 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cd C:\temp\Python-3.11.4\PCbuild C:\temp\Python-3.11.4\PCbuild>build.bat -d // <= option '-d' means "debug" Downloading nuget... [many lines omitted] Build succeeded. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(578,5): warning MSB3073: The command ""C:\Program Files\Git\cmd\git.exe" name-rev --name-only HEAD > "C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gitbranch.txt"" exited with code 128. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(578,5): warning MSB4181: The "Exec" task returned false but did not log an error. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(579,5): warning MSB3073: The command ""C:\Program Files\Git\cmd\git.exe" rev-parse --short HEAD > "C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gitversion.txt"" exited with code 128. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(579,5): warning MSB4181: The "Exec" task returned false but did not log an error. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(580,5): warning MSB3073: The command ""C:\Program Files\Git\cmd\git.exe" describe --all --always --dirty > "C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gittag.txt"" exited with code 128. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(580,5): warning MSB4181: The "Exec" task returned false but did not log an error. 6 Warning(s) 0 Error(s) Time Elapsed 00:00:34.87 C:\temp\Python-3.11.4\PCbuild> 5. I copied the example https://docs.python.org/3/extending/embedding.html#very-high-level-embedding, unchanged, to 'C:\temp\embedded_python\main.c'. 6. I created Qt Creator project file 'C:\temp\embedded_python\ embedded_python.pro': TEMPLATE = app TARGET = embedded_python SOURCES += main.c PYTHON_DIR = C:/temp/Python-3.11.4 INCLUDEPATH += $${PYTHON_DIR}/Include INCLUDEPATH += $${PYTHON_DIR}/PC LIBS += $${PYTHON_DIR}/PCbuild/amd64/python311_d.lib 7. I built the project: 20:02:38: Running steps for project embedded_python... 20:02:38: Starting: "C:\Qt\6.1.3\msvc2019_64\bin\qmake.exe" C:\temp\embedded_python\embedded_python.pro -spec win32-msvc "CONFIG+=debug" "CONFIG-=qml_debug" "CONFIG-=qtquickcompiler" Info: creating stash file C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\.qmake.stash 20:02:38: The process "C:\Qt\6.1.3\msvc2019_64\bin\qmake.exe" exited normally. 20:02:38: Starting: "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" -f C:/temp/build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug/Makefile qmake_all jom 1.1.3 - empower your cores 20:02:38: The process "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited normally. 20:02:38: Starting: "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" C:\Qt\Tools\QtCreator\bin\jom\jom.exe -f Makefile.Debug cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zi -MDd -utf-8 -W3 -w44456 -w44457 -w44458 /Fddebug\embedded_python.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_GUI_LIB -DQT_CORE_LIB -I..\embedded_python -I. -I..\Python-3.11.4\Include -I..\Python-3.11.4\PC -I..\..\Qt\6.1.3\msvc2019_64\include -I..\..\Qt\6.1.3\msvc2019_64\include\QtGui -I..\..\Qt\6.1.3\msvc2019_64\include\QtCore -Idebug -IC:/VulkanSDK/ 1.0.51.0/Include -I..\..\Qt\6.1.3\msvc2019_64\mkspecs\win32-msvc -Fodebug\ @C:\Users\dave\AppData\Local\Temp\main.obj.21168.0.jom main.c ..\embedded_python\main.c(12): warning C4996: 'Py_SetProgramName': deprecated in 3.11 link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\embedded_python.exe @C:\Users\dave\AppData\Local\Temp\embedded_python.exe.21168.484.jom 20:02:39: The process "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited normally. 20:02:39: Elapsed time: 00:01. 8. So far, so good. Next, I tried to run embedded_python.exe. In order for the Python DLL to be available: 8a. I closed Qt Creator. 8b. In the Control Panel, "System", "Advanced system settings", tab "Advanced", "Environment Variables...", I added 'C:\temp\Python-3.11.4\PCbuild\amd64' to variable 'Path' under "User variables for dave". 8c. I restarted Qt Creator. 9. And now, when I ran embedded_python.exe: 20:14:06: Starting C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe... Could not find platform independent libraries Python path configuration: PYTHONHOME = (not set) PYTHONPATH = (not set) program name = 'C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe' isolated = 0 environment = 1 user site = 1 safe_path = 0 import site = 1 is in build tree = 0 stdlib dir = 'C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\Lib' Fatal Python error: failed to get the Python codec of the filesystem encoding sys._base_executable = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug\\embedded_python.exe' sys.base_prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.base_exec_prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.platlibdir = 'DLLs' sys.executable = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug\\embedded_python.exe' sys.prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.exec_prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.path = [ 'C:\\temp\\Python-3.11.4\\PCbuild\\amd64\\python311_d.zip', 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug', 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\Lib', 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings' Current thread 0x00004298 (most recent call first): 20:14:06: C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe exited with code 1 What am I doing wrong? -- https://mail.python.org/mailman/listinfo/python-list From estates at hestates.org Sat Jun 24 20:49:58 2023 From: estates at hestates.org (Fulian Wang) Date: Sun, 25 Jun 2023 00:49:58 +0000 Subject: unable to run the basic Embedded Python example In-Reply-To: References: Message-ID: Forgot to try it or not in an Apple computer, but there?s one or two apple computers in my home when I just began to learn computer science. I should try it. Because I remembered clearly, I tried it on others. Get Outlook for iOS ________________________________ From: Fulian Wang Sent: Saturday, June 24, 2023 7:43:56 PM To: Dave Ohlsson ; python-list at python.org Subject: Re: unable to run the basic Embedded Python example I study computer science in byu.edu, we choose the 3.4.3 vision. No matter which kind of computers or windows, I needed to download it from Microsoft store. Now I can download it directly from python.org Get Outlook for iOS ________________________________ From: Python-list on behalf of Dave Ohlsson via Python-list Sent: Saturday, June 24, 2023 15:35 To: python-list at python.org Subject: unable to run the basic Embedded Python example I cannot get the simple program https://docs.python.org/3/extending/embedding.html#very-high-level-embedding to work. My environment: * Windows 10 * Microsoft Visual Studio 2019 * Qt Creator 10.0.1 (only as an IDE) * Python not installed This is what I did: 1. I downloaded https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tgz 2. I extracted Python-3.11.4.tgz into C:\temp\Python-3.11.4 3. I opened the "x64 Native Tools Command Prompt for VS 2019" which comes with Microsoft Visual Studio 2019 4. In "x64 Native Tools Command Prompt for VS 2019": ********************************************************************** ** Visual Studio 2019 Developer Command Prompt v16.11.26 ** Copyright (c) 2021 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>cd C:\temp\Python-3.11.4\PCbuild C:\temp\Python-3.11.4\PCbuild>build.bat -d // <= option '-d' means "debug" Downloading nuget... [many lines omitted] Build succeeded. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(578,5): warning MSB3073: The command ""C:\Program Files\Git\cmd\git.exe" name-rev --name-only HEAD > "C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gitbranch.txt"" exited with code 128. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(578,5): warning MSB4181: The "Exec" task returned false but did not log an error. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(579,5): warning MSB3073: The command ""C:\Program Files\Git\cmd\git.exe" rev-parse --short HEAD > "C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gitversion.txt"" exited with code 128. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(579,5): warning MSB4181: The "Exec" task returned false but did not log an error. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(580,5): warning MSB3073: The command ""C:\Program Files\Git\cmd\git.exe" describe --all --always --dirty > "C:\temp\Python-3.11.4\PCbuild\obj\311amd64_Debug\pythoncore\gittag.txt"" exited with code 128. C:\temp\Python-3.11.4\PCbuild\pythoncore.vcxproj(580,5): warning MSB4181: The "Exec" task returned false but did not log an error. 6 Warning(s) 0 Error(s) Time Elapsed 00:00:34.87 C:\temp\Python-3.11.4\PCbuild> 5. I copied the example https://docs.python.org/3/extending/embedding.html#very-high-level-embedding, unchanged, to 'C:\temp\embedded_python\main.c'. 6. I created Qt Creator project file 'C:\temp\embedded_python\ embedded_python.pro': TEMPLATE = app TARGET = embedded_python SOURCES += main.c PYTHON_DIR = C:/temp/Python-3.11.4 INCLUDEPATH += $${PYTHON_DIR}/Include INCLUDEPATH += $${PYTHON_DIR}/PC LIBS += $${PYTHON_DIR}/PCbuild/amd64/python311_d.lib 7. I built the project: 20:02:38: Running steps for project embedded_python... 20:02:38: Starting: "C:\Qt\6.1.3\msvc2019_64\bin\qmake.exe" C:\temp\embedded_python\embedded_python.pro -spec win32-msvc "CONFIG+=debug" "CONFIG-=qml_debug" "CONFIG-=qtquickcompiler" Info: creating stash file C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\.qmake.stash 20:02:38: The process "C:\Qt\6.1.3\msvc2019_64\bin\qmake.exe" exited normally. 20:02:38: Starting: "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" -f C:/temp/build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug/Makefile qmake_all jom 1.1.3 - empower your cores 20:02:38: The process "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited normally. 20:02:38: Starting: "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" C:\Qt\Tools\QtCreator\bin\jom\jom.exe -f Makefile.Debug cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zi -MDd -utf-8 -W3 -w44456 -w44457 -w44458 /Fddebug\embedded_python.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DQT_GUI_LIB -DQT_CORE_LIB -I..\embedded_python -I. -I..\Python-3.11.4\Include -I..\Python-3.11.4\PC -I..\..\Qt\6.1.3\msvc2019_64\include -I..\..\Qt\6.1.3\msvc2019_64\include\QtGui -I..\..\Qt\6.1.3\msvc2019_64\include\QtCore -Idebug -IC:/VulkanSDK/ 1.0.51.0/Include -I..\..\Qt\6.1.3\msvc2019_64\mkspecs\win32-msvc -Fodebug\ @C:\Users\dave\AppData\Local\Temp\main.obj.21168.0.jom main.c ..\embedded_python\main.c(12): warning C4996: 'Py_SetProgramName': deprecated in 3.11 link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\embedded_python.exe @C:\Users\dave\AppData\Local\Temp\embedded_python.exe.21168.484.jom 20:02:39: The process "C:\Qt\Tools\QtCreator\bin\jom\jom.exe" exited normally. 20:02:39: Elapsed time: 00:01. 8. So far, so good. Next, I tried to run embedded_python.exe. In order for the Python DLL to be available: 8a. I closed Qt Creator. 8b. In the Control Panel, "System", "Advanced system settings", tab "Advanced", "Environment Variables...", I added 'C:\temp\Python-3.11.4\PCbuild\amd64' to variable 'Path' under "User variables for dave". 8c. I restarted Qt Creator. 9. And now, when I ran embedded_python.exe: 20:14:06: Starting C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe... Could not find platform independent libraries Python path configuration: PYTHONHOME = (not set) PYTHONPATH = (not set) program name = 'C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe' isolated = 0 environment = 1 user site = 1 safe_path = 0 import site = 1 is in build tree = 0 stdlib dir = 'C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\Lib' Fatal Python error: failed to get the Python codec of the filesystem encoding sys._base_executable = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug\\embedded_python.exe' sys.base_prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.base_exec_prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.platlibdir = 'DLLs' sys.executable = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug\\embedded_python.exe' sys.prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.exec_prefix = 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug' sys.path = [ 'C:\\temp\\Python-3.11.4\\PCbuild\\amd64\\python311_d.zip', 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug', 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\Lib', 'C:\\temp\\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\\debug', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings' Current thread 0x00004298 (most recent call first): 20:14:06: C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe exited with code 1 What am I doing wrong? -- https://mail.python.org/mailman/listinfo/python-list From auriocus at gmx.de Mon Jun 26 01:49:07 2023 From: auriocus at gmx.de (Christian Gollwitzer) Date: Mon, 26 Jun 2023 07:49:07 +0200 Subject: unable to run the basic Embedded Python example In-Reply-To: References: Message-ID: Hi Dave, I can tell you where the error comes from, but I don't know how to fix it correctly: Am 24.06.23 um 19:29 schrieb Dave Ohlsson: > 9. And now, when I ran embedded_python.exe: > > 20:14:06: Starting > C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe... > Could not find platform independent libraries > Python path configuration: > PYTHONHOME = (not set) > PYTHONPATH = (not set) > program name = Python consists of the DLL that you have lined it with plus a large number of files (standard library) which contain, e.g., the encoding data and builtin functions etc. It needs to find these in order to run. You could set PYTHONHOME as an environment variable to point to that folder. If you don't use the regular Pyton installer, then you need to install these files yourself. Maybe there is also a way to set it from the C code. Christian From ma.waxdesign at gmail.com Mon Jun 26 13:46:33 2023 From: ma.waxdesign at gmail.com (small marcc) Date: Mon, 26 Jun 2023 10:46:33 -0700 (PDT) Subject: my excel file is not updated to add new data Message-ID: pandas.ExcelWriter import pandas This code creates the path to the Excel file where the data will be written. It checks if the file already exists, and if so, reads the existing data into a DataFrame. Otherwise, it creates a new empty DataFrame. Then it concatenates the existing data with the new data and writes the result to the Excel file. Finally, it displays a message that the backup was successful and closes the information window. I do not understand why it does not work, the new data is not displayed in excel when I am in python tkinter, my data in python must be displayed in excel. I use the following code to write data to an excel file using pandas: please help meHowever, when I run this code, the new data is not showing in the excel file. I don't understand why this isn't working. Can you help me solve this problem? data = {'Numero du client': [numero_du_client], 'Pr?nom': [prenom], 'Nom': [nom], 'Adresse': [adresse], 'Numero de t?l?phone': [numero_de_tel], 'Longueur de cour': [longueur_de_cour], 'Largeur de cour': [largeur_de_cour], "Unite(p ou m)":[boutonPieds, boutonMetres] #edit "Prix_coutant:[prix_coutant], #new add he asks me to define when I haven't done for others "Prix soumission":[prix_soumission], # new add he asks me to define when I haven't done for others "MargeProfit":[marge_profit]} # new dd he asks me to define when I haven't done for others #my link with live excel valid for any move as long as the script and excel are in the same folder chemin_script = os.path.abspath(__file__) dossier_script = os.path.dirname(chemin_script) nom_fichier_excel = "testpython.xlsx" chemin_fichier_excel = os.path.join(dossier_script, nom_fichier_excel) df = pd.DataFrame(data) if os.path.exists(chemin_fichier_excel): df_existant = pd.read_excel(chemin_fichier_excel) else: df_existant = pd.DataFrame() df_concat = pd.concat([df_existant, df], ignore_index=True) df_concat.to_excel(chemin_fichier_excel, index=False) with pd.ExcelWriter(path, engine='xlsxwriter') as writer: df.to_excel(writer, index=False, sheet_name='Clients') print("sauvegarde reussi") fenetre_info.destroy() From list1 at tompassin.net Mon Jun 26 14:20:03 2023 From: list1 at tompassin.net (Thomas Passin) Date: Mon, 26 Jun 2023 14:20:03 -0400 Subject: my excel file is not updated to add new data In-Reply-To: References: Message-ID: <2ea47a65-f209-6658-4d60-0add3415ad35@tompassin.net> On 6/26/2023 1:46 PM, small marcc via Python-list wrote: > pandas.ExcelWriter > > import pandas > > This code creates the path to the Excel file where the data will be written. It checks if the file already exists, and if so, reads the existing data into a DataFrame. Otherwise, it creates a new empty DataFrame. Then it concatenates the existing data with the new data and writes the result to the Excel file. Finally, it displays a message that the backup was successful and closes the information window. > > I do not understand why it does not work, the new data is not displayed in excel when I am in python tkinter, my data in python must be displayed in excel. > I use the following code to write data to an excel file using pandas: > > please help meHowever, when I run this code, the new data is not showing in the excel file. Do you meant the modified data is not displayed in a linked Excel window, or that the Excel file itself does not get changed? > I don't understand why this isn't working. Can you help me solve this problem? > > data = {'Numero du client': [numero_du_client], > 'Pr?nom': [prenom], > 'Nom': [nom], > 'Adresse': [adresse], > 'Numero de t?l?phone': [numero_de_tel], > 'Longueur de cour': [longueur_de_cour], > 'Largeur de cour': [largeur_de_cour], > "Unite(p ou m)":[boutonPieds, boutonMetres] #edit > "Prix_coutant:[prix_coutant], #new add he asks me to define when I haven't done for others > "Prix soumission":[prix_soumission], # new add he asks me to define when I haven't done for others > "MargeProfit":[marge_profit]} # new dd he asks me to define when I haven't done for others > > > #my link with live excel valid for any move as long as the script and excel are in the same folder > > > chemin_script = os.path.abspath(__file__) > dossier_script = os.path.dirname(chemin_script) > nom_fichier_excel = "testpython.xlsx" > chemin_fichier_excel = os.path.join(dossier_script, nom_fichier_excel) > df = pd.DataFrame(data) > if os.path.exists(chemin_fichier_excel): > df_existant = pd.read_excel(chemin_fichier_excel) > else: > df_existant = pd.DataFrame() > df_concat = pd.concat([df_existant, df], ignore_index=True) > df_concat.to_excel(chemin_fichier_excel, index=False) > with pd.ExcelWriter(path, engine='xlsxwriter') as writer: > df.to_excel(writer, index=False, sheet_name='Clients') > print("sauvegarde reussi") > fenetre_info.destroy() > From PythonList at DancesWithMice.info Mon Jun 26 19:54:33 2023 From: PythonList at DancesWithMice.info (dn) Date: Tue, 27 Jun 2023 11:54:33 +1200 Subject: my excel file is not updated to add new data In-Reply-To: References: Message-ID: Marc, Apologies for writing in English (the language of this Discussion List). I have attempted to keep the code in French... Thanks for this question. If it's OK with you, I would like to use it as an example-problem (and 'solution') challenge for some future Python Users' Group meeting (suitably translated, etc)... On 27/06/2023 05.46, small marcc via Python-list wrote: > This code creates the path to the Excel file where the data will be written. It checks if the file already exists, and if so, reads the existing data into a DataFrame. Otherwise, it creates a new empty DataFrame. Then it concatenates the existing data with the new data and writes the result to the Excel file. Finally, it displays a message that the backup was successful and closes the information window. > > I do not understand why it does not work, the new data is not displayed in excel when I am in python tkinter, my data in python must be displayed in excel. > I use the following code to write data to an excel file using pandas: > > please help meHowever, when I run this code, the new data is not showing in the excel file. I don't understand why this isn't working. Can you help me solve this problem? Is this a Python problem, or a problem with the way the solution has been coded? There are several steps in the solution-description. It is troubling (to both of us) that you are unable to locate the source of the error. Why? Because it is not noticed until the final stage "new data is not displayed"! NB am ignoring that the line defining "df" and everything thereafter, appears to be incorrectly indented - when viewed in my email-client. That said, the sequence of events seems muddled. Please review the code. Compare it to the verbal/English-language description of the solution. Can each sentence in the solution be easily identified in the code? Words like "and", "otherwise", "then", and "finally" indicate that there are multiple steps in the process. Let's split the separate sentences and phrases: - creates the path to the Excel file where the data will be written - checks if the file already exists [establish DataFrame] - if so, reads the existing data into a DataFrame - Otherwise, it creates a new empty DataFrame - concatenates the existing data with the new data - writes the result to the Excel file - displays a message that the backup was successful - closes the information window. NB addition of a task-label summarising the two DataFrame alternative situations. Now, we can outline the Python code by writing a bunch of function definitions: def create_data_path(): def check_for_file(): def establish_data_frame(): def read_existing_data(): def create_new_data_frame(): def accept_new_data(): def save_to_file(): def report(): def terminate(): NB my IDE would grumble and complain if I did this 'for real'. In a 'new code' situation, you may like to add a pass-statement inside each, and vertical-spacing to make the distracting-complaints 'go away'. Alternately and assuming the function-name doesn't say it all, add a docstring (you're going to add one anyway, right?) and expand upon the function-name with some explanation of what the function will do. In this situation, you could add the existing code. NBB the two sub-tasks have been indented here for continuity of flow. They may/may not be nested within establish_data_frame() when you detail the content of each function - not important to this outline. NBBB I've quickly drafted function-names for the sake of this discussion. I find it easier to name things when it is time to use them (in this case, call the function). Fortunately, a competent IDE will facilitate the refactoring of names ("symbols"). Yes, doing it that way costs (me) little extra effort - but it saves straining my brain up-front. That said, investing time in 'designing' a good name, will also tend to clarify and sharpen one's thinking. So, apparently I follow both paths... YMMV! Now that the solution has been outlined, one can consider what output you expect from each function, what input it will require to produce that, and the transformation in-between. For example: def create_data_path( nom_fichier ): * copy existing code into here return chemin_fichier_excel (pausing at the one function, for now...) [for non-French speakers: nom_fichier = file_name chemin_fichier_excel = data path including file-name ] How has this design-process improved things? 1 clearer thinking: we have a simple and more straightforward idea of what should happen 2 "separation of concerns": each function does one job (and should do it well!) 3 testability: we can now ensure that the (each) function performs correctly (in isolation) 4 the problem of locating the source of an error is simplified (in fact, the "testability" advantage may solve this problem - or in a new-design situation, avoid it*) Testing the function is carried-out by calling the function with a variety of example input-data, and ensuring the result is what you expect/want/require. Thus: chemin = create_data_path( "testpython.xlsx" ) assert "chemin\testpython.xlsx" == chemin, "Not equal, but should be" [for non-French speakers: chemin = path ] (an assert statement says: if the condition is False, print an optional message, and raise an exception/stop processing) similarly: chemin = create_data_path( "testpython.xlsx" ) assert "path_to_project\niaiserie.xlsx" != chemin, "Should not be equal" [for non-French speakers: niaiserie = some random name/silliness ] Such tests should not be written as one-off code (the way one might add debug-printing - and then take it out again). If you ever have need to copy such functions into other projects (eg create_data_path(), then you'll want to copy the tests as well, to ensure everything works in the new scenario! Accordingly, create a new .py file, with "test_" plus the name of the existing code-file. Inside that, import the code-file. The code the tests in the test file, to run each function in-turn (and several times, with different data), to assure the function in the code-file. (yes, if you see virtue in this approach, there are some very helpful libraries to ease testing and automate it (better to have the machine do the work, rather than you have to (keep) doing it!), eg pytest (py.test) - worth some investigation time?) What has been achieved? By the time you've tested the first few functions, you will know whether or not existing files are being (correctly) used as 'base data'. Continuing 'down', you will discover if new data is being correctly added/updating existing data. Further on, you will find if the output is being correctly written to that file. Sooner or later, you will have answered the "where is the error?" problem 'here'! You will also have noticed any similar errors which may be 'hiding' in the code, unnoticed (so far!)... (and all without needing to ask someone-else for help) * not entirely true. In this manner, each function can be relatively-well proven with "unit tests". There is however, an additional source of error: do the functions 'play well together'? Ensuring this happens is the objective of another type of test: "integration testing". For example, does check_for_file() work with the output from the preceding stage: create_data_path()? Yes, these sorts of tests could be included at the bottom of the 'unit test' script, or written in a separate test-file... Not forgetting, the "mainline" of the production program[me] needs to be written! It will call each function in-turn, feeding specific data into (at least) the first, eg which Excel file? Thereafter, likely feeding output from earlier functions into later processing. Until, 'the end'. Fin! NB the "mainline" will be a collection and compression of the imperatives which could be copied from any "integration testing". NBB what I call the "mainline" (a throw-back to my training, so long ago it is lost in the mists of time...) fits into a Python idiom: if __name__ == "__main__": print( "\nMy wonderful program\n" ) # you'll do this in the GUI intermediate_result_1 = function1() intermediate_result_1 = function2( intermediate_result_1 ) ... NB it seems long-winded (and my IDE often grumbles about this too!) but I often prefer creating 'intermediate results' rather than writing 'earlier' functions as parameters to 'later' functions. If any thing goes wrong (how could it, after all that testing?) it's easier to answer that famous question: "where is the error?". That said: there are exceptions to every 'rule' - and YMMV! -- Regards, =dn From martin.schoon at gmail.com Fri Jun 30 01:45:14 2023 From: martin.schoon at gmail.com (Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=) Date: 30 Jun 2023 05:45:14 GMT Subject: scipy.optimize.least_squares for more than one dimension? Message-ID: Yesterday I wanted to move from optimize.leastsq to least_squares. I have data depending on four variables and want to fit a function in four variables to this data. This works with leastsq but not with least_squares. Am I trying to do something least_squares is not capable of? Disclaimer: I was burning midnight oil... TIA /Martin From k04jg02 at gmail.com Fri Jun 30 18:35:36 2023 From: k04jg02 at gmail.com (Joseph Garvin) Date: Fri, 30 Jun 2023 17:35:36 -0500 Subject: from __future__ import annotations bug? Message-ID: ``` from __future__ import annotations from typing import Generic, TypeVar T = TypeVar("T") class Foo(Generic[T]): ... class Bar(Foo[Buzz]): ... # NameError here class Buzz: ... ``` This will error, despite the __future__ import, because cpython is trying to look up Buzz before it's defined, even though we have supposedly prevented annotations from being processed. I realize that Class[Args] is allowed in that area in general and isn't always type annotation related, but does this mean that even with PEP 649 that forward references will still be needed? From k04jg02 at gmail.com Fri Jun 30 19:55:19 2023 From: k04jg02 at gmail.com (Joseph Garvin) Date: Fri, 30 Jun 2023 18:55:19 -0500 Subject: from __future__ import annotations bug? In-Reply-To: References: Message-ID: Should mention this also affects Protocol[Buzz] On Fri, Jun 30, 2023, 5:35 PM Joseph Garvin wrote: > ``` > from __future__ import annotations > from typing import Generic, TypeVar > > T = TypeVar("T") > class Foo(Generic[T]): ... > class Bar(Foo[Buzz]): ... # NameError here > class Buzz: ... > ``` > > This will error, despite the __future__ import, because cpython is trying > to look up Buzz before it's defined, even though we have supposedly > prevented annotations from being processed. I realize that Class[Args] is > allowed in that area in general and isn't always type annotation related, > but does this mean that even with PEP 649 that forward references will > still be needed? >