Re: Passing info to function used in re.sub

2023-09-04 Thread Dieter Maurer via Python-list
Jan Erik Moström wrote at 2023-9-3 18:10 +0200: >I'm looking for some advice for how to write this in a clean way > ... >The "problem" is that I've currently written some code that works but it uses >global variables ... and I don't like global variables. I assume there is a >better way to write

Re: Question(s)

2023-10-25 Thread Dieter Maurer via Python-list
o1bigtenor wrote at 2023-10-25 08:29 -0500: > ... >It would appear that something has changed. > >Went to the Eclipse download page, downloaded and verified (using sha-512). >Expanded software to # opt . >There is absolutely NO mention of anything python - - - java, c and >its permutations,

Re: Question(s)

2023-10-25 Thread Dieter Maurer via Python-list
o1bigtenor wrote at 2023-10-25 07:50 -0500: >> There are several others, >> e.g. "ECLIPSE" can be used for Python development. > >Is 'Eclipse' a Windows oriented IDE? No. ==> "https://en.wikipedia.org/wiki/Eclipse_(software)" -- https://mail.python.org/mailman/listinfo/python-list

Re: NameError: name '__version__' is not defined

2023-10-27 Thread Dieter Maurer via Python-list
Loris Bennett wrote at 2023-10-27 09:29 +0200: > ... >For the application with the system Python this mechanism works, but for >the non-system Python I get the error: > > NameError: name '__version__' is not defined If you get exceptions (they usually end in `Error` (such as `NameError`)), look

Re: pip/pip3 confusion and keeping up to date

2023-11-02 Thread Dieter Maurer via Python-list
Chris Green wrote at 2023-11-2 10:58 +: > ... >So, going on from this, how do I do the equivalent of "apt update; apt >upgrade" for my globally installed pip packages? `pip list -o` will tell you for which packages there are upgrades available. `pip install -U ...` will upgrade packages. Be

Re: pip/pip3 confusion and keeping up to date

2023-11-03 Thread Dieter Maurer via Python-list
Karsten Hilbert wrote at 2023-11-3 14:47 +0100: > ... >> Are they not available in your system's package manager? > >... this clearly often answers to "no" for applications of >any complexity. > >Is there a suggested proper path to deal with that (Debian is >of interest to me here) ? Complex

Re: pip/pip3 confusion and keeping up to date

2023-11-06 Thread Dieter Maurer via Python-list
Karsten Hilbert wrote at 2023-11-5 23:19 +0100: > ... >do you happen to know where to read up on how to fit a pip >constraint file into a Debian package creation workflow ? I have only rudimentary `apt` knowledge. I know it is quite flexible, e.g. it used to handle `flash` in a special way. I

Re: Detect naming typos (AttributeError) in function names

2023-11-06 Thread Dieter Maurer via Python-list
c.bu...@posteo.jp wrote at 2023-11-6 12:47 +: >I would like to know how to detect (e.g. via a linter) typos in function >names imported from another module. One option is a test suite (--> Python's "unittest" package) with a sufficiently high coverage (near 100 %). --

Re: How to find any documentation for smbus?

2023-10-30 Thread Dieter Maurer via Python-list
Chris Green wrote at 2023-10-28 17:08 +0100: >I am using the python3 smbus module, but it's hard work because of the >lack of documentation. Web searches confirm that the documentation is >somewhat thin! > >If you do the obvious this is what you get:- > >>>> import smbus >>>> dir (smbus)

Re: Question(s)

2023-10-25 Thread Dieter Maurer via Python-list
o1bigtenor wrote at 2023-10-24 07:22 -0500: > ... >Is there a way to verify that a program is going to do what it is >supposed to do even >before all the hardware has been assembled and installed and tested? Others have already noted that "verify" is a very strong aim. There are different kinds

Re: Simple webserver

2023-10-25 Thread Dieter Maurer via Python-list
Frank Millman wrote at 2023-10-25 09:57 +0200: > ... >Based on this, I am considering the following - > >1. Replace my HTTP handler with Uvicorn. Functionality should be the >same, but performance should be improved. > >2. Instead of running as a stand-alone server, run my app as a >reverse-proxy

Re: Question(s)

2023-10-25 Thread Dieter Maurer via Python-list
o1bigtenor wrote at 2023-10-25 06:44 -0500: >On Wed, Oct 25, 2023 at 6:24?AM Dieter Maurer wrote: > ... >> There are different kinds of errors. >> >> Some can be avoided by using an integrated development environment >> (e.g. misspellings, type mismatches, ...). > >Haven't heard of a python IDE -

Re: How to write list of integers to file with struct.pack_into?

2023-10-02 Thread Dieter Maurer via Python-list
Jen Kris wrote at 2023-10-2 00:04 +0200: >Iwant to write a list of 64-bit integers to a binary file. Everyexample I >have seen in my research convertsit to .txt, but I want it in binary. I wrote >this code,based on some earlier work I have done: > >buf= bytes((len(qs_array)) * 8) > >for offset

Re: Simple webserver

2023-10-22 Thread Dieter Maurer via Python-list
Janis Papanagnou wrote at 2023-10-21 04:03 +0200: > ... >I'd like to ask; where do you see the specific risks with Python >(as language per se) and it's (web-socket-)libraries here? The web server in Python's runtime library is fairly simple, focusing only on the HTTP requirements. You might

Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread Dieter Maurer via Python-list
c.bu...@posteo.jp wrote at 2023-8-17 07:10 +: >I want to display one string in its original source (untranslated) >version and in its translated version site by site without duplicating >the string in the python source code? You could try to translate into an unknown language: this should

Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread Dieter Maurer via Python-list
c.bu...@posteo.jp wrote at 2023-8-17 07:10 +: >I want to display one string in its original source (untranslated) >version and in its translated version site by site without duplicating >the string in the python source code? Is it an option for you to replace the `gettext` binding by

Re: Canonical list of Python security vulnerabilities

2023-07-15 Thread Dieter Maurer via Python-list
Bob Kline wrote at 2023-7-14 13:35 -0400: >Can someone point me to the official catalog of security vulnerabilities in >Python (by which I mean cpython and the standard libraries)? I found >https://www.cvedetails.com/vulnerability-list/vendor_id-10210/product_id-18230/Python-Python.html >but that

Re: Fallback for operator and other dunder methods

2023-07-26 Thread Dieter Maurer via Python-list
Dom Grigonis wrote at 2023-7-26 05:22 +0300: > ... >Is there a way to achieve it without actually implementing operators? >I have looked at Proxy objects, but they do not seem suited to achieve this. Proxying is a good approach: you might have a look at `dm.reuse.proxy.OverridingProxy` (-->

Re: How to find the full class name for a frame

2023-08-04 Thread Dieter Maurer via Python-list
Jason Friedman wrote at 2023-8-3 21:34 -0600: > ... >my_frame = inspect.currentframe() > ... >My question is: let's say I wanted to add a type hint for my_frame. `my_frame` will be an instance of `Types.FrameType`. -- https://mail.python.org/mailman/listinfo/python-list

Re: Meta Class Maybe?

2023-07-23 Thread Dieter Maurer via Python-list
Chris Nyland wrote at 2023-7-22 19:12 -0400: >So I am stuck on a problem. I have a class which I want to use to create >another class without having to go through the boiler plate of subclassing. Do you know about `__init_subclass__`? It is called whenever a class is subclassed and can be used to

Re: extend behaviour of assignment operator

2024-01-10 Thread Dieter Maurer via Python-list
Guenther Sohler wrote at 2024-1-9 08:14 +0100: >when i run this code > >a = cube([10,1,1]) >b = a > >i'd like to extend the behaviour of the assignment operator >a shall not only contain the cube, but the cube shall also know which >variable name it >was assigned to, lately. I'd like to use that

Re: Question about garbage collection

2024-01-15 Thread Dieter Maurer via Python-list
Frank Millman wrote at 2024-1-15 15:51 +0200: >I have read that one should not have to worry about garbage collection >in modern versions of Python - it 'just works'. There are still some isolated cases when not all objects in an unreachable cycle are destroyed (see e.g. step 2 of

Re: Context without manager

2023-11-26 Thread Dieter Maurer via Python-list
Piergiorgio Sartor wrote at 2023-11-25 22:15 +0100: > ... >Apparently, the "with" context manager is not usable >in classes, at least not with __init__() & co. You can use `with` in classes -- with any context manager. However, you would usually not use `with` with a file you have opened in

Re: Await expressions (Posting On Python-List Prohibited)

2024-01-27 Thread Dieter Maurer via Python-list
>On 27/01/24 10:46 am, Stefan Ram wrote: >>But your explanation seems to have no mention of the "something" / >>"the awaitable object" part following the preposition "on". Shouldn't >>this awaitable object play a rôle in the explanation of what happens? You can explain a function call

RE: Extract lines from file, add to new files

2024-01-29 Thread Dieter Maurer via Python-list
Rich Shepard wrote at 2024-1-29 08:15 -0800: > ... >If this explanation is not sufficiently clear I'll re-write it. :-) Have you read "https://docs.python.org/3/library/io.html#module-io;? -- https://mail.python.org/mailman/listinfo/python-list

Re: __set_name__ equivalent for instance

2023-11-16 Thread Dieter Maurer via Python-list
Dom Grigonis wrote at 2023-11-16 20:12 +0200: >What I am interested in is a callback. >Preferably just after methods get bound. So in `object.__new__`. >I have done it via metaclass, but it is not ideal as there would be too much >overhead. > >I think what I am looking for is custom method

Re: __set_name__ equivalent for instance

2023-11-16 Thread Dieter Maurer via Python-list
Dom Grigonis wrote at 2023-11-15 18:44 +0200: >So there is a method __set_name__ which is called on class creation. > >The functionality that I am interested in is not retrieving name, but the fact >that it also receives `owner` argument. > >Thus, allowing simulation of bound class method. > >I

Re: __set_name__ equivalent for instance

2023-11-16 Thread Dieter Maurer via Python-list
Dom Grigonis wrote at 2023-11-16 21:11 +0200: > ... >> On 16 Nov 2023, at 21:00, Dieter Maurer wrote: >> ... >> Methods are not bound during instance creation, they are bound during >> access. > >Good to know. What is the criteria for binding then? Does it check if its type >is `vanilla`

Re: Popping key causes dict derived from object to revert to object

2024-03-21 Thread Dieter Maurer via Python-list
Loris Bennett wrote at 2024-3-21 10:56 +0100: > ... >So as I understand it, I need to convert the InstanceState-objects to, >say, dicts, in order to print them. However I also want to remove one >of the keys from the output and assumed I could just pop it off each >event dict, thus: > >

Re: Error in Module

2024-03-11 Thread Dieter Maurer via Python-list
Sanskar Mukeshbhai Joshi wrote at 2024-3-10 18:08 +: >I had made my project in BCA in Python. When I had complete my project and run >the program, at that time I got the error in runnig my project. The error was >ModuleNotFoundError: No module named 'flask'. `flask` is not part of the

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Dieter Maurer via Python-list
Thomas Nyberg wrote at 2024-3-22 11:08 +0100: > ... `future` use across thread boundaries ... > Here's an example using just the standard library that > exhibits the same issue: I think all `asyncio` objects (futures, tasks, ...) are meant to be used in a single thread. If you use them across

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Dieter Maurer via Python-list
dieter.mau...@online.de wrote at 2024-3-22 18:28 +0100: >Thomas Nyberg wrote at 2024-3-22 11:08 +0100: >> ... `future` use across thread boundaries ... >> Here's an example using just the standard library that >> exhibits the same issue: > ... >For use across thread boundaries, you likely will use

Re: how to discover what values produced an exception?

2024-05-04 Thread Dieter Maurer via Python-list
Johanne Fairchild wrote at 2024-5-3 10:56 -0300: >How to discover what values produced an exception? Or perhaps---why >doesn't the Python traceback show the values involved in the TypeError? >For instance: > >--8<>8--- (0,0) < 4