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 function

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: 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 o

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

2021-03-28 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 Py

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 f

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: 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 Box

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 y

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 spec

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 >references

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: 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 stra

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. Typical

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 err

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: > >logge

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 actually

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 wrapper

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 cl

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
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 the name w

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: 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 error

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 applicatio

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: 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) Yo

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: 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(&PyType_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" documenta

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: 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 was

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 start

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: 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 dow

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 / exe

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 ex

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 un

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, extr

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)? -- https://mail.python.org/mailman/list

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 py versi

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 ... >>> timeit

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: 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 c

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 m

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). >> &

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 li

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: 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. T

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 certif

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 "https://packa

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 helper

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 can

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): `' i

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 >>> >&

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: 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 wo

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: 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 dyna

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 01:4

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-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 should

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 on a ch

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 modu

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: 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 all

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 ex

Re: Documentation of __hash__

2020-02-05 Thread Dieter Maurer
Stefan Halfpap wrote at 2020-2-5 14:57 +0100: >I do not understand the following statement from the python (2 and 3) >documentation regarding __hash__ and __eq__ methods: >"If a class does not define an __eq__() > method it >shoul

Re: time.localtime add a parameter for timezone

2020-02-24 Thread Dieter Maurer
qbit wrote at 2020-2-24 05:18 -0800: >How about adding a time zone parameter to time.localtime? > >A offset just like the form: ± hh[:mm[:ss]]. Why should this be necessary? `localtime` returns the time in the "local timezone" -- and the "local timezone" usually does not change between different

Re: encapsulating a global variable

2020-02-25 Thread Dieter Maurer
BlindAnagram wrote at 2020-2-25 12:38 +: >I would appreciate advice on whether it is possible to avoid the use of >a global variable used in a function by encapsulating it in a class >without maaking any changes to the call interface (which I cannot change). > >I have: > > >seen

Re: Error while installing a python code

2020-03-09 Thread Dieter Maurer
Tim Ko wrote at 2020-3-9 07:18 -0700: >I am trying to install a custom Python code but ran into an error. The error >presumably associated with cython. I tried a different compiler since Intel >compiler often crashes when using cython, but couldn't get it working. Almost surely, the compiler is

Re: Error while installing a python code

2020-03-09 Thread Dieter Maurer
Tim Ko wrote at 2020-3-9 07:18 -0700: >I am trying to install a custom Python code but ran into an error. The error >presumably associated with cython. I tried a different compiler since Intel >compiler often crashes when using cython, but couldn't get it working. Almost surely, the compiler is

Re: link to venv python sees a different sys.path

2020-03-11 Thread Dieter Maurer
Robin Becker wrote at 2020-3-11 15:26 +: >I'm trying to understand why python 3.8.2 venv behaves differently when it is >executed va a link > >Make the env >> rptlab@everest:~/code/hg-repos >> $ python38 -mvenv __py__/382v >> rptlab@everest:~/code/hg-repos > >make a link >> $ ln -s ../__py__/3

Re: Issue with PYSFTP - Working in WINSCP

2020-03-11 Thread Dieter Maurer
NAND KISHORE wrote at 2020-3-10 20:20 -0500: > We have requirement where we need to get file from client path and then >upload the same to vendor directory path. I am not able to upload the file >to vendor directory path , however when I tried to use the WINSCP it worked >fine. So I thought of ch

Re: link to venv python sees a different sys.path

2020-03-12 Thread Dieter Maurer
Robin Becker wrote at 2020-3-12 09:07 +: >On 11/03/2020 17:24, Dieter Maurer wrote: >> Robin Becker wrote at 2020-3-11 15:26 +: >>> I'm trying to understand why python 3.8.2 venv behaves differently when it >>> is executed va a link >>> >>>

Re: link to venv python sees a different sys.path

2020-03-12 Thread Dieter Maurer
Robin Becker wrote at 2020-3-12 10:25 +: > ... >I want many different versions of python all in one place to use for testing. I contribute to the `zopefoundation` projects. They, too, have a need to test with many different Python versions -- and use "tox" for it. Maybe, "tox" can also help so

Re: Lock acquisition by the same thread - deadlock protection

2020-03-12 Thread Dieter Maurer
Yonatan wrote at 2020-3-11 16:24 +0200: >That code I'm talking about didn't require a reentrant lock - the >algorithm really wasn't reentrant. > >Let me clarify my point: I'm wondering why the non-reentrant lock >doesn't raise an exception immediately on this >erroneous situation. >I thought it cou

Re: Profiler showing path dependency?

2020-03-14 Thread Dieter Maurer
Go Luhng wrote at 2020-3-13 18:51 -0400: >Consider a simple call graph: `main()` calls `foo()`, which calls >`bar()`. Then `main()` calls `qux()` which also calls `bar()`, but >with different parameters. > >When you run the above through cProfile and view the result in >SnakeViz, you will see `main

Re: Lock acquisition by the same thread - deadlock protection

2020-03-15 Thread Dieter Maurer
Cameron Simpson wrote at 2020-3-15 10:17 +1100: >On 12Mar2020 20:08, Dieter Maurer wrote: > ... >>The documentation for the basic lock explicitely allows >>lock release by a foreign thread. >>As I understand the documentation, this lock type is by design >>very ba

Re: Confusing textwrap parameters, and request for RE help

2020-03-23 Thread Dieter Maurer
Chris Angelico wrote at 2020-3-23 06:00 +1100: >When using textwrap.fill() or friends, setting break_long_words=False >without also setting break_on_hyphens=False has the very strange >behaviour that a long hyphenated word will still be wrapped. Having worked with `TeX`, I am familiar that hyphens

Re: Confusing textwrap parameters, and request for RE help

2020-03-24 Thread Dieter Maurer
Karsten Hilbert wrote at 2020-3-24 10:34 +0100: >On Tue, Mar 24, 2020 at 08:20:32PM +1100, Chris Angelico wrote: > ... >> I'm trying to figure out a way to handle URLs, and that's something >> that has its own governing standard, so the meanings of characters >> like hyphens is well defined. > >Agr

Re: dynamic import of dynamically created modules failes

2020-03-31 Thread Dieter Maurer
Stephan Lukits wrote at 2020-3-31 17:44 +0300: >background: > >- a daemon creates package p1 (e.g. directory with __init__.py-file) and >in p1 a module m1 is created. > >- Then the daemon wants to import from m1, which functions (so far all >the time). > >- Then a module m2 is created in p1 and the

Re: Incremental PCA

2020-04-18 Thread Dieter Maurer
Rahul Gupta wrote at 2020-4-18 02:56 -0700: >i wanted to implement incremental PCA. >Got this code for stack overflow but i am wondering what y = chunk.pop("y") >does and what is this argument "y" to pop Key to answer your question is "what is the type of `chunk`. Either use python's inspection (

Re: Not understood error with __set_name__ in a descriptor class

2020-04-19 Thread Dieter Maurer
ast wrote at 2020-4-19 17:14 +0200: >Le 19/04/2020 à 17:06, ast a écrit : >I understood where the problem is. > >Once __get__ is defined, it is used to read self._name in method >__set_name__ and it is not défined yet. That's why I have >an error "'NoneType' object is not callable" >Thats a nice bu

Re: Something annoying about method __set_name__ in descriptors

2020-04-21 Thread Dieter Maurer
ast wrote at 2020-4-21 14:27 +0200: > From python version 3.6, there is a useful new method >__set_name__ which could be implemented in descriptors. > >This method is called after a descriptor is instantiated >in a class. Parameter "name" is filled with the name >of the attribute refering to the de

Re: Getting the dependencies of a function from a library

2020-04-21 Thread Dieter Maurer
elisha hollander wrote at 2020-4-21 00:40 +0300: >I have a python library with a function. >This function call some other functions, classes and variable from the >library (and those functions and classes call other ones, etc)... >Can I automatically create a file with all of the dependencies (and

Re: Getting a 401 from requests.get, but not when logging in via the browser.

2020-04-21 Thread Dieter Maurer
dcwhat...@gmail.com wrote at 2020-4-20 14:48 -0700: > ... >I tried telneting the landing page, i.e. without the specific node that >requires the login. So e.g. > >Telnet thissite.oh.gov 80 > >, but it returns a 400 Bad Request. Before that, the Telnet screen is >completely blank ; I have to pre

Re: SSL Certificate Verify Failed (_ssl.c:600) using Windows Server 2019

2020-04-30 Thread Dieter Maurer
separated wrote at 2020-4-29 21:11 +: >I just bought a rdp from someone and try to install python in order to running >youtube-dl but when I just run a simple youtube-dl command like 'youtube-dl >[youtube video url]' it got me this message : > >ERROR: Unable to download webpage: CERTIFICATE_V

Re: SSL Certificate Verify Failed (_ssl.c:600) using Windows Server 2019

2020-04-30 Thread Dieter Maurer
separated wrote at 2020-5-1 02:51 +: > ... >but I still dont know why when I running a command 'youtube-dl -U' then got a >message 'ERROR: can't find the current version. Please try again later' maybe >it needs a sudo password. This looks like a log message (the "ERROR" likely comes from thi

Re: Problem with doctest

2020-05-04 Thread Dieter Maurer
ast wrote at 2020-5-4 15:20 +0200: >doctest of the sample function funct() doesn't works >because flag used by funct() is the one defined in >first line "flag = True" and not the one in the >doctest code ">>> flag = False". > >Any work around known ? > > >flag = True # <- funct() alway

Re: RV: CodecRegistryError problem for an IDE.

2020-05-16 Thread Dieter Maurer
Bryan Cabrera Ramírez wrote at 2020-5-15 19:53 +0200: > I'm trying to insall an INET package for an IDE called OMNeT++ and when > I try to build the INET the following happens in the command window: > > Fatal Python error: Py_Initialize: unable to load the file system codec >   File "C:\Pyt

Re: Can one make 'in' ungreedy?

2020-05-18 Thread Dieter Maurer
Chris Green wrote at 2020-5-18 11:50 +0100: > ... >So in the particular case where I have a problem sbstrip is "[Ipswich >Recycle]" and the Subject: is "[SPAM] [Ipswich Recycle] OFFER: >Lawnmower (IP11)". The match isn't found, presumably because 'in' is >greedy and sees "[SPAM] [Ipswich Recycle]"

Re: How to design a class that will listen on stdin?

2020-05-23 Thread Dieter Maurer
zljubi...@gmail.com wrote at 2020-5-23 04:24 -0700: >I have to talk to outer system by stdin/stdout. >Each line that comes to stdin should be processed and its result returned back >to stdout. Logging should go to stderr. > >How to design a class that will listed to stdin and call required methods

Re: Is there some reason that recent Windows 3.6 releases don't included executable nor msi installers?

2020-05-28 Thread Dieter Maurer
Mike Dewhirst wrote at 2020-5-29 11:55 +1000: >On 29/05/2020 10:51 am, Terry Reedy wrote: > ... >> Source only releases only block Windows/Mac users who choose not to >> upgrade to a released installer and who cannot or choose not to compile. > >I am an example > >I installed all the Pythons on my

Re: Ram memory not freed after executing python script on ubuntu system (rmlibre)

2020-05-28 Thread Dieter Maurer
rmli...@riseup.net wrote at 2020-5-28 18:56 -0700: >We just ran into this problem when running our aiootp package's memory >hard password hashing function (https://github.com/rmlibre/aiootp/). The >memory was not being cleared after the function finished running but the >script was still live. I h

<    1   2   3   4   >