From torriem at gmail.com Wed Jan 1 00:41:42 2025 From: torriem at gmail.com (Michael Torrie) Date: Tue, 31 Dec 2024 22:41:42 -0700 Subject: No module name mutagen In-Reply-To: <2aab58dd-378d-4218-868d-09eda6e8d292@gmail.com> References: <2aab58dd-378d-4218-868d-09eda6e8d292@gmail.com> Message-ID: On Tue, Dec 31, 2024, 17:04 Tim Johnson via Python-list < python-list at python.org> wrote: > I am as of today, getting an import error for mutagen. Mutagen package > is installed at /root/.local/share/pipx/shared/lib/python3.12/site-packages > Pip-installed packages that go to /root/.local are only available when you run Python as root. Your normal user will never pick them up. So I'm not surprised it's not working. and indeed, that is the content of > /root/.local/share/pipx/shared/lib/python3.12/site-packages/pipx_shared.pth > Could you not apt install python3-mutagen? That will be accessible to all users. From hjp-python at hjp.at Wed Jan 1 08:16:34 2025 From: hjp-python at hjp.at (Peter J. Holzer) Date: Wed, 1 Jan 2025 14:16:34 +0100 Subject: No module name mutagen In-Reply-To: <2aab58dd-378d-4218-868d-09eda6e8d292@gmail.com> References: <2aab58dd-378d-4218-868d-09eda6e8d292@gmail.com> Message-ID: <20250101131634.vgrfeetikvq7y7hi@hjp.at> On 2024-12-31 15:00:10 -0900, Tim Johnson via Python-list wrote: > being retired for ten years, I get my butt kicked by python dependencies > every time I upgrade ubuntu. (I'm newly on 24.04) now. > > Now, after three weeks on using the following code correctly: > > from mutagen import mp3, id3, File as mutaFile > from mutagen.id3 import ID3, TIT2, TPE1 > > I am as of today, getting an import error for mutagen. So what changed between the last time it worked and today? Did you upgrade anything, install anything, delete anything, change permissions, etc.? Or maybe just invoke your scripts in a different context (different user, different environment) than before? > Mutagen package is > installed at /root/.local/share/pipx/shared/lib/python3.12/site-packages As Michael already noted, /root is not normally accessible by normal users. So installing stuff into /root/.local is a bad idea unless you only ever want to use it as root (which in the case of an audio metadata library seems unlikely). > Must I be using a virtual environment? I use virtual environments a lot, but that may not be the best option for you. Especially if you mostly writing command line tools and having difficulties with upgrades, it might be a good idea to stick with packages supplied by Ubuntu (I'm guessing that ?24.04? above refers to ?Ubuntu 24.04 LTS?). There are over 5000 of them, so it is very likely that you don't need anything else. This way Ubuntu's package management will take care of all the dependencies. Good reasons to use virtual enviroments (on Linux) include: * You have many different products[1] with different requirements running on several computers and you want to decouple upgrades of your products from upgrades to the hosts' OS. * You need either a package or a specific version not supplied by your distribution. * You can't install packages on the target host. A not so good reason is: * You are not familiar with your distribution's package manager. hp [1] By "product" I mean a collection of software for a common purpose. That might be a collection of scripts, it might be web site, etc. -- _ | 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 thjmmj15 at gmail.com Wed Jan 1 13:56:24 2025 From: thjmmj15 at gmail.com (Tim Johnson) Date: Wed, 1 Jan 2025 09:56:24 -0900 Subject: No module name mutagen In-Reply-To: <2aab58dd-378d-4218-868d-09eda6e8d292@gmail.com> References: <2aab58dd-378d-4218-868d-09eda6e8d292@gmail.com> Message-ID: On 12/31/24 15:00, Tim Johnson wrote: > ..... Snipped > I resolved this by extrapolating known paths of other non-distro pipx installs, and am back in business now. I'm taking lots of notes. For some reason, even after running updatedb, I had no luck finding with locate. I was not aware that mutagen is available through apt. Thanks to you who brought that up. I have noted some other things: Running pipx with the verbose flag gives me more information, and probably would have been enough to not require me to post this thread. *And: *the verbose flag tells me where the logs are. Whoopee! Seems to me it wouldn't be that hard for pipx to print out the full install path, both at install runtime and in the log. Oh well, if I didn't have problems, I would use my pythonisto brain even less and it would atrophy even further. Thanks for all the input. Happy New Year, one and all. :) Tim From aotto1968 at t-online.de Fri Jan 3 17:16:24 2025 From: aotto1968 at t-online.de (aotto1968) Date: Fri, 3 Jan 2025 23:16:24 +0100 Subject: it's a shame... python error over error In-Reply-To: References: Message-ID: On 30.12.24 18:29, Michael Torrie wrote: > On 12/26/24 12:34 AM, aotto1968 via Python-list wrote: >> sorry you don't understand the problem? >> >> > You managed to make a build of Python that attempts to link to a DLL >> >> I never touch the OpenSUSE python. the OpenSUSE python try to use my >> sqalite3. > > The *only* mechanism that would cause the system python binary to try to > load modules and libraries from your local install is your environment > (environment variables). > that is right because MY environment variable point to MY local user stuff. The CORE problem is that OpenSUSE (Linux) python use MY env. If I call a OS feature like "cnf" this should NOT interact with my private user stuff. the OpenSUSE do it right because OpenSUSE use /usr/bin/python in "cnf" BUT the python think to interact with MY env. To make it short: The OS python will NEVER proper work if LOCAL user stuff is used. From rosuav at gmail.com Fri Jan 3 17:25:19 2025 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 4 Jan 2025 09:25:19 +1100 Subject: it's a shame... python error over error In-Reply-To: References: Message-ID: On Sat, 4 Jan 2025 at 09:22, aotto1968 via Python-list wrote: > > On 30.12.24 18:29, Michael Torrie wrote: > > On 12/26/24 12:34 AM, aotto1968 via Python-list wrote: > >> sorry you don't understand the problem? > >> > >> > You managed to make a build of Python that attempts to link to a DLL > >> > >> I never touch the OpenSUSE python. the OpenSUSE python try to use my > >> sqalite3. > > > > The *only* mechanism that would cause the system python binary to try to > > load modules and libraries from your local install is your environment > > (environment variables). > > > > that is right because MY environment variable point to MY local user stuff. > > The CORE problem is that OpenSUSE (Linux) python use MY env. > > If I call a OS feature like "cnf" this should NOT interact with my private user stuff. > > the OpenSUSE do it right because OpenSUSE use /usr/bin/python in "cnf" BUT the > python think to interact with MY env. > > To make it short: The OS python will NEVER proper work if LOCAL user stuff is used. People have tried in vain to explain this to you. You refuse to listen. Go and argue with your OS instead of us; we're not the ones in charge of this. Maybe if you argue enough, you'll start to understand what "make install" does. ChrisA From cl at isbd.net Sat Jan 4 09:31:24 2025 From: cl at isbd.net (Chris Green) Date: Sat, 4 Jan 2025 14:31:24 +0000 Subject: How to manage accented characters in mail header? Message-ID: I have a Python script that filters my incoming E-Mail. It has been working OK (with various updates and improvements) for many years. I now have a minor new problem when handling E-Mail with a From: that has accented characters in it:- From: S?bastien Crignon I use Python mailbox to parse the message:- import mailbox ... ... msg = mailbox.MaildirMessage(sys.stdin.buffer.read()) Then various mailbox methods to get headers etc. I use the following to get the From: address:- str(msg.get('from', "unknown").lower() The result has the part with the accented character wrapped as follows:- From: =?utf-8?B?U8OpYmFzdGllbiBDcmlnbm9u?= I know I have hit this issue before but I can't rememeber the fix. The problem I have now is that searching the above doesn't work as expected. Basically I just need to get rid of the ?utf-8? wrapped bit altogether as I'm only interested in the 'real' address. How can I easily remove the UTF8 section in a way that will work whether or not it's there? -- Chris Green ? From pkpearson at nowhere.invalid Sat Jan 4 10:00:21 2025 From: pkpearson at nowhere.invalid (Peter Pearson) Date: 4 Jan 2025 15:00:21 GMT Subject: How to manage accented characters in mail header? References: Message-ID: On Sat, 4 Jan 2025 14:31:24 +0000, Chris Green wrote: > I have a Python script that filters my incoming E-Mail. It has been > working OK (with various updates and improvements) for many years. > > I now have a minor new problem when handling E-Mail with a From: that > has accented characters in it:- > > From: S?bastien Crignon > > > I use Python mailbox to parse the message:- > > import mailbox > ... > ... > msg = mailbox.MaildirMessage(sys.stdin.buffer.read()) > > Then various mailbox methods to get headers etc. > I use the following to get the From: address:- > > str(msg.get('from', "unknown").lower() > > The result has the part with the accented character wrapped as follows:- > > From: =?utf-8?B?U8OpYmFzdGllbiBDcmlnbm9u?= > > > I know I have hit this issue before but I can't rememeber the fix. The > problem I have now is that searching the above doesn't work as > expected. Basically I just need to get rid of the ?utf-8? wrapped bit > altogether as I'm only interested in the 'real' address. How can I > easily remove the UTF8 section in a way that will work whether or not > it's there? This seemed to work for me: import email.header text, encoding = email.header.decode_header(some_string)[0] -- To email me, substitute nowhere->runbox, invalid->com. From cl at isbd.net Sat Jan 4 14:07:57 2025 From: cl at isbd.net (Chris Green) Date: Sat, 4 Jan 2025 19:07:57 +0000 Subject: How to manage accented characters in mail header? References: Message-ID: Stefan Ram wrote: > Chris Green wrote or quoted: > >From: =?utf-8?B?U8OpYmFzdGllbiBDcmlnbm9u?= > > In Python, when you roll with decode_header from the email.header > module, it spits out a list of parts, where each part is like > a tuple of (decoded string, charset). To smash these decoded > sections into one string, you?ll want to loop through the list, > decode each piece (if it needs it), and then throw them together. > Here?s a straightforward example of how to pull this off: > > from email.header import decode_header > > # Example header > header_example = \ > 'From: =?utf-8?B?U8OpYmFzdGllbiBDcmlnbm9u?= ' > > # Decode the header > decoded_parts = decode_header(header_example) > > # Kick off an empty list for the decoded strings > decoded_strings = [] > > for part, charset in decoded_parts: > if isinstance(part, bytes): > # Decode the bytes to a string using the charset > decoded_string = part.decode(charset or 'utf-8') > else: > # If it?s already a string, just roll with it > decoded_string = part > decoded_strings.append(decoded_string) > > # Join the parts into a single string > final_string = ''.join(decoded_strings) > > print(final_string)# From: S?bastien Crignon > > Breakdown > > decode_header(header_example): This line takes your email header > and breaks it down into a list of tuples. > > Looping through decoded_parts: You check if each part is in > bytes. If it is, you decode it using whatever charset it?s > got (defaulting to 'utf-8' if it?s a little vague). > > Appending Decoded Strings: You toss each decoded part into a list. > > Joining Strings: Finally, you use ''.join(decoded_strings) to glue > all the decoded strings into a single, coherent piece. > > Just a Heads Up > > Keep an eye out for cases where the charset might be None. In those > moments, it?s smart to fall back to 'utf-8' or something safe. > Thanks, I think! :-) Is there a simple[r] way to extract just the 'real' address between the <>, that's all I actually need. I think it has the be the last chunk of the From: doesn't it? -- Chris Green ? From hjp-python at hjp.at Mon Jan 6 14:43:21 2025 From: hjp-python at hjp.at (Peter J. Holzer) Date: Mon, 6 Jan 2025 20:43:21 +0100 Subject: How to manage accented characters in mail header? In-Reply-To: References: Message-ID: <20250106194321.oz27jt37xpuhdssn@hjp.at> On 2025-01-04 19:07:57 +0000, Chris Green via Python-list wrote: > Stefan Ram wrote: > > Chris Green wrote or quoted: > > >From: =?utf-8?B?U8OpYmFzdGllbiBDcmlnbm9u?= > > > Is there a simple[r] way to extract just the 'real' address between > the <>, that's all I actually need. I think it has the be the last > chunk of the From: doesn't it? No, From: (S?bastien Crignon) would also be permissible (properly encoded, of course), and even From: < sebastien (S?bastien) . crignon (Crignon) @ amvs . fr > (although I think the latter is deprecated). And also, there can be more than one address in a From header. To properly extract email addresses from a header, use email.utils.getaddresses(). You don't have to decode the header first. The MIME-encoding is supposed to not interfere with parsing headers for machine-readable information like addresses or message ids. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From vinay_sajip at yahoo.co.uk Tue Jan 7 07:45:52 2025 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Tue, 7 Jan 2025 12:45:52 +0000 (UTC) Subject: ANN: A new version (0.5.4) of python-gnupg has been released. References: <1244613341.7834107.1736253952985.ref@mail.yahoo.com> Message-ID: <1244613341.7834107.1736253952985@mail.yahoo.com> What Changed?============= This is an enhancement and bug-fix release, and all users are encouraged to upgrade. Brief summary: * Fix #242: Handle exceptions in the `on_data` callable. This release [2] has been signed with my code signing key: Vinay Sajip (CODE SIGNING KEY) Fingerprint: CA74 9061 914E AC13 8E66 EADB 9147 B477 339A 9B86 Recent changes to PyPI don't show the GPG signature with the download links. An alternative download source where the signatures are available is at [4]. The source code repository is at [1]. Documentation is available at [5]. As always, your feedback is most welcome (especially bug reports [3], patches and suggestions for improvement, or any other points via this group). Enjoy! Cheers Vinay Sajip [1] https://github.com/vsajip/python-gnupg [2] https://pypi.org/project/python-gnupg/0.5.4 [3] https://github.com/vsajip/python-gnupg/issues [4] https://github.com/vsajip/python-gnupg/releases/ [5] python-gnupg - A Python wrapper for GnuPG From 643-408-1753 at kylheku.com Fri Jan 3 18:12:18 2025 From: 643-408-1753 at kylheku.com (Kaz Kylheku) Date: Fri, 3 Jan 2025 23:12:18 -0000 (UTC) Subject: Add the numbers in a 9x9 multiplication Table References: <0b09b939cdbbe465809a7ec27e30912a@www.novabbs.com> <87seq1fpv9.fsf@tilde.institute> <441f7c9599790e4d83d9910c8d099902@www.novabbs.com> Message-ID: <20250103135542.913@kylheku.com> On 2025-01-03, HenHanna wrote: > On Thu, 2 Jan 2025 10:54:02 +0000, yeti wrote: > >> https://oeis.org/A000537 ? > > Sum of first n cubes; or n-th triangular number squared. > > 0, 1, 9, 36, 100, 225, 441, 784, 1296, 2025, 3025, 4356, 6084, 8281, > 11025, 14400, 18496, 23409, 29241, 36100, 44100, 53361, 64009, 76176, > 90000, 105625, 123201, 142884, 164836, 189225, 216225, 246016, 278784, > 314721, 354025, 396900, 443556, 494209, 549081 > > > > Thank you... It's not obvous to me why > > Sum of (consecutive) cubes would be a Square number. Base case: 1^3 is a square number. Inductive hypothesis: Suppose that the sums of 1^3 through n^3 are a square number. What happens when we add (n+1)^3? In other words: sum{1, n, n^3} = k * k (for some positive integer k) What are we adding to this k * k? (n+1)^3 = n^3 + 3n^2 + 3n + 1 We have to show that adding this forumla to some k * k produces (k + m) * (k + m) for some positive integer m. When we take a k * k square and add m to the edges, we get k^2 + 2km + m^2. In other words, the newly added area beyond the original k^2 consists of two k * m quadrangles and an m^2 square. Thus, it follows that the (n+1)^3 formula must be expressible in this form: 2km + m^2. Each successive cube must be adding area to a previous k*k square to make a larger square, by adding m to the edge, which results in an new additional area of 2km + m^2. (Of course the k and m are different for each new cube.) n^3 + 3n^2 + 3n + 1 = m^2 + 2km For instance, 27 is equal to { k = 3, m = 3 } 3^2 + 2*3*3. On in the n = 7 case, 441 going to 784 (+ 343) we have { k = 21, m = 7 }: 343 = 7*7*7 = 7*7 + 2*21*7 A pattern is emerging that m is the root of the cube; in other words that m = n + 1. Thus: n^3 + 3n^2 + 3n + 1 = (n+1)^2 + 2k(n + 1) n^3 + 3n^2 + 3n + 1 = n^2 + 2n + 1 + 2k(n + 1) Get k by itself: n^3 + 2n^2 + 3n + 1 = 2n + 1 + 2k(n + 1) n^3 + 2n^2 + n + 1 = 1 + 2k(n + 1) n^3 + 2n^2 + n = 2k(n + 1) n^3 + 2n^2 + n = 2k ------ n + 1 We need to do long polynomial division to work out this fraction on the left: n^2 + n _____________________ n + 1 | n^3 + 2n^2 + n + 0 n^2 + n^2 ---------- n^2 + n + 0 n^2 + n --------- 0 + 0 This is the key: the division is exact! 2k = n^2 + n = n(n + 1) k = n(n + 1)/2 which we know is an integer! So we know that each new cube (n+1)^3 is expressible in the form of: m^2 + 2km if we identify k, m as: m = n + 1, and k = n(n + 1)/2 . What we have to show is that k is the correct square value. If k is the correct original square, then we have proved it; because k^2 + 2m is the correct quantity to take the k square to the k + m square. We could use a separate, parallel induction to prove this. Note that the formula k = n(n + 1)/2 is just the summation formula for consecutive integers from 1 to n. We can prove that the successive squares in the squares of these sums: sum(1..1)^2 = 1 sum(1..2)^2 = 3^2 = 9 sum(1..3)^2 = 6^2 = 36 sum(1..4)^2 = 10^2 = 100 So it's obvious by inspection that we have the correct k formula, and we can prove it more formally. Conclusion: Since we have a base case, and true inductive hypothesis, the result holds for all n. The key insights are that 1. the sequence values are the squares of consecutive integer sums; i.e. the squares of successive k-s, where k = n(n+1)/2. 2. each cube value added to the previous sequence value is expressible in the form m^2 + 2km, which has the right shape to preserve the square property, and that with some algebra we can identify m as m = n + 1. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator at mstdn.ca From garyfallidis at gmail.com Tue Jan 7 15:23:49 2025 From: garyfallidis at gmail.com (Eleftherios Garyfallidis) Date: Tue, 7 Jan 2025 15:23:49 -0500 Subject: =?UTF-8?Q?ANN=3A_Happy_2025_with_DIPY_1=2E10=2E0_=F0=9F=92=A5?= Message-ID: Hello and Happy 2025 to all !, We are excited to announce a new release of DIPY: DIPY 1.10.0 ! DIPY 1.10.0 (Friday, 12 December 2024) The release 1.10.0 received contributions from 28 developers (the full release notes are at: https://docs.dipy.org/stable/release_notes/release1.10.html). Thank you all for your contributions and feedback! Please click here to check 1.10.0 API changes. Highlights of 1.10.0 release include: - NF: Patch2Self3 - Memory less denoising for dMRI is now available. - NF: Fiber density and spread from ODF using Bingham distributions method added. - NF: Iteratively reweighted least squares for robust fitting of diffusion models added. - NF: NDC - Neighboring DWI Correlation quality metric added. - NF: DAM - DWI-based tissue classification method added. - NF: New Parallel Backends (Ray, Joblib, Dask) for fitting reconstruction methods added. - RF: Deprecation of Tensorflow support. PyTorch support is now the default. - Transition to Keyword-only arguments (PEP 3102). - Zero-warnings policy (CIs, Compilation, doc generation) adopted. - Adoption of ruff for automatic style enforcement. - Transition to using f-strings. - Citation system updated. It is more uniform and robust. - Multiple Workflows updated. - Multiple DIPY Horizon features updated. - Large documentation update. - Closed 258 issues and merged 187 pull requests. To upgrade or install DIPY Run the following command in your terminal: pip install --upgrade dipy This version of DIPY depends on nibabel (3.0.0+). For visualization you need FURY (0.12.0+). Questions or suggestions? For any questions go to https://dipy.org, or send an e-mail to dipy at python.org We also have an instant messaging service and chat room available at https://gitter.im/dipy/dipy Finally, a new forum is available at https://github.com/dipy/dipy/discussions Have a wonderful time using the new version. In addition, registration for the online DIPY workshop 2025 (March 17-21) is open! The workshop will equip you with the skills and knowledge needed to master the latest techniques and tools in structural and diffusion imaging. See the exquisite program and keynote speakers here . Register today to save a spot! Please support us by citing DIPY in your papers using the following DOI: 10.3389/fninf.2014.00008 On behalf of the DIPY developers, Eleftherios Garyfallidis, Ariel Rokem, Serge Koudoro https://dipy.org/contributors From info at egenix.com Thu Jan 9 06:42:00 2025 From: info at egenix.com (eGenix Team) Date: Thu, 9 Jan 2025 12:42:00 +0100 Subject: =?UTF-8?Q?ANN=3A_Python_Meeting_D=C3=BCsseldorf_-_22=2E01=2E2025?= Message-ID: <6e7d71f5-9ca4-4835-839c-7dd339700ca4@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 - Januar 2025 Ein Treffen von Python Enthusiasten und Interessierten in ungezwungener Atmosph?re. *22.01.2025, 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: * Daniel Schmitz: /*Maintaining SciPy: Large scale Open Source in practice */ * Arkadius Schuchhardt: /*Erfahrungen mit Reflex */ * Marc-Andr? Lemburg: /*Programming hardware displays the easy way - using MicroPython and LVGL */ * Jochen Wersd?rfer: /*Skip the Overhead: Lean Web Development with Django */ * Klaus Bremer: /*Server Side Events (SSE) with htmx and async frameworks*/ 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 *?? 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, Jan 09 2025) >>> 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 thjmmj15 at gmail.com Fri Jan 10 14:15:50 2025 From: thjmmj15 at gmail.com (Tim Johnson) Date: Fri, 10 Jan 2025 10:15:50 -0900 Subject: subprocess.Popen does not launch audacity Message-ID: <735b7965-c16c-45a7-a2b8-d9ff1adc21ba@gmail.com> Using Python 3.12.3 on Ubuntu 24.04 I've converted a legacy python2 script to python3. All went well. However, a glitch from python2 remains. The script uses dmenu to create menus to pick applications. Applications are then invoked from python using subprocess.Popen(). I have never been able to successfully launch audacity using this approach, which does work for other apps. I can launch audacity successfully using dmenu_run (on its own, outside of the script) Below is the pertinent code: ?Popen(choice, stdout=PIPE, stderr=PIPE, ????????????????? stdin=PIPE, close_fds=True) My guess is my argument list is either insufficient or an argument is causing the problem, but am unsure of which. I have been retired from python programming for ten years, and am pretty rusty, but it is still fun. There are plenty of other ways to successfully launch audacity but it would be great to make it work from this script. Thanks in advance Tim From python at mrabarnett.plus.com Fri Jan 10 15:32:08 2025 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 10 Jan 2025 20:32:08 +0000 Subject: subprocess.Popen does not launch audacity In-Reply-To: <735b7965-c16c-45a7-a2b8-d9ff1adc21ba@gmail.com> References: <735b7965-c16c-45a7-a2b8-d9ff1adc21ba@gmail.com> Message-ID: <616dcf1e-4f82-48ed-851c-fe5342f42f40@mrabarnett.plus.com> On 2025-01-10 19:15, Tim Johnson via Python-list wrote: > Using Python 3.12.3 on Ubuntu 24.04 > > I've converted a legacy python2 script to python3. All went well. > However, a glitch from python2 remains. > > The script uses dmenu to create menus to pick applications. Applications > are then invoked from python > > using subprocess.Popen(). I have never been able to successfully launch > audacity using this approach, > > which does work for other apps. > > I can launch audacity successfully using dmenu_run (on its own, outside > of the script) > > Below is the pertinent code: > > ?Popen(choice, stdout=PIPE, stderr=PIPE, > ????????????????? stdin=PIPE, close_fds=True) > > My guess is my argument list is either insufficient or an argument is > causing the problem, but am unsure of which. > > I have been retired from python programming for ten years, and am pretty > rusty, but it is still fun. There are plenty > > of other ways to successfully launch audacity but it would be great to > make it work from this script. > What is the value of 'choice'? You could try printing out the value of 'choice' for one that works and the one that doesn't and then try them again interactively from the Python prompt with the given values. That should eliminate all but the essential code for easier debugging. From thjmmj15 at gmail.com Fri Jan 10 16:00:02 2025 From: thjmmj15 at gmail.com (Tim Johnson) Date: Fri, 10 Jan 2025 12:00:02 -0900 Subject: subprocess.Popen does not launch audacity In-Reply-To: <616dcf1e-4f82-48ed-851c-fe5342f42f40@mrabarnett.plus.com> References: <735b7965-c16c-45a7-a2b8-d9ff1adc21ba@gmail.com> <616dcf1e-4f82-48ed-851c-fe5342f42f40@mrabarnett.plus.com> Message-ID: On 1/10/25 11:32, MRAB via Python-list wrote: >> ,,, snipped >> Below is the pertinent code: >> >> ? ?Popen(choice, stdout=PIPE, stderr=PIPE, >> ? ????????????????? stdin=PIPE, close_fds=True) >> >> My guess is my argument list is either insufficient or an argument is >> causing the problem, but am unsure of which. >> >> I have been retired from python programming for ten years, and am pretty >> rusty, but it is still fun. There are plenty >> >> of other ways to successfully launch audacity but it would be great to >> make it work from this script. >> > > What is the value of 'choice'? > > You could try printing out the value of 'choice' for one that works > and the one that doesn't and then try them again interactively from > the Python prompt with the given values. That should eliminate all but > the essential code for easier debugging. choice is /usr/local/bin/audacity, which is the correct path for audacity on my system. As far as I can see, that string has no hidden bytes. Invoking /usr/local/bin/audacity from the command line launches audacity and so does choosing? with dmenu_run. which -a audacity shows only that item. Maybe I need to isolate the function call and start stripping out parameters. I should have time to do that later today. Thanks From olegsivokon at gmail.com Fri Jan 10 16:39:35 2025 From: olegsivokon at gmail.com (Left Right) Date: Fri, 10 Jan 2025 22:39:35 +0100 Subject: subprocess.Popen does not launch audacity In-Reply-To: References: <735b7965-c16c-45a7-a2b8-d9ff1adc21ba@gmail.com> <616dcf1e-4f82-48ed-851c-fe5342f42f40@mrabarnett.plus.com> Message-ID: I just tried this: >>> import subprocess >>> subprocess.run('which audacity', shell=True) /usr/bin/audacity CompletedProcess(args='which audacity', returncode=0) >>> proc = subprocess.Popen('/usr/bin/audacity', stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, close_fds=True) >>> proc.returncode >>> proc.pid 53308 >>> proc.kill() >>> proc.returncode 0 >>> And I saw the interface of the program... So, in principle, what you tried should work. What happens if in a separate terminal you try: $ ps auxwww | grep audacity? Are there any processes running? If your script fails, what is the error? If it doesn't, can you run this: $strace python ./audacity-test.py where audacity-test.py looks like this: import subprocess proc = subprocess.Popen('/usr/local/bin/audacity', stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, close_fds=True) print(proc.returncode) print(proc.pid) proc.wait() proc.kill() print(proc.returncode) Then, you should see something like: clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f377d83b750) = 53932 close(10) = 0 close(8) = 0 close(6) = 0 close(3) = 0 read(9, "", 50000) = 0 close(9) = 0 write(1, "None\n", 5None ) = 5 write(1, "53932\n", 653932 ) = 6 wait4(53932, (the process id you are waiting for is going to be different of course, but the important part is that you find the clone() call that returns the process id your code is waiting on.) And, if it doesn't look like the above, then show what *does* it look like. On Fri, Jan 10, 2025 at 10:03?PM Tim Johnson via Python-list wrote: > > > On 1/10/25 11:32, MRAB via Python-list wrote: > >> ,,, snipped > > >> Below is the pertinent code: > >> > >> Popen(choice, stdout=PIPE, stderr=PIPE, > >> stdin=PIPE, close_fds=True) > >> > >> My guess is my argument list is either insufficient or an argument is > >> causing the problem, but am unsure of which. > >> > >> I have been retired from python programming for ten years, and am pretty > >> rusty, but it is still fun. There are plenty > >> > >> of other ways to successfully launch audacity but it would be great to > >> make it work from this script. > >> > > > > What is the value of 'choice'? > > > > You could try printing out the value of 'choice' for one that works > > and the one that doesn't and then try them again interactively from > > the Python prompt with the given values. That should eliminate all but > > the essential code for easier debugging. > > choice is /usr/local/bin/audacity, which is the correct path for > audacity on my system. As far as I can see, that string has no hidden bytes. > > Invoking /usr/local/bin/audacity from the command line launches audacity > and so does choosing with dmenu_run. which -a audacity shows only that > item. > > Maybe I need to isolate the function call and start stripping out > parameters. I should have time to do that later today. > > Thanks > > -- > https://mail.python.org/mailman/listinfo/python-list From list1 at tompassin.net Fri Jan 10 16:53:14 2025 From: list1 at tompassin.net (Thomas Passin) Date: Fri, 10 Jan 2025 16:53:14 -0500 Subject: subprocess.Popen does not launch audacity In-Reply-To: References: <735b7965-c16c-45a7-a2b8-d9ff1adc21ba@gmail.com> <616dcf1e-4f82-48ed-851c-fe5342f42f40@mrabarnett.plus.com> Message-ID: <5f5b9fdd-1680-470b-bd09-715e67f145bc@tompassin.net> On 1/10/2025 4:00 PM, Tim Johnson via Python-list wrote: > > On 1/10/25 11:32, MRAB via Python-list wrote: >>> ,,, snipped > >>> Below is the pertinent code: >>> >>> ? ?Popen(choice, stdout=PIPE, stderr=PIPE, >>> ? ????????????????? stdin=PIPE, close_fds=True) >>> >>> My guess is my argument list is either insufficient or an argument is >>> causing the problem, but am unsure of which. >>> >>> I have been retired from python programming for ten years, and am pretty >>> rusty, but it is still fun. There are plenty >>> >>> of other ways to successfully launch audacity but it would be great to >>> make it work from this script. >>> >> >> What is the value of 'choice'? >> >> You could try printing out the value of 'choice' for one that works >> and the one that doesn't and then try them again interactively from >> the Python prompt with the given values. That should eliminate all but >> the essential code for easier debugging. > > choice is /usr/local/bin/audacity, which is the correct path for > audacity on my system. As far as I can see, that string has no hidden > bytes. > > Invoking /usr/local/bin/audacity from the command line launches audacity > and so does choosing? with dmenu_run. which -a audacity shows only that > item. > > Maybe I need to isolate the function call and start stripping out > parameters. I should have time to do that later today. I don't know why you would want to redirect stdin, etc. It's a GUI application. This worked for me in a Python session on EndeavourOS, python 3.13.1: >>> from subprocess import run >>> run('/usr/bin/audacity') From thjmmj15 at gmail.com Fri Jan 10 18:21:21 2025 From: thjmmj15 at gmail.com (Tim Johnson) Date: Fri, 10 Jan 2025 14:21:21 -0900 Subject: subprocess.Popen does not launch audacity In-Reply-To: <5f5b9fdd-1680-470b-bd09-715e67f145bc@tompassin.net> References: <735b7965-c16c-45a7-a2b8-d9ff1adc21ba@gmail.com> <616dcf1e-4f82-48ed-851c-fe5342f42f40@mrabarnett.plus.com> <5f5b9fdd-1680-470b-bd09-715e67f145bc@tompassin.net> Message-ID: On 1/10/25 12:53, Thomas Passin via Python-list wrote: > On 1/10/2025 4:00 PM, Tim Johnson via Python-list wrote: >> >> On 1/10/25 11:32, MRAB via Python-list wrote: >>>> ,,, snipped >> >>>> Below is the pertinent code: >>>> >>>> ? ?Popen(choice, stdout=PIPE, stderr=PIPE, >>>> ? ????????????????? stdin=PIPE, close_fds=True) >>>> >>>> My guess is my argument list is either insufficient or an argument is >>>> causing the problem, but am unsure of which. >>>> >>>> I have been retired from python programming for ten years, and am >>>> pretty >>>> rusty, but it is still fun. There are plenty >>>> >>>> of other ways to successfully launch audacity but it would be great to >>>> make it work from this script. >>>> >>> >>> What is the value of 'choice'? >>> >>> You could try printing out the value of 'choice' for one that works >>> and the one that doesn't and then try them again interactively from >>> the Python prompt with the given values. That should eliminate all >>> but the essential code for easier debugging. >> >> choice is /usr/local/bin/audacity, which is the correct path for >> audacity on my system. As far as I can see, that string has no hidden >> bytes. >> >> Invoking /usr/local/bin/audacity from the command line launches >> audacity and so does choosing? with dmenu_run. which -a audacity >> shows only that item. >> >> Maybe I need to isolate the function call and start stripping out >> parameters. I should have time to do that later today. > > I don't know why you would want to redirect stdin, etc.? It's a GUI > application. > > This worked for me in a Python session on EndeavourOS, python 3.13.1: > > >>> from subprocess import run > >>> run('/usr/bin/audacity') You're right as I suspected. The input files that I am using need a flag field to indicate whether the target is a gui or terminal app. Removing the pipe parameters gave me audacity just fine. Time to roll up my sleeves and get to work adding the relevant code. Beats shoveling snow. :) Thanks everybody. > > From cl at isbd.net Sat Jan 11 09:28:49 2025 From: cl at isbd.net (Chris Green) Date: Sat, 11 Jan 2025 14:28:49 +0000 Subject: Tools to help with text mode (i.e. non-GUI) input Message-ID: <1qba5l-7rcr.ln1@q957.zbmc.eu> I'm looking for Python packages that can help with text mode input, i.e. for use with non-GUI programs that one runs from the command prompt in a terminal window running a bash shell or some such. What I'm specifically after is a way to provide a default value that can be accepted or changed easily and also a way to provide a number of different values to choose from. I.e. for the default sort of input one might see:- Colour? red Hitting return would return 'red' to the program but you could also backspace over the 'red' and enter something else. Maybe even better would be that the 'red' disappears as soon as you hit any key other than return. For the select a value type of input I want something like the above but hitting (say) arrow up and arrow down would change the value displayed by the 'Colour?' prompt and hitting return would accept the chosen value. In addition I want the ability to narrow down the list by entering one or more initial characters, so if you enter 'b' at the Colour? prompt the list of values presented would only include colours starting with 'b' (beige, blue, black, etc.) Are there any packages that offer this sort of thing? I'd prefer ones from the Debian repositories but that's not absolutely necessary. It might also be possible/useful to use the mouse for this. -- Chris Green ? From cl at isbd.net Sat Jan 11 16:54:32 2025 From: cl at isbd.net (Chris Green) Date: Sat, 11 Jan 2025 21:54:32 +0000 Subject: Using pipx for packages as opposed to applications Message-ID: Can one use pipx to wrap the process of creating an independent environment for a python package as opposed to a runnable application? E.g. I want to install and use pksheet but, as it's not available from the Debian repositories, I'll have to install it from PyPi. So I should put it in its own environment. Can pipx help me with this? -- Chris Green ? From PythonList at DancesWithMice.info Sat Jan 11 19:49:03 2025 From: PythonList at DancesWithMice.info (dn) Date: Sun, 12 Jan 2025 13:49:03 +1300 Subject: Tools to help with text mode (i.e. non-GUI) input In-Reply-To: <1qba5l-7rcr.ln1@q957.zbmc.eu> References: <1qba5l-7rcr.ln1@q957.zbmc.eu> Message-ID: On 12/01/25 03:28, Chris Green via Python-list wrote: > I'm looking for Python packages that can help with text mode input, > i.e. for use with non-GUI programs that one runs from the command > prompt in a terminal window running a bash shell or some such. > > What I'm specifically after is a way to provide a default value that > can be accepted or changed easily and also a way to provide a number > of different values to choose from. > > I.e. for the default sort of input one might see:- > > Colour? red > > Hitting return would return 'red' to the program but you could also > backspace over the 'red' and enter something else. Maybe even better > would be that the 'red' disappears as soon as you hit any key other > than return. > > > For the select a value type of input I want something like the above > but hitting (say) arrow up and arrow down would change the value > displayed by the 'Colour?' prompt and hitting return would accept the > chosen value. In addition I want the ability to narrow down the list > by entering one or more initial characters, so if you enter 'b' at the > Colour? prompt the list of values presented would only include colours > starting with 'b' (beige, blue, black, etc.) > > > Are there any packages that offer this sort of thing? I'd prefer ones > from the Debian repositories but that's not absolutely necessary. > > > It might also be possible/useful to use the mouse for this. There must be more choices/combinations of packages to do this. Maybe a good place to start is the Python Prompt Toolkit (https://python-prompt-toolkit.readthedocs.io/en/master/) -- Regards, =dn From olegsivokon at gmail.com Sun Jan 12 05:02:00 2025 From: olegsivokon at gmail.com (Left Right) Date: Sun, 12 Jan 2025 11:02:00 +0100 Subject: Using pipx for packages as opposed to applications In-Reply-To: References: Message-ID: What would be the intended use? If this is for other Debian users, then why not make a Debian package? If it's for yourself, why do you need to automate it? To be fair, I don't see a point in tools like pipx. Have never used it, and cannot imagine a scenario where I'd want to. It seems like there's always a better way to do what this tool alleges to be able to do... Also, you say that you want it in its own environment: then what difference does it make if it's on Debian or anywhere else? If you are distributing a library, it makes sense to incorporate it into the user's infrastructure. Either you do the integration, or let users decide how to best integrate it. If you provide them with the environment that they *must* use, that's going to be the worst of both worlds: users won't be able to use the library in the environment created by them, nor will this library integrate with the other libraries provided by the system. So, it's hard to imagine why your users would want that. On Sun, Jan 12, 2025 at 12:47?AM Chris Green via Python-list wrote: > > Can one use pipx to wrap the process of creating an independent > environment for a python package as opposed to a runnable application? > > E.g. I want to install and use pksheet but, as it's not available from > the Debian repositories, I'll have to install it from PyPi. So I > should put it in its own environment. Can pipx help me with this? > > -- > Chris Green > ? > -- > https://mail.python.org/mailman/listinfo/python-list From ht at inf.ed.ac.uk Mon Jan 13 11:09:36 2025 From: ht at inf.ed.ac.uk (Henry S. Thompson) Date: Mon, 13 Jan 2025 16:09:36 +0000 Subject: Complete working version of cython Queue example? In-Reply-To: (Left Right via Python-list's message of "Sun\, 12 Jan 2025 11\:02\:00 +0100") References: Message-ID: I've spent several days trying to get this example [1] working, using Python3.11 and Cython 3.0.11 of Debian. I've copied the example files as carefully as I can, renamed some to avoid a name clash with the queue.py library, but the Pure Python version throws errors at compile time and although the Cython version compiles, it doesn't work. Before giving details, just checking first if anyone can simply point to a set of files, preferably Pure Python but failing that Cython, that actually work for them. Thanks, ht -- Henry S. Thompson, School of Informatics, University of Edinburgh 10 Crichton Street, Edinburgh EH8 9AB, SCOTLAND e-mail: ht at inf.ed.ac.uk URL: https://www.ltg.ed.ac.uk/~ht/ [mail from me _always_ has a .sig like this -- mail without it is forged spam] From rustbuckett at nope.com Sat Jan 11 21:49:39 2025 From: rustbuckett at nope.com (rustbuckett at nope.com) Date: Sat, 11 Jan 2025 21:49:39 -0500 Subject: Tools to help with text mode (i.e. non-GUI) input References: <1qba5l-7rcr.ln1@q957.zbmc.eu> Message-ID: <87jzb04ugs.fsf@pm.me> This is what I was going to suggest. Rich is super easy to use. From cl at isbd.net Sun Jan 12 07:11:22 2025 From: cl at isbd.net (Chris Green) Date: Sun, 12 Jan 2025 12:11:22 +0000 Subject: Using pipx for packages as opposed to applications References: Message-ID: Stefan Ram wrote: > Chris Green wrote or quoted: > >E.g. I want to install and use pksheet but, as it's not available from > >the Debian repositories, I'll have to install it from PyPi. > > I can't dig up any "pksheet" on PyPI. So, you got to take > my earlier response like a rumor from a random tech meetup in > Palo Alto - sounds interesting, but needs serious verification. > Ah, oops, a typo. It's pysheet (I have pk on the brain from it being Point Kilometrique, distance markers on canals in France). Thanks for your previous response, it told me what I needed to know, that pipx isn't really going to do what I want particularly easily. If I DIY an environment for pysheet and then develop some python that uses it, how do I then make it accessible as a 'normal' program? This is just for my own use by the way, on (probably) just a couple of Linux systems. -- Chris Green ? From cl at isbd.net Sun Jan 12 07:03:37 2025 From: cl at isbd.net (Chris Green) Date: Sun, 12 Jan 2025 12:03:37 +0000 Subject: Tools to help with text mode (i.e. non-GUI) input References: <1qba5l-7rcr.ln1@q957.zbmc.eu> <87jzb04ugs.fsf@pm.me> Message-ID: rustbuckett at nope.com wrote: > > This is what I was going to suggest. Rich is super easy to use. OK, thanks, Rich is on my shortlist then. -- Chris Green ? From list1 at tompassin.net Mon Jan 13 13:15:49 2025 From: list1 at tompassin.net (Thomas Passin) Date: Mon, 13 Jan 2025 13:15:49 -0500 Subject: Using pipx for packages as opposed to applications In-Reply-To: References: Message-ID: On 1/12/2025 7:11 AM, Chris Green via Python-list wrote: > Stefan Ram wrote: >> Chris Green wrote or quoted: >>> E.g. I want to install and use pksheet but, as it's not available from >>> the Debian repositories, I'll have to install it from PyPi. >> >> I can't dig up any "pksheet" on PyPI. So, you got to take >> my earlier response like a rumor from a random tech meetup in >> Palo Alto - sounds interesting, but needs serious verification. >> > Ah, oops, a typo. It's pysheet (I have pk on the brain from it being > Point Kilometrique, distance markers on canals in France). > > Thanks for your previous response, it told me what I needed to know, > that pipx isn't really going to do what I want particularly easily. > > > If I DIY an environment for pysheet and then develop some python that > uses it, how do I then make it accessible as a 'normal' program? This > is just for my own use by the way, on (probably) just a couple of > Linux systems. Create a launch script that sets the environmental variables and launches the program. From ht at inf.ed.ac.uk Mon Jan 13 14:58:45 2025 From: ht at inf.ed.ac.uk (Henry S. Thompson) Date: Mon, 13 Jan 2025 19:58:45 +0000 Subject: Complete working version of cython Queue example? In-Reply-To: (Henry S. Thompson via Python-list's message of "Mon\, 13 Jan 2025 16\:09\:36 +0000") References: Message-ID: [with link] Henry S. Thompson via Python-list writes: > I've spent several days trying to get this example [1] working, using > Python3.11 and Cython 3.0.11 of Debian. > > I've copied the example files as carefully as I can, renamed some to > avoid a name clash with the queue.py library, but the Pure Python > version throws errors at compile time and although the Cython version > compiles, it doesn't work. > > Before giving details, just checking first if anyone can simply point > to a set of files, preferably Pure Python but failing that Cython, > that actually work for them. > > Thanks, > > ht [1] https://cython.readthedocs.io/en/stable/src/tutorial/clibraries.html -- Henry S. Thompson, School of Informatics, University of Edinburgh 10 Crichton Street, Edinburgh EH8 9AB, SCOTLAND e-mail: ht at inf.ed.ac.uk URL: https://www.ltg.ed.ac.uk/~ht/ [mail from me _always_ has a .sig like this -- mail without it is forged spam] From list1 at tompassin.net Mon Jan 13 13:18:50 2025 From: list1 at tompassin.net (Thomas Passin) Date: Mon, 13 Jan 2025 13:18:50 -0500 Subject: Complete working version of cython Queue example? In-Reply-To: References: Message-ID: On 1/13/2025 11:09 AM, Henry S. Thompson via Python-list wrote: > I've spent several days trying to get this example [1] working, using > Python3.11 and Cython 3.0.11 of Debian. > > I've copied the example files as carefully as I can, renamed some to > avoid a name clash with the queue.py library, but the Pure Python > version throws errors at compile time and although the Cython version > compiles, it doesn't work. > > Before giving details, just checking first if anyone can simply point > to a set of files, preferably Pure Python but failing that Cython, > that actually work for them. Your reference [1] is missing from your post. If it was an attachment, this list doesn't do attachments. From learn2program at gmail.com Mon Jan 13 17:46:19 2025 From: learn2program at gmail.com (Alan Gauld) Date: Mon, 13 Jan 2025 22:46:19 +0000 Subject: Tools to help with text mode (i.e. non-GUI) input In-Reply-To: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> Message-ID: <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> On 11/01/2025 14:28, Chris Green via Python-list wrote: > I'm looking for Python packages that can help with text mode input, The standard package for this is curses which comes as part of the standard library on *nix distros. > What I'm specifically after is a way to provide a default value that > can be accepted or changed easily and also a way to provide a number > of different values to choose from. The default value is easy. The list of values sounds like a pop-up menu. Ofr you can just offer a prompt with a list in it that the user picks(maybe by number?) Its really a programmers choice, curses provides the tools to display it however you choose. (Yu might also find the dialog third party package useful for displaying text mode dialog boxes) > I.e. for the default sort of input one might see:- > > Colour? red > > Hitting return would return 'red' to the program but you could also > backspace over the 'red' and enter something else. Maybe even better > would be that the 'red' disappears as soon as you hit any key other > than return. All of that is possible in curses, you just have to code it. > For the select a value type of input I want something like the above > but hitting (say) arrow up and arrow down would change the value > displayed by the 'Colour?' prompt and hitting return would accept the > chosen value. Again that's easy enough to do. Or you could pop up a menu and allow the user to cursor up/dowmn (or use the mouse) to select an option. > In addition I want the ability to narrow down the list > by entering one or more initial characters, so if you enter 'b' at the > Colour? prompt the list of values presented would only include colours > starting with 'b' (beige, blue, black, etc.) Again that's more about the programmer's use of the tools. curses allows you to display the characters wherever/however you want on screen. > Are there any packages that offer this sort of thing? I'd prefer ones > from the Debian repositories but that's not absolutely necessary. > It might also be possible/useful to use the mouse for this. curses dores all you want but you need to do all the logic, its not as simple as using a GUI toolkit. dialog sits on top of curses and provides a more GUI like experiece. urwin is another toolkit for text mode but it is more of a pseudo GUI environment with a menu-bar, dialogs, forms etc etc. Curses is about mapping areas of the screen(windows) and displaying text within those areas. You can control colour and strength etc, move things around, hide/show areas, position the cursor anywhere on screen. You can even create huge virtual screens and use the visible screen as a viewport into that(think like a big spreadsheet) There are a couple of Howto type documents online Shameless Plug: --------- I wrote a short kindle book on curses with python: https://kdp.amazon.com/amazon-dp-action/us/dualbookshelf.marketplacelink/B091B85B77 ------------- HTH -- 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 grant.b.edwards at gmail.com Mon Jan 13 19:20:57 2025 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Mon, 13 Jan 2025 19:20:57 -0500 (EST) Subject: Tools to help with text mode (i.e. non-GUI) input References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> Message-ID: <4YX8tK2xv4znb1c@mail.python.org> On 2025-01-13, Alan Gauld via Python-list wrote: > All of that is possible in curses, you just have to code it. All of that is easy with curses in C. Unfortunately, the high level "panel" and "menu" curses subystems that make it easy aren't included in the Python curses API, so doing it in Pyhton is a _lot_ more work than doing it in C. I always like the Python API for the newt library (yonks ago it was used for the Redhat installer), but haven't used it for years. From learn2program at gmail.com Tue Jan 14 03:56:14 2025 From: learn2program at gmail.com (Alan Gauld) Date: Tue, 14 Jan 2025 08:56:14 +0000 Subject: Tools to help with text mode (i.e. non-GUI) input In-Reply-To: <4YX8tK2xv4znb1c@mail.python.org> References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> <4YX8tK2xv4znb1c@mail.python.org> Message-ID: <0c3821d3-78c1-45c0-81da-81f9fb4c4f02@yahoo.co.uk> On 14/01/2025 00:20, Grant Edwards via Python-list wrote: > On 2025-01-13, Alan Gauld via Python-list wrote: > >> All of that is possible in curses, you just have to code it. > > All of that is easy with curses in C. Unfortunately, the high level > "panel" and "menu" curses subystems that make it easy aren't included > in the Python curses API, panel is included. Just import curses.panel. menu unfortunately isn't but it's not difficult to roll your own by creating a window with a list of options, provided you don't try to get too fancy(submenus etc). -- 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 grant.b.edwards at gmail.com Tue Jan 14 09:21:41 2025 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Tue, 14 Jan 2025 09:21:41 -0500 (EST) Subject: Tools to help with text mode (i.e. non-GUI) input References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> <4YX8tK2xv4znb1c@mail.python.org> <0c3821d3-78c1-45c0-81da-81f9fb4c4f02@yahoo.co.uk> Message-ID: <4YXWXP3qnBznVGW@mail.python.org> On 2025-01-14, Alan Gauld via Python-list wrote: > On 14/01/2025 00:20, Grant Edwards via Python-list wrote: >> On 2025-01-13, Alan Gauld via Python-list wrote: >> >>> All of that is possible in curses, you just have to code it. >> >> All of that is easy with curses in C. Unfortunately, the high level >> "panel" and "menu" curses subystems that make it easy aren't included >> in the Python curses API, > > panel is included. Just import curses.panel. Ah my bad, I meant "forms" and "menu" support was missing. > menu unfortunately isn't but it's not difficult to roll your own by > creating a window with a list of options, provided you don't try to > get too fancy(submenus etc). Yea, it was "menu" and "forms" that I really wanted. -- Grant From rocstr at gmail.com Tue Jan 14 00:47:17 2025 From: rocstr at gmail.com (roc str) Date: Mon, 13 Jan 2025 21:47:17 -0800 Subject: Installing Python-3.10.16 Message-ID: having a difficult time installing Python-3.10.16.tgz using the Python-3.20.0a2.exe installer. Please Advise Mario Ramos. From cl at isbd.net Tue Jan 14 04:15:01 2025 From: cl at isbd.net (Chris Green) Date: Tue, 14 Jan 2025 09:15:01 +0000 Subject: Tools to help with text mode (i.e. non-GUI) input References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> <4YX8tK2xv4znb1c@mail.python.org> <0c3821d3-78c1-45c0-81da-81f9fb4c4f02@yahoo.co.uk> Message-ID: Alan Gauld wrote: > On 14/01/2025 00:20, Grant Edwards via Python-list wrote: > > On 2025-01-13, Alan Gauld via Python-list wrote: > > > >> All of that is possible in curses, you just have to code it. > > > > All of that is easy with curses in C. Unfortunately, the high level > > "panel" and "menu" curses subystems that make it easy aren't included > > in the Python curses API, > > panel is included. Just import curses.panel. > > menu unfortunately isn't but it's not difficult to roll > your own by creating a window with a list of options, provided > you don't try to get too fancy(submenus etc). > Yes, thanks all, maybe just straightforward curses is the way to go. Looking at some of the 'cleverer' ones they end up looking remarkably like GUI code, in which case I might as well use a GUI. I have written a (fairly simple) Gtk based python program, I was just trying to avoid all the GUI overheads for a little new project. -- Chris Green ? From cl at isbd.net Tue Jan 14 06:32:35 2025 From: cl at isbd.net (Chris Green) Date: Tue, 14 Jan 2025 11:32:35 +0000 Subject: Strategies for avoiding having to use --break-system-packages with pip Message-ID: I have a (relatively) clean Debian 12 installation running on my two workhorse systems, a desktop server at home and my laptop that travels around with me. I moved from Xubuntu to Debian on both these systems a few months ago. I ran Xubuntu for many years and acquired a whole lot of python packages installed with pip, as root. For the last couple of years I had to use the --break-system-packages option to get things installed. As far as I'm aware I never hit any dependency problems doing this. It's probably because things I installed with pip were mostly quite small, specialised, packages that I used in just one or two utility programs that I had written myself. In quite a few cases these were realated to image processing and such things. So far I've managed to keep my Debian 12 installations 'pip free', I haven't even got pip installed. However I may have just come across something that would at least be very useful and it comes from PyPi. (It's tkintertable if that's of any interest or relevance) What are my options? Just install it using pip as root and --break-system-packages, what's likely to break? Use a virtual environment, what do I have to do then to make using my program (that uses tkintertable) 'transparent', i.e. I just want to be able to run the program from the command prompt like any other program. Download tkintertable from git into my development environment and use that. My PYTHONPATH will need to point to it but I can't see any further issues with doing this. Anything else? As far as I can see using pipx doesn't help me at all (see recent thread here). -- Chris Green ? From mats at wichmann.us Tue Jan 14 10:53:01 2025 From: mats at wichmann.us (Mats Wichmann) Date: Tue, 14 Jan 2025 08:53:01 -0700 Subject: Installing Python-3.10.16 In-Reply-To: References: Message-ID: <9bc28a22-5f52-45fc-8705-91fcabfaf45d@wichmann.us> On 1/13/25 22:47, roc str via Python-list wrote: > having a difficult time installing Python-3.10.16.tgz using > the Python-3.20.0a2.exe installer. > > Please Advise > Mario Ramos. Your question doesn't exactly make sense, but note this: Windows installers are not built for "security bugfix" releases. The last python.org release in the 3.10 series that had installers was 3.10.11; subsequent 3.10 releases only consist of the source code (this pattern repeats for all Python release series, once they hit a certain age the move to source-only security bugfix releases, normally when there are two newer Python series available which would contain those fixes already). You have to download the source release and build it yourself if you need this. You can't install a source release using an installer for a different version. There are some instructions here: https://devguide.python.org/getting-started/setup-building/index.html but note that they're oriented to building from a revision control checkout, not from a source release bundle. There should be some instructions somewhere on the internet if buildi-for-windows-from-a-source-release really is exactly what you need. From mats at wichmann.us Tue Jan 14 11:06:06 2025 From: mats at wichmann.us (Mats Wichmann) Date: Tue, 14 Jan 2025 09:06:06 -0700 Subject: Strategies for avoiding having to use --break-system-packages with pip In-Reply-To: References: Message-ID: <8c110143-0ecd-445b-84bb-d46b0254bbfb@wichmann.us> On 1/14/25 04:32, Chris Green via Python-list wrote: > I have a (relatively) clean Debian 12 installation running on my two > workhorse systems, a desktop server at home and my laptop that travels > around with me. > > I moved from Xubuntu to Debian on both these systems a few months ago. > > I ran Xubuntu for many years and acquired a whole lot of python > packages installed with pip, as root. For the last couple of years I > had to use the --break-system-packages option to get things installed. > > As far as I'm aware I never hit any dependency problems doing this. > It's probably because things I installed with pip were mostly quite > small, specialised, packages that I used in just one or two utility > programs that I had written myself. In quite a few cases these were > realated to image processing and such things. > > > So far I've managed to keep my Debian 12 installations 'pip free', I > haven't even got pip installed. However I may have just come across > something that would at least be very useful and it comes from PyPi. > (It's tkintertable if that's of any interest or relevance) > > > What are my options? > > Just install it using pip as root and --break-system-packages, > what's likely to break? > > Use a virtual environment, what do I have to do then to make using > my program (that uses tkintertable) 'transparent', i.e. I just > want to be able to run the program from the command prompt like > any other program. > > Download tkintertable from git into my development environment and > use that. My PYTHONPATH will need to point to it but I can't see > any further issues with doing this. > > Anything else? As far as I can see using pipx doesn't help me at > all (see recent thread here). You might look at uv, which makes the managing of a virtualenv for your program pretty transparent. You declare your dependencies, and then just: uv run myscript.py And of course if you don't want to type three words to launch, you can put those in an executable shell script in your path, and invoke it with a single command. There was a nice article on this somewhere which I now can't find, but the project docs cover the topics pretty well: https://docs.astral.sh/uv/guides/scripts From c.buhtz at posteo.jp Tue Jan 14 11:09:16 2025 From: c.buhtz at posteo.jp (c.buhtz at posteo.jp) Date: Tue, 14 Jan 2025 16:09:16 +0000 Subject: Strategies for avoiding having to use --break-system-packages with pip In-Reply-To: References: Message-ID: Hello Chris, I do have similar "problems" and still try to get used to the "new way". Other might correct me. I am not sure yet. To my current understanding the way to go is to install Python applications via "pipx". That make the application available in your system but also isolate it in its own virtual environment. Of course you should prefer to install applications from your GNU/Linux distros official repository if available. If you install a Python package (library, not an application) you should create your own Python environment via venv for example. Pipx is not intended to install Python packages that are not applications. Regrads, Christian From hugo at python.org Tue Jan 14 11:35:54 2025 From: hugo at python.org (Hugo van Kemenade) Date: Tue, 14 Jan 2025 18:35:54 +0200 Subject: Python 3.14.0 alpha 4 is out Message-ID: Hello, three dot fourteen dot zero alpha four! https://www.python.org/downloads/release/python-3140a4/ This is an early developer preview of Python 3.14. Python 3.14 is still in development. This release, 3.14.0a4, is the fourth of seven planned alpha releases. Alpha releases are intended to make it easier to test the current state of new features and bug fixes and to test the release process. During the alpha phase, features may be added up until the start of the beta phase (2025-05-06) and, if necessary, may be modified or deleted up until the release candidate phase (2025-07-22). Please keep in mind that this is a preview release and its use is not recommended for production environments. Many new features for Python 3.14 are still being planned and written. Among the new major new features and changes so far: * PEP 649: deferred evaluation of annotations * PEP 741: Python configuration C API * PEP 761: Python 3.14 and onwards no longer provides PGP signatures for release artifacts. Instead, Sigstore is recommended for verifiers. * Improved error messages * Removals of old deprecations, and new deprecations, many scheduled for removal from Python 3.16 * C API removals and deprecations * (Hey, fellow core developer, if a feature you find important is missing from this list, let Hugo know.) The next pre-release of Python 3.14 will be 3.14.0a5, currently scheduled for 2025-02-11. More resources: * Online documentation: https://docs.python.org/3.14/ * PEP 745, 3.14 Release Schedule: https://peps.python.org/pep-0745/ * Report bugs at https://github.com/python/cpython/issues * Help fund Python and its community: https://www.python.org/psf/donations/ And now for something completely different In Python, you can use Greek letters as constants. For example: ``` from math import pi as ? def circumference(radius: float) -> float: return 2 * ? * radius print(circumference(6378.137)) # 40075.016685578485 ``` Enjoy the new release. 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 organisation contributions to the Python Software Foundation. Regards from a slushy, slippery Helsinki, Your release team, Hugo van Kemenade Ned Deily Steve Dower ?ukasz Langa From list1 at tompassin.net Tue Jan 14 11:36:34 2025 From: list1 at tompassin.net (Thomas Passin) Date: Tue, 14 Jan 2025 11:36:34 -0500 Subject: Strategies for avoiding having to use --break-system-packages with pip In-Reply-To: References: Message-ID: On 1/14/2025 6:32 AM, Chris Green via Python-list wrote: > I have a (relatively) clean Debian 12 installation running on my two > workhorse systems, a desktop server at home and my laptop that travels > around with me. > > I moved from Xubuntu to Debian on both these systems a few months ago. > > I ran Xubuntu for many years and acquired a whole lot of python > packages installed with pip, as root. For the last couple of years I > had to use the --break-system-packages option to get things installed. > > As far as I'm aware I never hit any dependency problems doing this. > It's probably because things I installed with pip were mostly quite > small, specialised, packages that I used in just one or two utility > programs that I had written myself. In quite a few cases these were > realated to image processing and such things. > > > So far I've managed to keep my Debian 12 installations 'pip free', I > haven't even got pip installed. However I may have just come across > something that would at least be very useful and it comes from PyPi. > (It's tkintertable if that's of any interest or relevance) > > > What are my options? > > Just install it using pip as root and --break-system-packages, > what's likely to break? You can also install with --user and --break-system-packages, but that doesn't really solve the problem. Also, as just happened to me, if an upgrade happens to change the system's python to a newer version (e.g., 3.12.x to 3.13.y), you would have to install all your packages again with the new Python install. > Use a virtual environment, what do I have to do then to make using > my program (that uses tkintertable) 'transparent', i.e. I just > want to be able to run the program from the command prompt like > any other program. You can write a shell script that activates the venv and then launches your program. This works pretty well. > Download tkintertable from git into my development environment and > use that. My PYTHONPATH will need to point to it but I can't see > any further issues with doing this. This is an approach I use sometimes, mainly if I have cloned a project. I run the project's program(s) using a script that sets the PYTHONPATH. > Anything else? As far as I can see using pipx doesn't help me at > all (see recent thread here). To completely avoid problems when the system's Python install gets changed, you can install your own Python version outside of the package manager; it doesn't have to be the same version as the system's. I've done this when I wanted to run a later version of Python than the system's. You would have to take care of updating it yourself since the package manager won't know about it. On the system where I did this, I ran the system's python version using "python3" and my own using "python3.11" (I think the system was still on 3.8 or 3.9). From olegsivokon at gmail.com Tue Jan 14 14:06:39 2025 From: olegsivokon at gmail.com (Left Right) Date: Tue, 14 Jan 2025 20:06:39 +0100 Subject: Strategies for avoiding having to use --break-system-packages with pip In-Reply-To: References: Message-ID: I wouldn't trust pip to install anything into my system. It's not a reliable program that I'd recommend anyone to use for things that they might depend on. My typical course of action is to create a virtual environment for the package I need. Install the package into that virtual environment using pip or w/e the package wants to be installed with. Investigate and refine the dependencies I need (It's very common in the Python world to incorrectly specify dependencies, to require a lot of unnecessary dependencies, to depend on packages in the wrong way). And after I've figured out what exactly I need to get the package to work, copy the dependencies together with the package to the platlib directory of Python I'm using for this task. If platlib happens to be in the system directories or anywhere else: I wouldn't care about that. In the process of installing the program, I would've learned about the nature and the layout of dependencies, so that I could make informed decisions about what goes where and whether anything is needed or is in danger of being affected by system updates or endangers system updates. So far, this has worked every time. This worked for me personally, for small companies that do internal deployments and for big companies that distribute Python together with the entire Linux distribution in this way. The key ingredient is to know what you are doing and to be able to anticipate the bad things. Tools like pip take away from the users the need to know what they are doing in hopes of reducing complexity on the part of the users' knowledge necessary to accomplish program installation. However, there's no free lunch, and tools like pip bring an extra layer of complexity in trying to do what they claim. This layer of complexity is usually revealed when these tools fail to do what they claim, and users are forced to learn what they actually need to know and, on top of that, how to troubleshoot programs like pip. >From working in infra / automation, I get the knowledge about program / package installation "free" on the job, so, I don't see a point in using a tool that automates that for me beyond what I already described. I'm probably also biased because of that, but I still think that learning to do the thing is more important than learning how to use the tool that does the thing. On Tue, Jan 14, 2025 at 4:42?PM Chris Green via Python-list wrote: > > I have a (relatively) clean Debian 12 installation running on my two > workhorse systems, a desktop server at home and my laptop that travels > around with me. > > I moved from Xubuntu to Debian on both these systems a few months ago. > > I ran Xubuntu for many years and acquired a whole lot of python > packages installed with pip, as root. For the last couple of years I > had to use the --break-system-packages option to get things installed. > > As far as I'm aware I never hit any dependency problems doing this. > It's probably because things I installed with pip were mostly quite > small, specialised, packages that I used in just one or two utility > programs that I had written myself. In quite a few cases these were > realated to image processing and such things. > > > So far I've managed to keep my Debian 12 installations 'pip free', I > haven't even got pip installed. However I may have just come across > something that would at least be very useful and it comes from PyPi. > (It's tkintertable if that's of any interest or relevance) > > > What are my options? > > Just install it using pip as root and --break-system-packages, > what's likely to break? > > Use a virtual environment, what do I have to do then to make using > my program (that uses tkintertable) 'transparent', i.e. I just > want to be able to run the program from the command prompt like > any other program. > > Download tkintertable from git into my development environment and > use that. My PYTHONPATH will need to point to it but I can't see > any further issues with doing this. > > Anything else? As far as I can see using pipx doesn't help me at > all (see recent thread here). > > -- > Chris Green > ? > -- > https://mail.python.org/mailman/listinfo/python-list From grant.b.edwards at gmail.com Tue Jan 14 19:54:09 2025 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Tue, 14 Jan 2025 19:54:09 -0500 (EST) Subject: Tools to help with text mode (i.e. non-GUI) input References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> <4YX8tK2xv4znb1c@mail.python.org> <0c3821d3-78c1-45c0-81da-81f9fb4c4f02@yahoo.co.uk> Message-ID: <4YXnZ9475vznWGk@mail.python.org> On 2025-01-14, Chris Green via Python-list wrote: > Yes, thanks all, maybe just straightforward curses is the way to go. > Looking at some of the 'cleverer' ones they end up looking remarkably > like GUI code, in which case I might as well use a GUI. The source code to configure and handle a UI with a certain set of input widgets is going to be pretty much the same regardless of the low-level screen bashing details involved in rendering the widgets. You choose a TUI toolkit like curses panel/menu/forms instead of a GUI toolkit like gtk because you need your app to run on a terminal instead of on a X11/wayland screen, not because you want your app to be simpler than the code for a GUI app (as you've seen, it isn't). > I have written a (fairly simple) Gtk based python program, I was > just trying to avoid all the GUI overheads for a little new project. If you want to avoid the [TG]UI overhead, then command line options are your friend. If that's not sophisticated enough the gnu "readline" library with a simple command processor is a common next step. Or you can use curses to print some help stuff at the top of the terminal window and then do everything based on single-stroke "command keys" that print output in the lower part of the terminal window. -- Grant From mk1853387 at gmail.com Wed Jan 15 12:40:43 2025 From: mk1853387 at gmail.com (marc nicole) Date: Wed, 15 Jan 2025 18:40:43 +0100 Subject: How to weight terms based on semantic importance Message-ID: Hello, I want to weight terms of a large text based on their semantics (not on their frequency (TF-IDF)). Is there a way to do that using NLTK or other means? through a vectorizer? For example: a certain term weights more than others etc... Thanks From learn2program at gmail.com Wed Jan 15 20:06:07 2025 From: learn2program at gmail.com (Alan Gauld) Date: Thu, 16 Jan 2025 01:06:07 +0000 Subject: Tools to help with text mode (i.e. non-GUI) input In-Reply-To: <4YXnZ9475vznWGk@mail.python.org> References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> <4YX8tK2xv4znb1c@mail.python.org> <0c3821d3-78c1-45c0-81da-81f9fb4c4f02@yahoo.co.uk> <4YXnZ9475vznWGk@mail.python.org> Message-ID: <18c5dc35-ea6a-4611-b331-be97e924b322@yahoo.co.uk> On 15/01/2025 00:54, Grant Edwards via Python-list wrote: > are your friend. If that's not sophisticated enough the gnu "readline" > library with a simple command processor is a common next step. On that front the cmd module in Python is often overlooked but is useful for structuring a non-GUI-like text UI. It doesn't support mouse or screen mapping or colours etc. But if all you want/need is a pdb type interface it works well. -- 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 roel at roelschroeven.net Thu Jan 16 04:09:36 2025 From: roel at roelschroeven.net (Roel Schroeven) Date: Thu, 16 Jan 2025 10:09:36 +0100 Subject: Tools to help with text mode (i.e. non-GUI) input In-Reply-To: <1qba5l-7rcr.ln1@q957.zbmc.eu> References: <1qba5l-7rcr.ln1@q957.zbmc.eu> Message-ID: Op 11/01/2025 om 15:28 schreef Chris Green via Python-list: > I'm looking for Python packages that can help with text mode input, > i.e. for use with non-GUI programs that one runs from the command > prompt in a terminal window running a bash shell or some such. > > What I'm specifically after is a way to provide a default value that > can be accepted or changed easily and also a way to provide a number > of different values to choose from. > > I.e. for the default sort of input one might see:- > > Colour? red > > Hitting return would return 'red' to the program but you could also > backspace over the 'red' and enter something else. Maybe even better > would be that the 'red' disappears as soon as you hit any key other > than return. > > > For the select a value type of input I want something like the above > but hitting (say) arrow up and arrow down would change the value > displayed by the 'Colour?' prompt and hitting return would accept the > chosen value. In addition I want the ability to narrow down the list > by entering one or more initial characters, so if you enter 'b' at the > Colour? prompt the list of values presented would only include colours > starting with 'b' (beige, blue, black, etc.) > > > Are there any packages that offer this sort of thing? I'd prefer ones > from the Debian repositories but that's not absolutely necessary. Maybe pythondialog could be useful for this. I've never used it so I can't really tell if it will fit your requirements, but at least it seems worth a look. It looks like it supports text input with a default value (https://pythondialog.sourceforge.io/doc/widgets.html#single-line-input-fields). The other thing you describe is, if I understand correctly, an input with predefined values but also the ability to enter a custom value. At first sight that doesn't seem to be provided. PyPI page: https://pypi.org/project/pythondialog/ Home page: https://pythondialog.sourceforge.io/ -- "Let everything happen to you Beauty and terror Just keep going No feeling is final" -- Rainer Maria Rilke From Keith.S.Thompson+u at gmail.com Tue Jan 14 19:41:51 2025 From: Keith.S.Thompson+u at gmail.com (Keith Thompson) Date: Tue, 14 Jan 2025 16:41:51 -0800 Subject: Tools to help with text mode (i.e. non-GUI) input References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> Message-ID: <87plko9acw.fsf@nosuchdomain.example.com> Alan Gauld writes: > On 11/01/2025 14:28, Chris Green via Python-list wrote: >> I'm looking for Python packages that can help with text mode input, > > The standard package for this is curses which comes as part > of the standard library on *nix distros. The thing about curses (which may or may not be a problem) is that, by design, it takes over the whole screen. If you want to do simpler text manipulations (showing a dismissible message, showing bold text, etc.) without interfering with existing text, curses can't do it, at least not easily. If your terminal supports it, your current screen contents can be restored after the application finishes (curses enables the "alternate screen" and then restores the primary screen on exit). There don't seem to be a lot of good solutions for doing curses-like text manipulation without taking over the entire screen. [...] -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u at gmail.com void Void(void) { Void(); } /* The recursive call of the void */ From kammamuri at libero.it Wed Jan 15 13:31:34 2025 From: kammamuri at libero.it (km) Date: Wed, 15 Jan 2025 18:31:34 -0000 (UTC) Subject: is input from a pipe? Message-ID: Not a question, but a quick note about a problem that sometimes pops up in forums, that is how to detect on Linux if standard input (or any I/O stream) is via pipe. My suggestion is to check if the stream is a FIFO, if True it is a pipe, otherwise not a pipe The solution that sometimes is proposed, that is if not sys.stdin.isatty() simply checks if the input is not from a terminal, but it may be from a file, not only from a pipe. import os import sys import stat def check_if_stream_is_pipe(ifile): return stat.S_ISFIFO(os.fstat(ifile.fileno()).st_mode) print(check_if_stream_is_pipe(sys.stdin)) From learn2program at gmail.com Fri Jan 17 13:11:47 2025 From: learn2program at gmail.com (Alan Gauld) Date: Fri, 17 Jan 2025 18:11:47 +0000 Subject: Tools to help with text mode (i.e. non-GUI) input In-Reply-To: <87plko9acw.fsf@nosuchdomain.example.com> References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> <87plko9acw.fsf@nosuchdomain.example.com> Message-ID: <844b5f22-623a-42c0-941c-addd3a469687@yahoo.co.uk> On 15/01/2025 00:41, Keith Thompson via Python-list wrote: > Alan Gauld writes: >> On 11/01/2025 14:28, Chris Green via Python-list wrote: >>> I'm looking for Python packages that can help with text mode input, >> >> The standard package for this is curses which comes as part >> of the standard library on *nix distros. > > The thing about curses (which may or may not be a problem) is that, by > design, it takes over the whole screen. If you want to do simpler text > manipulations (showing a dismissible message, showing bold text, etc.) > without interfering with existing text, curses can't do it, at least not > easily. It's not that difficult to use the terminfo codes directly. But that won't give access to things like lists of default values, mouse control etc that the OP wanted. But for simple text characteristics and moving the cursor around terminfo works ok even if a bit tedious. Here is "hello world" in bold... import curses curses.setupterm() bold = curses.tigetstr('bold').decode('ascii') normal = curses.tigetstr('sgr0').decode('ascii') print(bold, 'Hello world', normal) Whilst you can position the cursor etc it very quickly becomes easier to just use full blown curses. -- 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 Keith.S.Thompson+u at gmail.com Fri Jan 17 14:03:16 2025 From: Keith.S.Thompson+u at gmail.com (Keith Thompson) Date: Fri, 17 Jan 2025 11:03:16 -0800 Subject: Tools to help with text mode (i.e. non-GUI) input References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> <87plko9acw.fsf@nosuchdomain.example.com> <844b5f22-623a-42c0-941c-addd3a469687@yahoo.co.uk> Message-ID: <87ikqd6z63.fsf@nosuchdomain.example.com> Alan Gauld writes: > On 15/01/2025 00:41, Keith Thompson via Python-list wrote: >> Alan Gauld writes: >>> On 11/01/2025 14:28, Chris Green via Python-list wrote: >>>> I'm looking for Python packages that can help with text mode input, >>> >>> The standard package for this is curses which comes as part >>> of the standard library on *nix distros. >> >> The thing about curses (which may or may not be a problem) is that, by >> design, it takes over the whole screen. If you want to do simpler text >> manipulations (showing a dismissible message, showing bold text, etc.) >> without interfering with existing text, curses can't do it, at least not >> easily. > > It's not that difficult to use the terminfo codes directly. But > that won't give access to things like lists of default values, mouse > control etc that the OP wanted. But for simple text characteristics > and moving the cursor around terminfo works ok even if a bit tedious. > > Here is "hello world" in bold... > > import curses > curses.setupterm() > bold = curses.tigetstr('bold').decode('ascii') > normal = curses.tigetstr('sgr0').decode('ascii') > > print(bold, 'Hello world', normal) Cool -- but I think you want: print(bold, 'Hello world', normal, sep='') > Whilst you can position the cursor etc it very quickly > becomes easier to just use full blown curses. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u at gmail.com void Void(void) { Void(); } /* The recursive call of the void */ From grant.b.edwards at gmail.com Fri Jan 17 16:09:14 2025 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Fri, 17 Jan 2025 16:09:14 -0500 (EST) Subject: Tools to help with text mode (i.e. non-GUI) input References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> <87plko9acw.fsf@nosuchdomain.example.com> <844b5f22-623a-42c0-941c-addd3a469687@yahoo.co.uk> Message-ID: <4YZXRG1NFKznVCN@mail.python.org> On 2025-01-17, Alan Gauld via Python-list wrote: > On 15/01/2025 00:41, Keith Thompson via Python-list wrote: >> Alan Gauld writes: >>> On 11/01/2025 14:28, Chris Green via Python-list wrote: >>>> I'm looking for Python packages that can help with text mode input, >>> >>> The standard package for this is curses which comes as part >>> of the standard library on *nix distros. >> >> The thing about curses (which may or may not be a problem) is that, by >> design, it takes over the whole screen. If you want to do simpler text >> manipulations (showing a dismissible message, showing bold text, etc.) >> without interfering with existing text, curses can't do it, at least not >> easily. > > It's not that difficult to use the terminfo codes directly. It's easy to do, but it's tricky to do it right. https://github.com/GrantEdwards/Python-curses-and-terminfo > [...] > > Here is "hello world" in bold... > > import curses > curses.setupterm() > bold = curses.tigetstr('bold').decode('ascii') > normal = curses.tigetstr('sgr0').decode('ascii') > > print(bold, 'Hello world', normal) Don't forget to use tparm() to parameterize strings for things like "move curser". Once you've parameterized the string (if needed), you've _might_ need to worry about the stuff in the string that's meant to be interpreted by tputs/putp: Quoting man tparm(3) All terminfo strings [including the output of tparm] should be printed with tputs or putp. That's becuase terminfo strings can contain escape sequences that are filterd out and interpreted by tputs/putp. The approach above only works if you only care about certain terminals, and you know that none of the terminfo strings you're using have those interal terminfo escape sequences in them [AFAIK, that's true for the linux console, xterm and the like, but not for many serial terminals.] -- Grant From mats at wichmann.us Fri Jan 17 16:11:57 2025 From: mats at wichmann.us (Mats Wichmann) Date: Fri, 17 Jan 2025 14:11:57 -0700 Subject: Tools to help with text mode (i.e. non-GUI) input In-Reply-To: <87ikqd6z63.fsf@nosuchdomain.example.com> References: <2113dab2-59ba-408e-b34a-78722d525f8c@yahoo.co.uk> <3ab7002b-689d-4609-96d7-bb388513f227@yahoo.co.uk> <87plko9acw.fsf@nosuchdomain.example.com> <844b5f22-623a-42c0-941c-addd3a469687@yahoo.co.uk> <87ikqd6z63.fsf@nosuchdomain.example.com> Message-ID: <301d32b0-2de7-48eb-a926-59fc88979dcd@wichmann.us> On 1/17/25 12:03, Keith Thompson via Python-list wrote: > Alan Gauld writes: >> On 15/01/2025 00:41, Keith Thompson via Python-list wrote: >>> Alan Gauld writes: >>>> On 11/01/2025 14:28, Chris Green via Python-list wrote: >>>>> I'm looking for Python packages that can help with text mode input, I haven't followed this whole thread, but rich (low-level) and textual (higher-level) are designed for this - part of the same project family - and really worth a look. I know someone else mentioned rich earlier. There's a little video on the textual homepage that shows some of what it can do in action: https://github.com/Textualize/textual From hjp-python at hjp.at Fri Jan 17 18:22:08 2025 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sat, 18 Jan 2025 00:22:08 +0100 Subject: Strategies for avoiding having to use --break-system-packages with pip In-Reply-To: References: Message-ID: <20250117232208.kbitploxjkktzpwo@hjp.at> On 2025-01-14 11:32:35 +0000, Chris Green via Python-list wrote: > Use a virtual environment, what do I have to do then to make using > my program (that uses tkintertable) 'transparent', i.e. I just > want to be able to run the program from the command prompt like > any other program. Just use the python interpreter in the venv in the hashbang line. For example, here's the first line of one my scripts: #!/usr/local/share/wds/venv/bin/python3 As you can probably guess, the venv is in /usr/local/share/wds/venv. There is no need for wrapper scripts which activate the venv. Python does that all by itself. I have a small script, install-python[1], to assist with setting the hashbang, but if it's just a few scripts you can simply edit it manually. hp [1] https://git.hjp.at:3000/hjp/install-python/src/branch/master/install-python -- _ | 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 arequipeno at gmail.com Fri Jan 17 18:33:23 2025 From: arequipeno at gmail.com (Ian Pilcher) Date: Fri, 17 Jan 2025 17:33:23 -0600 Subject: Struggling to understand Callable type hinting Message-ID: I am making my first attempt to use type hinting in a new project, and I'm quickly hitting areas that I'm having trouble understanding. One of them is how to write type hints for a method decorator. Here is an example that illustrates my confusion. (Sorry for the length.) import collections.abc class BufferScanner(object): def __init__(self, buf: str) -> None: self._buffer = buf self._index = 0 self._eof = False self._line = 1 self._column = 1 @property def eof(self) -> bool: return self._eof @staticmethod def _check_eof(method: collections.abc.Callable -> ( collections.abc.Callable ): def wrapper(*args, **kwargs): self = args[0] if not self._eof: method(*args, **kwargs) if self._index >= len(self._buffer): self._eof = True return self._eof return wrapper @_check_eof def next_line(self) -> None: """Advance the scanner to the beginning of the next line.""" try: i = self._buffer.index('\n', self._index) except ValueError: self._index = len(self._buffer) # decorator will set _eof return self._index = i + 1 # move past the newline self._line += 1 self._column = 1 I cannot figure out how to correctly specify the Callable argument and return type for _check_eof(). As indicated by the name, method should be a method (of the BufferScanner class), so its first positional argument should always be an instance of BufferScanner, but it could have any combination of positional and/or keyword arguments after that. I've read the TypeVar and ParamSpec documentation, and me head is spinning, but neither one really seems to help with this situation. Any pointers to good resources or the correct way to do this are appreciated. Thanks! -- ======================================================================== If your user interface is intuitive in retrospect ... it isn't intuitive ======================================================================== From PythonList at DancesWithMice.info Fri Jan 17 20:26:02 2025 From: PythonList at DancesWithMice.info (dn) Date: Sat, 18 Jan 2025 14:26:02 +1300 Subject: Struggling to understand Callable type hinting In-Reply-To: References: Message-ID: <113709c0-0530-47c7-ad8d-8294dd00924f@DancesWithMice.info> On 18/01/25 12:33, Ian Pilcher via Python-list wrote: > I am making my first attempt to use type hinting in a new project, and > I'm quickly hitting areas that I'm having trouble understanding.? One of > them is how to write type hints for a method decorator. > > Here is an example that illustrates my confusion.? (Sorry for the > length.) > > > import collections.abc > > class BufferScanner(object): > ... > ??? @staticmethod > ??? def _check_eof(method: collections.abc.Callable -> ( > ??????? collections.abc.Callable > ??? ): ... > > I cannot figure out how to correctly specify the Callable argument and > return type for _check_eof().? As indicated by the name, method should > be a method (of the BufferScanner class), so its first positional > argument should always be an instance of BufferScanner, but it could > have any combination of positional and/or keyword arguments after that. Is it a typing problem? The def is not syntactically-correct (parentheses). What happens once corrected? Also, which tool is 'complaining', and what does it have to say? General comment: as far as type-hints go, rather than trying to learn how to deal with complex situations, it might be better to ease-in gradually - add the easy stuff now, and come back to deal with the rest later (otherwise the typing 'tail' is wagging the coding 'dog'!) -- Regards, =dn From arequipeno at gmail.com Sat Jan 18 09:52:02 2025 From: arequipeno at gmail.com (Ian Pilcher) Date: Sat, 18 Jan 2025 08:52:02 -0600 Subject: Struggling to understand Callable type hinting In-Reply-To: <113709c0-0530-47c7-ad8d-8294dd00924f@DancesWithMice.info> References: <113709c0-0530-47c7-ad8d-8294dd00924f@DancesWithMice.info> Message-ID: <3da391eb-b245-429b-bcc1-3c88ef557241@gmail.com> (Note: I have mail delivery disabled for this list and read it through GMane, so I am unable to respond with correct threading if I'm not cc'ed directly.) On 1/17/25 7:26 PM, dn via Python-list wrote: > On 18/01/25 12:33, Ian Pilcher via Python-list wrote: >> I am making my first attempt to use type hinting in a new project, and >> I'm quickly hitting areas that I'm having trouble understanding.? One of >> them is how to write type hints for a method decorator. >> >> Here is an example that illustrates my confusion.? (Sorry for the >> length.) >> >> >> import collections.abc >> >> class BufferScanner(object): >> > ... > >> ???? @staticmethod >> ???? def _check_eof(method: collections.abc.Callable -> ( >> ???????? collections.abc.Callable >> ???? ): > ... >> >> I cannot figure out how to correctly specify the Callable argument and >> return type for _check_eof().? As indicated by the name, method should >> be a method (of the BufferScanner class), so its first positional >> argument should always be an instance of BufferScanner, but it could >> have any combination of positional and/or keyword arguments after that. > > Is it a typing problem? > The def is not syntactically-correct (parentheses). Yes, but only when I re-typed it in my email client to avoid word- wrapping issues. > What happens once corrected? Once the missing parenthesis is added, the version in my original post works just fine, but it's incomplete, because the Callables aren't parameterized. Based on what I've read, I would expect to be able to replace: @staticmethod def _check_eof(method: collections.abc.Callable) -> ( collections.abc.Callable ): ... with something like this: @staticmethod def _check_eof( method: collections.abc.Callable[[BufferScanner, ...], None] ) -> ( collections.abc.Callable[[BufferScanner, ...], bool] ): ... But Mypy gives me a bunch of errors when I do that. bs.py:19: error: Unexpected "..." [misc] bs.py:21: error: Unexpected "..." [misc] bs.py:32: error: Argument 1 to "_check_eof" of "BufferScanner" has incompatible type "Callable[[BufferScanner], None]"; expected "Callable[[BufferScanner, Any], None]" [arg-type] Found 3 errors in 1 file (checked 1 source file) (And even that wouldn't really be correct, if it worked, because it doesn't express the fact that the arguments of the two Callables are the same. I believe that ParamSpecs are supposed to address this, but there doesn't seem to be any way to use a ParamSpec when one or more of the parameter types is known. > Also, which tool is 'complaining', and what does it have to say? Mypy 1.14.1. > General comment: as far as type-hints go, rather than trying to learn > how to deal with complex situations, it might be better to ease-in > gradually - add the easy stuff now, and come back to deal with the rest > later (otherwise the typing 'tail' is wagging the coding 'dog'!) Makes sense ... except that this decorator is what motivated me to use type hinting in this project in the first place. -- ======================================================================== If your user interface is intuitive in retrospect ... it isn't intuitive ======================================================================== From arequipeno at gmail.com Sat Jan 18 11:17:31 2025 From: arequipeno at gmail.com (Ian Pilcher) Date: Sat, 18 Jan 2025 10:17:31 -0600 Subject: [SOLVED] Struggling to understand Callable type hinting In-Reply-To: <3da391eb-b245-429b-bcc1-3c88ef557241@gmail.com> References: <113709c0-0530-47c7-ad8d-8294dd00924f@DancesWithMice.info> <3da391eb-b245-429b-bcc1-3c88ef557241@gmail.com> Message-ID: <11ea559c-26da-4676-8bfc-1e58660d45cd@gmail.com> (Note: I have mail delivery disabled for this list and read it through GMane, so I am unable to respond with correct threading if I'm not cc'ed directly.) On 1/18/25 8:52 AM, Ian Pilcher wrote: > (And even that wouldn't really be correct, if it worked, because it > doesn't express the fact that the arguments of the two Callables are the > same.? I believe that ParamSpecs are supposed to address this, but there > doesn't seem to be any way to use a ParamSpec when one or more of the > parameter types is known. I think that I figured it out. __P = typing.ParamSpec('__P') @staticmethod def _check_eof( method: collections.abc.Callable[ typing.Concatenate[BufferScanner, __P], None ] ) -> ( collections.abc.Callable[ typing.Concatenate[BufferScanner, __P], bool ] ): ... Mypy is happy, and it catches me if I try to use the decorator on some- thing that isn't a method of BufferScanner (or some other callable that takes an instance of BufferScanner as its first positional argument). -- ======================================================================== If your user interface is intuitive in retrospect ... it isn't intuitive ======================================================================== From lele at metapensiero.it Sat Jan 18 03:08:04 2025 From: lele at metapensiero.it (Lele Gaifax) Date: Sat, 18 Jan 2025 09:08:04 +0100 Subject: Tools to help with text mode (i.e. non-GUI) input Message-ID: <87ldv8zgrf.fsf@metapensiero.it> Chris Green via Python-list writes: > I'm looking for Python packages that can help with text mode input, > i.e. for use with non-GUI programs that one runs from the command > prompt in a terminal window running a bash shell or some such. I'd suggest giving a try to https://pypi.org/project/questionary/, seems very close to what you are looking for and very simple to drive. Another package is https://github.com/petereon/beaupy, that seems a good fit as well. ciao, lele. -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From cl at isbd.net Sat Jan 18 06:47:57 2025 From: cl at isbd.net (Chris Green) Date: Sat, 18 Jan 2025 11:47:57 +0000 Subject: Strategies for avoiding having to use --break-system-packages with pip References: <20250117232208.kbitploxjkktzpwo@hjp.at> Message-ID: Peter J. Holzer wrote: > [-- text/plain, encoding quoted-printable, charset: us-ascii, 32 lines --] > > On 2025-01-14 11:32:35 +0000, Chris Green via Python-list wrote: > > Use a virtual environment, what do I have to do then to make using > > my program (that uses tkintertable) 'transparent', i.e. I just > > want to be able to run the program from the command prompt like > > any other program. > > Just use the python interpreter in the venv in the hashbang line. > > For example, here's the first line of one my scripts: > > #!/usr/local/share/wds/venv/bin/python3 > > As you can probably guess, the venv is in /usr/local/share/wds/venv. > > There is no need for wrapper scripts which activate the venv. Python > does that all by itself. > > I have a small script, install-python[1], to assist with setting the > hashbang, but if it's just a few scripts you can simply edit it manually. > OP here. Yes, thank you, I thought that the shebang line would do the trick but it's nioce to have it confirmed. -- Chris Green ? From deqser25 at gmail.com Sat Jan 18 07:55:56 2025 From: deqser25 at gmail.com (=?UTF-8?B?44GC44GG44GH44GP44KN?=) Date: Sat, 18 Jan 2025 21:55:56 +0900 Subject: bool type have big problem. finally program returned "True".Is this the TRUE spec? Message-ID: from typing import List from types import FunctionType, LambdaType def composite(*func: List[FunctionType]) -> LambdaType: if len(func) < 2: raise TypeError(f'composite expected over 2 arguments, but got {len(func)}') if len(func) == 2: return lambda *args, **kwargs: func[1](func[0](*args, **kwargs)) return lambda *args, **kwargs: composite(*func[1:])(func[0](*args, **kwargs )) tpr=composite(type,print) print(tpr('a')==tpr(1)) I subscribed to python-list, so I sent this message again. Why does tpr('a')==tpr(1) return True? From alan at csail.mit.edu Mon Jan 20 14:16:42 2025 From: alan at csail.mit.edu (Alan Bawden) Date: Mon, 20 Jan 2025 14:16:42 -0500 Subject: bool type have big problem. finally program returned "True".Is this the TRUE spec? References: Message-ID: <865xm95m91.fsf@williamsburg.bawden.org> ????? writes: tpr=composite(type,print) print(tpr('a')==tpr(1)) Why does tpr('a')==tpr(1) return True? Because tpr always returns the value None. From mk1853387 at gmail.com Wed Jan 22 16:54:12 2025 From: mk1853387 at gmail.com (marc nicole) Date: Wed, 22 Jan 2025 22:54:12 +0100 Subject: How to properly use py-webrtcvad? Message-ID: Hi, I am getting audio from my mic using PyAudio as follows: self.stream = audio.open(format=self.FORMAT, > channels=self.CHANNELS, > rate=self.RATE, > input=True, > frames_per_buffer=self.FRAMES_PER_BUFFER, > input_device_index=1) then reading data as follows: for i in range(0, int(self.RATE / self.FRAMES_PER_BUFFER * > self.RECORD_SECONDS)): > data = self.stream.read(4800) on the other hand I am using py-webrtcvad as follows: self.vad = webrtcvad.Vad() and want to use *is_speech*() using audio data from PyAudio. But getting the error: return _webrtcvad.process(self._vad, sample_rate, buf, length) > Error: Error while processing frame no matter how I changed the input data format (wav: using speech_recognition's *get_wav_data*(), using numpy...) Any suggestions (using Python 2.x)? Thanks. From arequipeno at gmail.com Tue Jan 28 17:02:47 2025 From: arequipeno at gmail.com (Ian Pilcher) Date: Tue, 28 Jan 2025 16:02:47 -0600 Subject: Any way to "subclass" typing.Annotated? Message-ID: (Note: I have mail delivery disabled for this list and read it through GMane. Please copy me on any responses, so that I can respond with proper threading.) From the things that I probably shouldn't spend my free time on department ... As background, I'm working on a project that is going to involve a bunch of abstract classes and dynamic types, and I've found that Python's existing abstract class implementation leaves a lot to be desired, particularly the inability to create abstract class variables and class methods. Having been seduced by the Siren song of Python's flexibility, I've been rolling my own implementation. Now to my question. I'm currently using annotations to create abstract class variables, for example: class Foo(object, metaclass=AbstractType): acv: Annotated[int, abstract] ('abstract' is simply a unique "flag" object.) This works just fine, but it's somewhat un-idiomatic. What I'd like to be able to do is create my own type, so that I could do something like this: class Foo(object, metaclass=AbstractType): acv: AbstractClassVariable[int] Essentially I'd like to create "subclass" of typing.Annotated that always sets the metadata to 'abstract'. Thus far, I haven't found a way to do this, as typing.Annotated can't be subclassed. Anyone have any ideas? -- ======================================================================== If your user interface is intuitive in retrospect ... it isn't intuitive ======================================================================== From rob.cliffe at btinternet.com Thu Jan 30 19:38:38 2025 From: rob.cliffe at btinternet.com (Rob Cliffe) Date: Fri, 31 Jan 2025 00:38:38 +0000 Subject: sys.call_tracing Message-ID: From the documentation on the sys module at https://docs.python.org/3/library/sys.html: sys.call_tracing(/func/, /args/) Call |func(*args)|, while tracing is enabled. The tracing state is saved, and restored afterwards. This is intended to be called from a debugger from a checkpoint, to recursively debug or profile some other code. Tracing is suspended while calling a tracing function set by |settrace()| or |setprofile()| to avoid infinite recursion. |call_tracing()| enables explicit recursion of the tracing function. Is there any reason it doesn't support sys.call_tracing(/func/, /args/, kargs) to call func(*args, **kargs) ? Best wishes Rob Cliffe From fabienluce at gmail.com Fri Jan 31 05:41:22 2025 From: fabienluce at gmail.com (Fabien LUCE) Date: Fri, 31 Jan 2025 11:41:22 +0100 Subject: Any way to "subclass" typing.Annotated? In-Reply-To: References: Message-ID: Maybe you'd better use descriptors? On Tue, 28 Jan 2025 at 23:03, Ian Pilcher via Python-list < python-list at python.org> wrote: > (Note: I have mail delivery disabled for this list and read it through > GMane. Please copy me on any responses, so that I can respond with > proper threading.) > > From the things that I probably shouldn't spend my free time on > department ... > > As background, I'm working on a project that is going to involve a bunch > of abstract classes and dynamic types, and I've found that Python's > existing abstract class implementation leaves a lot to be desired, > particularly the inability to create abstract class variables and class > methods. Having been seduced by the Siren song of Python's flexibility, > I've been rolling my own implementation. > > Now to my question. > > I'm currently using annotations to create abstract class variables, for > example: > > class Foo(object, metaclass=AbstractType): > > acv: Annotated[int, abstract] > > ('abstract' is simply a unique "flag" object.) > > This works just fine, but it's somewhat un-idiomatic. What I'd like to > be able to do is create my own type, so that I could do something like > this: > > class Foo(object, metaclass=AbstractType): > > acv: AbstractClassVariable[int] > > Essentially I'd like to create "subclass" of typing.Annotated that > always sets the metadata to 'abstract'. Thus far, I haven't found a > way to do this, as typing.Annotated can't be subclassed. > > Anyone have any ideas? > > -- > ======================================================================== > If your user interface is intuitive in retrospect ... it isn't intuitive > ======================================================================== > > -- > https://mail.python.org/mailman/listinfo/python-list >