Re: Best-practice for formatted string literals and localization?

2020-12-01 Thread Dieter Maurer
Hartmut Goebel wrote at 2020-11-30 19:30 +0100: >formatted string literals are great, but can't be used together with >localization: > >_(f"These are {count} stones") > >will crash babel ("NameError: name 'count' is not defined". Translations are kept in external files (without any runtime

[issue42549] "quopri" line endings not standard conform

2020-12-02 Thread Dieter Maurer
New submission from Dieter Maurer : RFC 1521 and "https://tools.ietf.org/html/rfc2045#section-6.7; stipulate that the quoted printable encoding uses CRLF line endings. Python's "quopri" implementation does not honor this. -- components: Library (Lib) messages: 38235

Re: ssl connection has been closed unexpectedly

2020-11-29 Thread Dieter Maurer
Shaozhong SHI wrote at 2020-11-28 23:29 +: >I keep getting the following error when I use engine = >create_engine(logging in details to postgres) >df.to_sql('table_name', and etc.) > > >OperationalError: (psycopg2.OperationalError) SSL connection has been >closed unexpectedly SSL works as

Re: A problem with opening a file

2020-11-29 Thread Dieter Maurer
Gabor Urban wrote at 2020-11-29 08:56 +0100: >I am facing an issue I was not able to solve yet. I have a class saving >messages to a file. The relevant code is: > > > >import OS >import sys > >class MxClass: > >def __init__(self, fName, fMode,): >self.fileName = fName >

Re: Returning from a multiple stacked call at once

2020-12-12 Thread Dieter Maurer
ast wrote at 2020-12-12 07:39 +0100: >In case a function recursively calls itself many times, >is there a way to return a data immediately without >unstacking all functions ? Python does not have "long jump"s (out of many functions, many loop incarnations). In some cases, you can use exceptions

Re: Python Client Rest API Invocation - POST with empty body - Invalid character found in method name [{}POST]. HTTP method names must be tokens

2020-11-20 Thread Dieter Maurer
Shelke, Bhushan wrote at 2020-11-19 15:12 +: >I have a Tomcat+Java based server exposing REST APIs. I am writing a client in >python to consume those APIs. Everything is fine until I send empty body in >POST request. It is a valid use case for us. If I send empty body I get 400 >bad request

Re: Questions about XML processing?

2020-11-07 Thread Dieter Maurer
Hernán De Angelis wrote at 2020-11-6 21:54 +0100: > ... >However, the hard thing to do here is to get those only when >tagC/note/title/string='value'. I was expecting to find a way of >specifying a certain construction in square brackets, like >[@string='value'] or

Re: Automatically advancing a bi-directional generator to the point of accepting a non-None value?

2020-11-22 Thread Dieter Maurer
Go Luhng wrote at 2020-11-21 14:30 -0500: >Suppose we write a very simple bi-directional generator in Python: > >def share_of_total(): >s = 0 >new_num = 0 >while True: >new_num = yield new_num / (s or 1) >s += new_num > >share_calculator =

Re: Post request and encoding

2020-11-03 Thread Dieter Maurer
Hernán De Angelis wrote at 2020-11-2 10:06 +0100: > ... >My request has the form: > >header = {'Content-type':'application/xml', 'charset':'utf-8'} Not your problem (which you have already resolved) but: `charset` is not an individual header but a parameter for the `Content-Type` header. For

Re: SMS API

2021-02-03 Thread Dieter Maurer
ismail nagi wrote at 2021-2-3 21:06 +0300: >Yes, its about sending messages. For example, something like >twilio...it's an SMS API, can something like twilio be created using python >and how (just a basic idea)? Thank You. "twilio" provides a web service interface to send messages. You can use

Re: SMS API

2021-02-03 Thread Dieter Maurer
ismail nagi wrote at 2021-2-3 08:48 -0800: >I would like to know how an sms api is created. I assume that "sms api" means that your Python application should be able to send SMS messages. In this case, you need a service which interfaces between your device (mobile phone, computer, tablet, ...)

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-16 Thread Dieter Maurer
Chris Angelico wrote at 2021-6-16 02:20 +1000: >On Wed, Jun 16, 2021 at 2:18 AM Dieter Maurer wrote: >> As far as I know, there are no guarantees are the language level. >> There are some (partially documented) implementation details >> for CPython (which is just one po

Re: Optimizing Small Python Code

2021-06-23 Thread Dieter Maurer
Kais Ayadi wrote at 2021-6-22 08:03 -0700: >Hi There! >this is a small python code executed in 61 steps > >for n in range(1, 7): >print (n) >for x in range(0, n): >print(" ", x) > >can this code be more optimised? You should proceed as follows: implement a task in the most

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Dieter Maurer
Chris Angelico wrote at 2021-6-15 05:35 +1000: >On Tue, Jun 15, 2021 at 5:12 AM Jach Feng wrote: >> >> >>> n = [(1,2) for i in range(3)] >> >>> n >> [(1, 2), (1, 2), (1, 2)] >> >>> id(n[0]) == id(n[1]) == id(n[2]) >> True > >This is three tuples. Tuples are immutable and you get three

Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?

2021-06-15 Thread Dieter Maurer
Chris Angelico wrote at 2021-6-15 19:08 +1000: >On Tue, Jun 15, 2021 at 6:32 PM Dieter Maurer wrote: >> >> Chris Angelico wrote at 2021-6-15 05:35 +1000: >> >On Tue, Jun 15, 2021 at 5:12 AM Jach Feng wrote: >> >> >> >> >>> n = [(1,2) fo

Re: Transistion from module to package and __init__.py

2021-05-05 Thread Dieter Maurer
Chris Nyland wrote at 2021-5-4 22:20 -0400: > ... >So for a while now I have taken to converting >my module, in this example database.py, to the __init__.py of the package. >I remember reading years back that having code in the __init__.py was bad >practice but I can't remember reading for any

Re: async watch directory for new files

2021-04-24 Thread Dieter Maurer
Zoran wrote at 2021-4-23 14:31 -0700: >I need to watch for new files in directory, and when it shows up, I should >create async task with file's full path for it, and wait for new file. > >If anyone here used a library for such task, please share which one. The solution likely depends on the OS

Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-29 Thread Dieter Maurer
lucas wrote at 2021-3-27 18:53 +0100: >Following our previous discussion: > https://www.talkend.net/post/287193.html > >I finally took time (thanks to Florian R.) to get a reproducible example >of my problem, as asked previously by ChrisA. I compared `xmlrpc.client.ServerProxy.__init__` for

Re: memory consumption

2021-03-31 Thread Dieter Maurer
Alexey wrote at 2021-3-31 02:43 -0700: >среда, 31 марта 2021 г. в 06:54:52 UTC+3, Inada Naoki: > ... >> You can get some hints from sys._debugmallocstats(). It prints >> obmalloc (allocator for small objects) stats to stderr. >> Try printing stats before and after 1st run, and after 2nd run. And

Re: memory consumption

2021-03-29 Thread Dieter Maurer
Alexey wrote at 2021-3-29 06:26 -0700: >понедельник, 29 марта 2021 г. в 15:57:43 UTC+3, Julio Oña: >> It looks like the problem is on celery. >> The mentioned issue is still open, so not sure if it was corrected. >> >> https://manhtai.github.io/posts/memory-leak-in-celery/ > >As I mentioned in my

Re: SSL certificate issue

2021-03-18 Thread Dieter Maurer
Sagar, Neha wrote at 2021-3-18 10:58 +: >I am facing SSL certificate issue working with python. Can you help me on this. Python does not directly operate on SSL certificates. Usually, certificates for trusted CAs (= "Certificate Authorities") are stored at a standard place (depending on your

yield from () Was: Re: weirdness with list()

2021-03-02 Thread Dieter Maurer
Alan Gauld wrote at 2021-2-28 23:47 +: >yield from () "yield from iterator" is similar to "for i in iterator: yield i" (with special handling when data/exceptions are injected into the generator). Thus, "yield from ()" does essentially nothing with the side effect that the containing

Re: How to implement logging for an imported module?

2021-03-07 Thread Dieter Maurer
Robert Latest wrote at 2021-3-7 10:21 GMT: >I'm trying to add logging to a module that gets imported by another module. But >I only get it to work right if the imported module knows the name of the >importing module. The example given in the "Logging Cookbook" also rely on this >fact. I have used

Re: Determine what the calling program is

2021-04-18 Thread Dieter Maurer
Jason Friedman wrote at 2021-4-18 07:46 -0600: > ... >I have a program that runs via crontab every five minutes. It polls a >Box.com folder for files and, if any are found, it copies them locally and >performs a computation on them that can exceed five minutes. It pushes the >results back up to

Re: Trouble propagating logging configuration

2021-08-31 Thread Dieter Maurer
Loris Bennett wrote at 2021-8-31 15:25 +0200: >I am having difficulty getting the my logging configuration passed on >to imported modules. > >My initial structure was as follows: > > $ tree blorp/ > blorp/ > |-- blorp > | |-- __init__.py > | |-- bar.py > | |-- foo.py > | `-- main.py

Re: Trouble propagating logging configuration

2021-09-01 Thread Dieter Maurer
Loris Bennett wrote at 2021-9-1 13:48 +0200: > ... >Yes, but to quote from >https://docs.python.org/3.6/howto/logging.html#logging-basic-tutorial: > > A good convention to use when naming loggers is to use a module-level > logger, in each module which uses logging, named as follows: > >

Re: Add a method to list the current named logging levels

2021-09-02 Thread Dieter Maurer
Edward Spencer wrote at 2021-9-2 10:02 -0700: >Sometimes I like to pass the logging level up to the command line params so my >user can specific what level of logging they want. However there is no easy >method for pulling the named logging level names. > >Looking into the code, it would

[issue36674] "unittest.TestCase.debug" should honour "skip" (and other test controls)

2021-09-18 Thread Dieter Maurer
Dieter Maurer added the comment: Thank you for working on this issue! -- ___ Python tracker <https://bugs.python.org/issue36674> ___ ___ Python-bugs-list mailin

Re: How to "cast" an object to a derived class?

2021-09-19 Thread Dieter Maurer
Robert Latest wrote at 2021-9-18 13:03 GMT: >Stefan Ram wrote: >> Robert Latest writes: But how can I "promote" a >>>given Opaque instance to the derived class? >> >> Sometimes, one can use containment instead of inheritance. > >Nah, doesn't work in my case. I'm trying to write a

Re: a clean exit

2021-07-29 Thread Dieter Maurer
jak wrote at 2021-7-29 00:07 +0200: > ... >Thanks to both of you for the replies. I know the rules you described to >me for process synchronization but unfortunately, due to the structure >of the library I am using, I cannot apply them. I can't even use >try/except because the library, when the

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Dieter Maurer
Steve Keller wrote at 2021-9-24 11:48 +0200: >Why do some built-in Python functions feel so differently: Because the typical use cases are different >For example sum(), all(), any() expect exactly one argument which is a >sequence to operate on, i.e. a list, an iterator or a generator etc. > >

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Dieter Maurer
Stefan Ram wrote at 2021-9-24 14:53 GMT: >Steve Keller writes: >>Why do some built-in Python functions feel so differently: > >|>>> s = set() >|>>> s.add( 1 ) >|>>> > > >|>>> l = [] >|>>> l.add( 1 ) > >| >|Traceback (most recent call last): >| File "", line 1, in >|AttributeError: 'list' object

Re: Different "look and feel" of some built-in functions

2021-09-25 Thread Dieter Maurer
Steve Keller wrote at 2021-9-25 00:15 +0200: >"Dieter Maurer" writes: > >> Steve Keller wrote at 2021-9-24 11:48 +0200: >> >Why do some built-in Python functions feel so differently: >> >> Because the typical use cases are different >> >

Re: Different "look and feel" of some built-in functions

2021-09-25 Thread Dieter Maurer
Stefan Ram wrote at 2021-9-24 16:48 GMT: >"Dieter Maurer" writes: >>A list is ordered. Therefore, it is important where >>in this order an element is added. Thus, for a list, >>`append` is a better name than `add` -- because it already >>tells us in t

Re: Does loading PDB slow down execution?

2021-10-06 Thread Dieter Maurer
Unixnut wrote at 2021-10-3 22:03 +0100: >If I run a python3 program with "import pdb" in the code, would it >execute slower than without loading the debugger? Importing `pdb` does not slow down the application significantly (it just adds the import time but does not otherwise affect the

Re: Package conflicts trying to install jpegdupes package

2021-09-27 Thread Dieter Maurer
Skip Montanaro wrote at 2021-9-27 07:48 -0500: >I'd like to use the jpegdupes package but >can't seem to get past compilation issued related to jpegtrans-cffi. >Attempts to install any available versions on my XUbuntu system crap out >with this C compiler

Re: Explaining exec(globals, separate_locals)

2021-09-21 Thread Dieter Maurer
Terry Reedy wrote at 2021-9-20 12:46 -0400: >The second paragraph of the current exec entry >https://docs.python.org/3.11/library/functions.html#exec >ends with a sentence I wrote. > >"If exec gets two separate objects as globals and locals, the code will >be executed as if it were embedded in a

Re: threading and multiprocessing deadlock

2021-12-06 Thread Dieter Maurer
Johannes Bauer wrote at 2021-12-6 00:50 +0100: >I'm a bit confused. In my scenario I a mixing threading with >multiprocessing. Threading by itself would be nice, but for GIL reasons >I need both, unfortunately. I've encountered a weird situation in which >multiprocessing Process()es which are

Re: pytest segfault, not with -v

2021-12-19 Thread Dieter Maurer
Marco Sulla wrote at 2021-12-18 21:01 +0100: >Emh, maybe I was not clear. I created a C extension and it segfaults. >So I created that script to see where it segfaults. But the script >does not segfault. My doubt is: is that because I'm using eval and >exec in the script? The segfault in your C

Re: Is there any way to make sense of these E-Mail subjects?

2021-12-24 Thread Dieter Maurer
Chris Green wrote at 2021-12-24 16:03 +: >I have a Python 3 script which processes E-Mail caught in my hosting >provider's 'catchall' mailbox. It looks for things that *might* be >useful E-Mails, forwards them, and throws the rest away. > ... >I have a function which, given a header name,

Re: Advanced ways to get object information from within python

2021-12-23 Thread Dieter Maurer
Julius Hamilton wrote at 2021-12-23 12:01 +0100: >I would like to significantly increase my abilities to find the information >I am seeking about any Python object I am using from within Python. I find >this to be a really essential skill set. After reading documentation, it >really helps to get

Re: What's the public API alternative to _PyObject_GC_IS_TRACKED()?

2021-12-28 Thread Dieter Maurer
Marco Sulla wrote at 2021-12-27 19:30 +0100: >I need it since I'm developing an immutable dict. And in dict that >function is used. Why do you not derive from `dict` and override its mutating methods (to raise a type error after initialization is complete)? --

Re: What's the public API alternative to _PyObject_GC_IS_TRACKED()?

2021-12-29 Thread Dieter Maurer
Marco Sulla wrote at 2021-12-29 08:08 +0100: >On Wed, 29 Dec 2021 at 00:03, Dieter Maurer wrote: >> Why do you not derive from `dict` and override its mutating methods >> (to raise a type error after initialization is complete)? > >I've done this for the pure

Re: What's the public API alternative to _PyObject_GC_IS_TRACKED()?

2021-12-29 Thread Dieter Maurer
Marco Sulla wrote at 2021-12-29 11:59 +0100: >On Wed, 29 Dec 2021 at 09:12, Dieter Maurer wrote: >> `MutableMapping` is a so called abstract base class (--> `abc`). >> >> It uses the `__subclass_check__` (and `__instance_check__`) of >> `abc.ABCMeta` to ensure `i

Re: What's the public API alternative to _PyObject_GC_IS_TRACKED()?

2021-12-29 Thread Dieter Maurer
Marco Sulla wrote at 2021-12-29 09:29 +0100: >On second thought, I think I'll do this for the pure py version. But I >will definitely not do this for the C extension Are you sure you need to implement your type in C at all? I made a small `timeit` test: ``` >>> class cd(dict): pass ... >>>

Re: pytest segfault, not with -v

2021-12-18 Thread Dieter Maurer
Marco Sulla wrote at 2021-12-18 14:10 +0100: >Ok, I created the script: > >https://github.com/Marco-Sulla/python-frozendict/blob/master/test/debug.py > >The problem is it does _not_ crash, while a get a segfault using >pytest with python 3.9 on MacOS 10.15 > >Maybe it's because I'm using eval /

Re: pytest segfault, not with -v

2021-11-20 Thread Dieter Maurer
Marco Sulla wrote at 2021-11-20 19:07 +0100: >I know how to check the refcounts, but I don't know how to check the >memory usage, since it's not a program, it's a simple library. Is >there not a way to check inside Python the memory usage? I have to use >a bash script (I'm on Linux)? If Python

Re: Python script seems to stop running when handling very large dataset

2021-10-30 Thread Dieter Maurer
Shaozhong SHI wrote at 2021-10-29 23:42 +0100: >Python script works well, but seems to stop running at a certain point when >handling very large dataset. > >Can anyone shed light on this? Some algorithms have non linear runtime. For example, it is quite easy to write code with quadratic runtime

Re: CWD + relative path + import name == resultant relative path?

2021-10-30 Thread Dieter Maurer
Dan Stromberg wrote at 2021-10-29 16:38 -0700: >Is there a predefined function somewhere that can accept the 3 things on >the LHS in the subject line, and give back a resultant relative path - >relative to the unchanged CWD? > >To illustrate, imagine: >1) You're sitting in /home/foo/coolprog >2)

Re: Python C API: how to mark a type as subclass of another type

2021-11-02 Thread Dieter Maurer
Marco Sulla wrote at 2021-11-2 13:43 +0100: >I already added the address of the type to tp_base, but it does not work. It worked for me in `dm.incrementalsearch`. Maybe, you need a special value for `tp_flags`. Look at the examples. -- https://mail.python.org/mailman/listinfo/python-list

Re: what's unsafe to do in a __getattr__?

2021-10-25 Thread Dieter Maurer
Mats Wichmann wrote at 2021-10-24 19:10 -0600: >Have run into a problem on a "mature" project I work on (there are many >years of history before I joined), there are a combination of factors >that combine to trigger a KeyError when using copy.copy(). > ... >There's a class that's a kind of proxy

Re: Python C API: how to mark a type as subclass of another type

2021-11-01 Thread Dieter Maurer
Marco Sulla wrote at 2021-10-31 23:59 +0100: >I have two types declared as > >PyTypeObject PyX_Type = { >PyVarObject_HEAD_INIT(_Type, 0) > >etc. > >How can I mark one of the types as subclass of the other one? I tried >to use tp_base but it didn't work. Read the "Python/C Api" documentation.

Re: HTML extraction

2021-12-09 Thread Dieter Maurer
Pieter van Oostrum wrote at 2021-12-8 11:00 +0100: > ... >bs4 can do it, but lxml wants correct XML. Use `lxml's the `HTMLParser` to parse HTML (--> "see https://lxml.de/parsing.html#parsing-html;). -- https://mail.python.org/mailman/listinfo/python-list

Re: How to package a Python command line app?

2021-12-09 Thread Dieter Maurer
Manfred Lotz wrote at 2021-12-8 12:31 +0100: >The are many possibilities to package a Python app, and I have to admit >I am pretty confused. > >Here is what I have: > >A Python command line app which requires some packages which are not in >the standard library. Are they on PyPI or can they be

Re: HTML extraction

2021-12-08 Thread Dieter Maurer
Roland Mueller wrote at 2021-12-7 22:55 +0200: > ... >Can bs4 or lxml cope with HTML code that does not comply with XML as the >following fragment? `lxml` comes with an HTML parser; that can be configured to check loosely. -- https://mail.python.org/mailman/listinfo/python-list

Re: Odd locale error that has disappeared on reboot.

2021-12-08 Thread Dieter Maurer
Chris Green wrote at 2021-12-7 15:28 +: >I have a very short Python program that runs on one of my Raspberry >Pis to collect temperatures from a 1-wire sensor and write them to a >database:- > ... >At 03:40 last night it suddenly started throwing the following error every >time it ran:- > >

Re: a clean exit

2021-07-24 Thread Dieter Maurer
jak wrote at 2021-7-23 10:55 +0200: > ... >The problem is that sometimes I get an error from the library (python- >telegram-bot) via logging that my bot has no way of intercepting. The >error is "connection reset by pear" after which my program is no longer >called and I need to restart it.

Re: preserving entities with lxml

2022-01-12 Thread Dieter Maurer
Robin Becker wrote at 2022-1-12 10:22 +: >I have a puzzle over how lxml & entities should be 'preserved' code below >illustrates. To preserve I change & --> >in the source and add resolve_entities=False to the parser definition. The >escaping means we only have one kind of >entity which

Re: Script profiling details

2022-01-11 Thread Dieter Maurer
Joseph L. Casale wrote at 2022-1-10 18:43 +: > ... >I expected this given the implementation, but I was hoping to get some >finer details so I can track down the specific module or at least the specific >file so I have a place to start reviewing code for optimizations. > >Is there something I

Re: Behavior of the for-else construct

2022-03-04 Thread Dieter Maurer
Avi Gross wrote at 2022-3-4 16:43 +: >Your use is creative albeit it is not "needed" since all it does is make sure >your variable is initialized to something, specifically None. > >So would this not do the same thing? > > eye = None > > for eye in range(0): > print(eye) > > eye It

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-07 Thread Dieter Maurer
Martin Di Paola wrote at 2022-3-6 20:42 +: >>Try to use `fork` as "start method" (instead of "spawn"). > >Yes but no. Indeed with `fork` there is no need to pickle anything. In >particular the child process will be a copy of the parent so it will >have all the modules loaded, including the

Re: How to test input via subprocess.Popen with data from file

2022-03-10 Thread Dieter Maurer
Loris Bennett wrote at 2022-3-11 07:40 +0100: > ... I want to test the parsing ... >Sorry if I was unclear but my question is: > >Given that the return value from Popen is a Popen object and given that >the return value from reading a file is a single string or maybe a list >of strings, what

Re: Typing on child class' methods of a Generic base class

2022-03-10 Thread Dieter Maurer
Nicolas Haller wrote at 2022-3-9 10:53 -0500: > ... >The documentation about "user-defined generic types"[1] says that I can >fix some types on a child class (class MyDict(Mapping[str, T]):) but >doesn't say much about the signature of the methods I need to >implement/override on that child class.

Re: How to test input via subprocess.Popen with data from file

2022-03-10 Thread Dieter Maurer
Loris Bennett wrote at 2022-3-10 13:16 +0100: >I have a command which produces output like the >following: > > Job ID: 9431211 > Cluster: curta > User/Group: build/staff > State: COMPLETED (exit code 0) > Nodes: 1 > Cores per node: 8 > CPU Utilized: 01:30:53 > CPU Efficiency: 83.63% of

Re: Execute in a multiprocessing child dynamic code loaded by the parent process

2022-03-06 Thread Dieter Maurer
Martin Di Paola wrote at 2022-3-6 12:42 +: >Hi everyone. I implemented time ago a small plugin engine to load code >dynamically. > >So far it worked well but a few days ago an user told me that he wasn't >able to run in parallel a piece of code in MacOS. > >He was using multiprocessing.Process

Re: Typing on child class' methods of a Generic base class

2022-03-12 Thread Dieter Maurer
Nicolas Haller wrote at 2022-3-12 12:05 -0500: >On 2022-03-10 12:31, Dieter Maurer wrote: >> Nicolas Haller wrote at 2022-3-9 10:53 -0500: >>> ... >>> The documentation about "user-defined generic types"[1] says that I can >>> fix some types

Re: Why does not Python accept functions with no names?

2022-02-20 Thread Dieter Maurer
Abdur-Rahmaan Janhangeer wrote at 2022-2-20 19:32 +0400: >Out of curiosity, why doesn't Python accept >def (): >return '---' > >() > >Where the function name is ''? Python knows about (somewhat restricted) anonymous functions: it calls them `lambda` expressions (the body of those functions

Re: lxml empty versus self closed tag

2022-03-02 Thread Dieter Maurer
Robin Becker wrote at 2022-3-2 15:32 +: >I'm using lxml.etree.XMLParser and would like to distinguish > > > >from > > > >I seem to have e.getchildren()==[] and e.text==None for both cases. Is there a >way to get the first to have e.text=='' I do not think so (at least not without a DTD): `'

Re: lxml empty versus self closed tag

2022-03-03 Thread Dieter Maurer
Robin Becker wrote at 2022-3-3 09:21 +: >On 02/03/2022 18:39, Dieter Maurer wrote: >> Robin Becker wrote at 2022-3-2 15:32 +: >>> I'm using lxml.etree.XMLParser and would like to distinguish >>> >>> >>> >>> from >>> >>&g

Re: Behavior of the for-else construct

2022-03-03 Thread Dieter Maurer
computermaster360 wrote at 2022-3-3 14:24 +0100: >Do you find the for-else construct useful? Yes. >Have you used it in practice? Yes -- https://mail.python.org/mailman/listinfo/python-list

Re: Behavior of the for-else construct

2022-03-03 Thread Dieter Maurer
Rob Cliffe wrote at 2022-3-4 00:13 +: >I find it so hard to remember what `for ... else` means that on the very >few occasions I have used it, I ALWAYS put a comment alongside/below the >`else` to remind myself (and anyone else unfortunate enough to read my >code) what triggers it, e.g. > >    

Re: Exchange OWA using Python?

2022-03-31 Thread Dieter Maurer
Grant Edwards wrote at 2022-3-31 07:41 -0700: >Is anybody aware of any Python code for the Exchange OWA protocol/API? According to "https://en.wikipedia.org/wiki/Outlook.com#Mail_client_access; Outlook.com (the modern name for OWA) supports "pop3" and "imap", both supported by Python library

Re: dict.get_deep()

2022-04-03 Thread Dieter Maurer
Marco Sulla wrote at 2022-4-2 22:44 +0200: >A proposal. Very often dict are used as a deeply nested carrier of >data, usually decoded from JSON. Sometimes I needed to get some of >this data, something like this: > >data["users"][0]["address"]["street"] > >What about something like this instead? >

Re: dict.get_deep()

2022-04-03 Thread Dieter Maurer
Marco Sulla wrote at 2022-4-3 21:17 +0200: >On Sun, 3 Apr 2022 at 18:57, Dieter Maurer wrote: >> You know you can easily implement this yourself -- in your own >> `dict` subclass. > >Well, of course, but the question is if such a method is worth to be >builtin, in a w

Re: http.client and dns lookups

2022-02-02 Thread Dieter Maurer
Michael Welle wrote at 2022-2-1 19:28 +0100: > ... >That doesn't happen when the 'real' issue occurs. Attaching strace to >the Python process I can see that resolv.conf is stat'ed and open'ed. I >guess now I'm more confused than before ;). There must be an additional >condition that I'm missing.

Re: PYTHONPATH vs Python Virtual Environment

2022-02-04 Thread Dieter Maurer
Sina Mobasheri wrote at 2022-2-4 15:55 +: >it's not good title defiantly and I don't mean to compare apples and oranges > >when I start using python virtual environment it was because isolation >proposes and everyone say about its benefits in isolation and working with >different versions of

Re: ssl server: how to disable client cert verfication?

2022-02-04 Thread Dieter Maurer
Grant Edwards wrote at 2022-2-3 14:36 -0800: >On 2022-02-03, Barry wrote: > ... >I've looked through the ssl.Context documentation multiple times, and >haven't been able to spot any option or flag that disables client >certificate validation or allows the user to override the actual >client

Re: http.client and dns lookups

2022-01-31 Thread Dieter Maurer
Michael Welle wrote at 2022-1-30 09:18 +0100: > ... The machine this is running on regularly switches >its network configuration without restarting the Python application. Now >it turns out that the application is still using an old, outdated dns >server after such a network configuration switch.

Re: Correct way to setup a package with both compiled C code and Python code?

2022-02-08 Thread Dieter Maurer
Christian Gollwitzer wrote at 2022-2-7 20:33 +0100: >we've developed a Python pacakge which consists of both a compiled >extension module and some helper functions in Python. Is there a >tutorial on how to package such an extension? Look at "https://package.python.org;, especially

Re: Correct way to setup a package with both compiled C code and Python code?

2022-02-09 Thread Dieter Maurer
Christian Gollwitzer wrote at 2022-2-8 22:43 +0100: >Am 08.02.22 um 18:57 schrieb Dieter Maurer: >> Christian Gollwitzer wrote at 2022-2-7 20:33 +0100: >>> we've developed a Python pacakge which consists of both a compiled >>> extension module and some

Re: "undefined symbol" in C extension module

2022-01-23 Thread Dieter Maurer
Robert Latest wrote at 2022-1-22 11:29 GMT: >I've written some CPython extension modules in the past without problems. Now >after moving to a new Archlinux box with Python3.10 installed, I can't build >them any more. Or rather, I can build them but not use them due to "undefined >symbols" during

Re: preserving entities with lxml

2022-01-13 Thread Dieter Maurer
Robin Becker wrote at 2022-1-13 09:13 +: >On 12/01/2022 20:49, Dieter Maurer wrote: > ... >> Apparently, the `resolve_entities=False` was not effective: otherwise, >> your tree content should have more structure (especially some >> entity reference children). >&g

[issue47246] Race condition in `threadig.Thread._wait_for_tstate_lock`

2022-04-07 Thread Dieter Maurer
New submission from Dieter Maurer : I have observed an `AssertionError (assert self._is_stopped)` in `threading.Thread._wait_for_tstate_lock`. This indicates that Python's internal state has been corrupted. The analysis revealed the following race condition: `_wait_for_tstate:lock` contains

[issue47246] Race condition in `threadig.Thread._wait_for_tstate_lock`

2022-04-07 Thread Dieter Maurer
Dieter Maurer added the comment: The observation was caused by a bug which has been fixed in newer Python versions (3.9+ if I remember correctly). `isAlive` was called on a `_DummyThread` (while `_DummyThread` overides `is_alive` it had forgotten to override `isAlive` as well

[issue47246] Race condition in `threadig.Thread._wait_for_tstate_lock`

2022-04-07 Thread Dieter Maurer
Dieter Maurer added the comment: Apparently, the explanation is not that easy: `_stop` first sets `_is_stopped` to `True` and only then `_tstate_lock` to `None`. Therefore, the race should not cause the `AssertionError`. I observed the `AssertionError` in Python 3.6. The related `threading

Re: Comparing sequences with range objects

2022-04-07 Thread Dieter Maurer
Antoon Pardon wrote at 2022-4-7 17:16 +0200: > ... >Sorry I wasn't clear. The data contains information about persons. But not >all records need to be complete. So a person can occur multiple times in >the list, while the records are all different because they are missing >different bits. > >So

Re: Functionality like local static in C

2022-04-14 Thread Dieter Maurer
Cecil Westerhof wrote at 2022-4-14 17:02 +0200: >In C when you declare a variable static in a function, the variable >retains its value between function calls. >The first time the function is called it has the default value (0 for >an int). >But when the function changes the value in a call (for

Re: Issue sending data from C++ to Python

2022-05-19 Thread Dieter Maurer
Pablo Martinez Ulloa wrote at 2022-5-18 15:08 +0100: >I have been using your C++ Python API, in order to establish a bridge from >C++ to Python. Do you know `cython`? It can help very much in the implementation of bridges between Python and C/C++. --

Re: traceback Shows path to my python libraries

2022-06-21 Thread Dieter Maurer
jsch...@sbcglobal.net wrote at 2022-6-20 13:49 -0500: >I coded an application with a 64-bit executable using cython with the embed >option and gcc and I received a traceback showing the path to my python >installation. Is that normal or does that mean the application is going >outside of my

Re: argparse modify

2022-06-23 Thread Dieter Maurer
נתי שטרן wrote at 2022-6-23 15:31 +0300: >how to solve this (argparse) > > >traceback: >Traceback (most recent call last): > File "u:\oracle\RTR.py", line 10, in >class sre_constants(): > File "u:\oracle\RTR.py", line 77, in sre_constants >MAXREPEAT = _NamedIntConstant(32,name=str(32))

Re: argparse modify

2022-06-24 Thread Dieter Maurer
נתי שטרן wrote at 2022-6-24 08:28 +0300: >I copied code from argparse library and modified it > >בתאריך יום חמישי, 23 ביוני 2022, מאת Dieter Maurer : > >> נתי שטרן wrote at 2022-6-23 15:31 +0300: >> >how to solve this (argparse) >> > >> > >&g

Re: Logging into single file from multiple modules in python when TimedRotatingFileHandler is used

2022-06-22 Thread Dieter Maurer
Chethan Kumar S wrote at 2022-6-21 02:04 -0700: > ... >I have a main process which makes use of different other modules. And these >modules also use other modules. I need to log all the logs into single log >file. Due to use of TimedRotatingFileHandler, my log behaves differently after

Re: Fwd: timedelta object recursion bug

2022-07-28 Thread Dieter Maurer
Ben Hirsig wrote at 2022-7-28 19:54 +1000: >Hi, I noticed this when using the requests library in the response.elapsed >object (type timedelta). Tested using the standard datetime library alone >with the example displayed on

Re: Fwd: timedelta object recursion bug

2022-07-28 Thread Dieter Maurer
Please stay on the list (such that others can help, too) Ben Hirsig wrote at 2022-7-29 06:53 +1000: >Thanks for the replies, I'm just trying to understand why this would be >useful? > >E.g. why does max need a min/max/resolution, and why would these attributes >themselves need a

Re: Register multiple excepthooks?

2022-08-01 Thread Dieter Maurer
Albert-Jan Roskam wrote at 2022-7-31 11:39 +0200: > I have a function init_logging.log_uncaught_errors() that I use for > sys.excepthook. Now I also want to call another function (ffi.dlclose()) > upon abnormal termination. Is it possible to register multiple > excepthooks, like with

Re: Trying to understand nested loops

2022-08-05 Thread Dieter Maurer
ojomooluwatolami...@gmail.com wrote at 2022-8-5 08:34 +0100: >Hello, I’m new to learning python and I stumbled upon a question nested loops. For future, more complex, questions of this kind, you might have a look at the module `pdb` in Python's runtime library. It implements a debugger which

RE: Parallel(?) programming with python

2022-08-10 Thread Dieter Maurer
Schachner, Joseph (US) wrote at 2022-8-9 17:04 +: >Why would this application *require* parallel programming? This could be >done in one, single thread program. Call time to get time and save it as >start_time. Keep a count of the number of 6 hour intervals, initialize it to >0. You

Re: Parallel(?) programming with python

2022-08-11 Thread Dieter Maurer
Dennis Lee Bieber wrote at 2022-8-10 14:19 -0400: >On Wed, 10 Aug 2022 19:33:04 +0200, "Dieter Maurer" > ... >>You could also use the `sched` module from Python's library. > >Time to really read the library reference manual again... > > Thoug

Re: setup.py + cython == chicken and the egg problem

2022-08-17 Thread Dieter Maurer
Dan Stromberg wrote at 2022-8-16 14:03 -0700: > ... >I'm attempting to package up a python package that uses Cython. > ... > Installing build dependencies ... error > error: subprocess-exited-with-error > > ×? pip subprocess to install build dependencies did not run successfully. > ?? exit

Re: Mailing-Lists (pointer)

2023-01-10 Thread Dieter Maurer
Chris Green wrote at 2023-1-10 08:45 +: > ... >Yes, this is important I think. Plus, if possible, if it's decided to >move to a forum format make that accessible by E-Mail. I much prefer a mailing list over an http based service. With mailing lists, all interesting messages arrive in my

<    1   2   3   4   >