Re: A new feature request - parser add_mutually_exclusive_group - add a default value

2024-07-09 Thread Barry Scott via Python-list
> On 9 Jul 2024, at 06:13, ⁨אורי via Python-list⁩ <⁨python-list@python.org⁩> > wrote: > > I tried to subscribe to Python-ideas These days ideas are discussed on https://discuss.python.org/ It is rare to see an idea on the mailing list. Barry --

Re: PyGILState_Ensure() deadlocks, why?

2024-07-08 Thread Barry Scott via Python-list
> On 7 Jul 2024, at 23:21, Barry via Python-list wrote: > > > >> On 7 Jul 2024, at 22:09, Tomas Ukkonen via Python-list >> wrote: >> >>Py_Initialize(); > > You also need to tell python to init threading. I'm in front of my dev machine now and checking up on threading. There is no

Re: Best (simplest) way to share data between processes

2024-07-08 Thread Barry Scott via Python-list
> On 7 Jul 2024, at 23:47, MRAB via Python-list wrote: > > For clarity I'd recommend os.replace instead. This is because on Windows > os.rename it would complain if the target file already exists, but os.replace > has the same behaviour on both Linux and Windows. Agreed. In this case the

Re: Anonymous email users

2024-06-24 Thread Barry Scott via Python-list
> On 23 Jun 2024, at 06:58, Sebastian Wells via Python-list > wrote: > > The spammers won the spam wars, so even if you have someone's real > e-mail address, that's no guarantee that you can contact them. You > certainly wouldn't be able to contact me at my real e-mail address, > unless you

Re: Suggested python feature: allowing except in context maneger

2024-06-13 Thread Barry Scott via Python-list
> On 13 Jun 2024, at 11:01, Yair Eshel via Python-list > wrote: > > I read this is a good place to give some suggestions for features in > python. Best place these days is to raise an idea on https://discuss.python.org/ Beware that this idea has come up in the past and was rejected. Barry

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-29 Thread Barry Scott via Python-list
> On 29 May 2024, at 05:38, Kevin M. Wilson via Python-list > wrote: > > The format in this email is not of my making, should someone know, how to do > this so that it's a readable script do tell! > KMW Your mail program may have a plain-text mode to compose messages in try using that.

Re: Making 'compiled' modules work with multiple python versions on Linux

2024-03-29 Thread Barry Scott via Python-list
> On 29 Mar 2024, at 16:09, Olivier B. > wrote: > > It is not a symlink on my system, where i built python myself, but a > 15KB so file. But it seems to lack lots of python symbols. > > Maybe what i should do is actually make libpython.so a physical copy > of libpyton311.so before linking to

Re: Feature proposal: unittest.mock.NAN

2024-01-24 Thread Barry Scott via Python-list
Python ideas are discussed here these days: https://discuss.python.org/ Suggest you raise this there in the Ideas category. Barry > On 24 Jan 2024, at 17:11, Kerrick Staley via Python-list > wrote: > > I think we should define a unittest.mock.NAN constant that can be used with >

Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-09 Thread Barry Scott via Python-list
> On 7 Jan 2024, at 15:09, Sibylle Koczian via Python-list > wrote: > > Oh, and the two Windows and Python versions are on two different computers. > > Will remove the "/env" from my shebang lines, even if I don't understand > what's happening. Thanks for the details. Only thing I can

Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-03 Thread Barry Scott via Python-list
> On 2 Jan 2024, at 17:24, Thomas Passin via Python-list > wrote: > > You might learn about this if you happen to read and remember the right part > of the Python docs. Otherwise you have no idea what py.exe is up to nor how > it does it. I would say that most people don't know there's

Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-23 Thread Barry Scott via Python-list
> On 23 Dec 2023, at 03:01, Thomas Passin via Python-list > wrote: > > Not on my system. It may depend on whether Python gets installed to Program > Files or to %USERPROFILE%/AppData/Local/Programs/Python. Python 3.9 is the > last verson I installed to Program Files, and that's the

Re: making your own DirEntry.

2023-12-23 Thread Barry Scott via Python-list
> On 23 Dec 2023, at 09:48, Antoon Pardon via Python-list > wrote: > > Because I have functions with DirEntry parameters. I would duck-type a class I control to be my DirEnrry in this situation. Would also help you when debugging as you can tell injected DirEntry from "real" DirEntry.

Re: How/where to store calibration values - written by program A, read by program B

2023-12-06 Thread Barry Scott via Python-list
> On 6 Dec 2023, at 09:32, Chris Green via Python-list > wrote: > > My requirement is *slightly* more complex than just key value pairs, > it has one level of hierarchy, e.g.:- > >KEY1: > a: v1 > c: v3 > d: v4 >KEY2: > a: v7 > b: v5 > d: v6 > >

Re: How/where to store calibration values - written by program A, read by program B

2023-12-05 Thread Barry Scott via Python-list
> On 5 Dec 2023, at 14:37, Chris Green via Python-list > wrote: > > Are there any Python modules aimed specifically at this sort of > requirement? I tend to use JSON for this type of thing. Suggest that you use the options to pretty print the json that is saved so that a human can read it.

Re: Request: inspect: signature & getfullargspec & getcallargs

2023-12-04 Thread Barry Scott via Python-list
> On 4 Dec 2023, at 02:29, Dom Grigonis via Python-list > wrote: > > Hello, > > I have a request. > > Would it be possible to include `follow_wrapper_chains` and `skip_bound_arg` > arguments to higher level functions of `inspect` module? > > Would exposing them, but setting defaults to

Re: Silly (maybe) question re imported module(s)

2023-05-19 Thread Barry Scott
> On 19 May 2023, at 07:44, Grizzy Adams via Python-list > wrote: > > Morning All > > I'm working through the tutorial and running / saving work that I wish to > keep > and build on, most times I can save and (re)import later with no difference > to > when typed in console or editor and

Re: Windows Gui Frontend

2023-04-01 Thread Barry Scott
> On 1 Apr 2023, at 18:47, Igor Korot wrote: > > I suggest going with wxPython/wxGlade. I ported all my wxPython code to PyQt and have not regretted it. wxPython was (its been a while so may not be an issue now) far to hard to make consistent across OS, my apps run on Linux, macOS and

Re: Python not showing correct version

2023-04-01 Thread Barry Scott
> On 31 Mar 2023, at 22:02, Eryk Sun wrote: > > > The OP installed the standard Python 3.8 distribution, which does > install the launcher by default. The launcher can run all installed > versions, including store app installations. By default it runs the > highest available version, which

Re: Python not showing correct version

2023-03-31 Thread Barry Scott
; because of this I am not able to proceed with next steps. > > Thanks > Sumeet > > On Thu, 30 Mar 2023 at 22:45, Barry Scott <mailto:ba...@barrys-emacs.org>> wrote: >> >> >>> On 30 Mar 2023, at 15:17, Sumeet Firodia >> <mailto:ssfiro...@gmail.com&

Re: built-in pow() vs. math.pow()

2023-03-30 Thread Barry Scott
> On 30 Mar 2023, at 18:11, Barry Scott wrote: > > > >> On 30 Mar 2023, at 10:15, Andreas Eisele wrote: >> >> I sometimes make use of the fact that the built-in pow() function has an >> optional third argument for modulo calculation, which is handy whe

Re: Python not showing correct version

2023-03-30 Thread Barry Scott
> On 30 Mar 2023, at 15:17, Sumeet Firodia wrote: > >> >> Hi Team, >> >> I have installed Python 3.8 for Snowpark but when I check the version in >> command prompt it shows me Python 3.10.10. >> >> C:\Users\admin>python --version >> Python 3.10.10 Try this: py -3.8 And this to list all

Re: built-in pow() vs. math.pow()

2023-03-30 Thread Barry Scott
> On 30 Mar 2023, at 10:15, Andreas Eisele wrote: > > I sometimes make use of the fact that the built-in pow() function has an > optional third argument for modulo calculation, which is handy when dealing > with tasks from number theory, very large numbers, problems from Project > Euler,

Re: PyGILState_Release called twice in embedded application

2023-03-23 Thread Barry Scott
> On 23 Mar 2023, at 08:46, Arnaud Loonstra wrote: > > Hi all, > > I'm running in a crash due to a ResourceWarning (some socket is not closed in > a used module) after calling PyGILState_Release. > > I'm running Python in a native thread (so a thread created by C not Python). > I'm

Re: Is there a more efficient threading lock?

2023-02-26 Thread Barry Scott
On 25/02/2023 23:45, Jon Ribbens via Python-list wrote: I think it is the case that x += 1 is atomic but foo.x += 1 is not. No that is not true, and has never been true. :>>> def x(a): :...    a += 1 :... :>>> :>>> dis.dis(x)  1   0 RESUME   0  2   2

Re: file.read Method Documentation (Python 2.7.10)

2023-01-09 Thread Barry Scott
On 09/01/2023 14:34, Stephen Tucker wrote: Dear Python-list, Yes, I know that Python 2.x is no longer supported. I have found that the documentation for this method is misleading when the file being read is UTF-8-encoded: Instead of reading *size* bytes, the method reads *size *UTF-8

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott
On 03/01/2023 21:24, c.bu...@posteo.jp wrote: Am 03.01.2023 17:51 schrieb r...@zedat.fu-berlin.de: logging.getLogger().addHandler( logging.StreamHandler( sys.stdout )) But I don't want to make all log levels go to stdout. Just DEBUG and INFO. But this would be a workaround. The main

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott
On 03/01/2023 21:24, c.bu...@posteo.jp wrote: Am 03.01.2023 17:51 schrieb r...@zedat.fu-berlin.de: logging.getLogger().addHandler( logging.StreamHandler( sys.stdout )) But I don't want to make all log levels go to stdout. Just DEBUG and INFO. But this would be a workaround. The main

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott
On 04/01/2023 06:46, Chris Angelico wrote: I've known some systems to have a trigger of "reading on FD 0 flushes FD 1" C++ has this feature: Quote from https://en.cppreference.com/w/cpp/io/cin "Once |std::cin| is constructed, std::cin.tie() returns ::cout

Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-04 Thread Barry Scott
On 04/01/2023 02:26, Chris Angelico wrote: Reading/writing the FD is the same as using stdout (technically you'd write to fd 1 and read from fd 0), but yes, can use /dev/tty to reach for the console directly. I think the logic is more like checking that stdin is a tty then using the tty it

Re: Possible re bug

2022-12-29 Thread Barry Scott
Please please fix you email client so that your replies stay with the emails you are replying to. Barry On 28/12/2022 19:09, Stefan Ram wrote: Alexander Richert writes: |print(re.findall(".*","pattern")) |yields ['pattern',''] which is not what I was expecting. The asterisk is "greedy",

Re: Does one have to use curses to read single characters from keyboard?

2022-12-11 Thread Barry Scott
> On 11 Dec 2022, at 18:50, Chris Green wrote: > > My solution in the end was copied from one I found that was much > simpler and straightforward than most. I meant to post this earlier > but it got lost somewhere:- > >import sys, termios, tty ># ># ># Read a single character

Re: NEO6 GPS with Py PICO with micropython

2022-11-30 Thread Barry Scott
> On 30 Nov 2022, at 10:58, KK CHN wrote: > > List, > > Just commented the // gpsModule.readline() in the while loop, ( > refer the link > https://microcontrollerslab.com/neo-6m-gps-module-raspberry-pi-pico-micropython/ > ) > > > while True: # gpsModule.readline() // This line

Re: Python 3.11.0 installation and Tkinter does not work

2022-11-23 Thread Barry Scott
> On 23 Nov 2022, at 06:31, Stefan Ram wrote: > > darkst...@o2online.de writes: >> I want learn python for 4 weeks and have problems, installing Tkinter. If I= >> installed 3.11.0 for my windows 8.1 from python.org and type > > Ok, so you already installed from python.org. I wonder a >

Re: How to manage python shebang on mixed systems?

2022-11-07 Thread Barry Scott
> On 7 Nov 2022, at 09:28, Chris Green wrote: > > Chris Green wrote: >>> 3: with your pseudo "python3" script in place, make all the scripts use >>> the "#!/usr/bin/env python3" shebang suggested above. >>> >> Yes, that sounds a good plan to me, thanks Cameron. >> > Doesn't '#!/usr/bin/env

Re: Information about slow execution notebook

2022-11-01 Thread Barry Scott
> On 1 Nov 2022, at 16:08, nhlanhlah198506 wrote: > > I wish to know why sometimes my notebook won't execute my program And VS code > won't connect to kernels. Thank you Nhlanhla Ndwandwe Sent from my Galaxy You need to provide details on what you do and what happens. Reminder do not attach

Re: UTF-8 and latin1

2022-10-25 Thread Barry Scott
> On 25 Oct 2022, at 11:16, Stefan Ram wrote: > > r...@zedat.fu-berlin.de (Stefan Ram) writes: >> You can let Python guess the encoding of a file. >> def encoding_of( name ): >> path = pathlib.Path( name ) >> for encoding in( "utf_8", "cp1252", "latin_1" ): >> try: >> with path.open(

Re: Any PyQt developers here?

2022-10-25 Thread Barry Scott
There is an active PyQt mailing list that has lots of helpful and knowledgeable people on it. https://www.riverbankcomputing.com/mailman/listinfo/pyqt Barry > On 25 Oct 2022, at 18:03, DFS wrote: > > Having problems with removeRow() on a QTableView object. > > After calling removeRow(),

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-24 Thread Barry Scott
> On 8 Oct 2022, at 11:50, Weatherby,Gerard wrote: > > Logging does support passing a callable, if indirectly. It only calls __str__ > on the object passed if debugging is enabled. > > class Defer: > > def __init__(self,fn): > self.fn = fn > > def __str__(self): >

Re: Changing 'Scripts/*.exe'

2022-10-03 Thread Barry Scott
> On 1 Oct 2022, at 16:50, Gisle Vanem via Python-list > wrote: > > Hello list. > > I'm moved my old Python27 installation from > f:\ProgramFiler\Python27 ( == 'ProgramFiles') > to > f:\gv\Python27 The design of Windows installed software makes this hard to do without a lot of

Re: Python 3.9.14

2022-09-15 Thread Barry Scott
> On 14 Sep 2022, at 14:03, ⁨אורי⁩ <⁨u...@speedy.net⁩> wrote: > > Hi, > > Python 3.9.14 has been released on Sept. 6, 2022. As I can see written on > https://www.python.org/downloads/release/python-3914/: > > According to the release calendar specified in PEP 596, Python 3.9 is now > in the

Re: why I cannot to install packages?

2022-09-15 Thread Barry Scott
> On 15 Sep 2022, at 12:31, ⁨נתי שטרן⁩ <⁨nsh...@gmail.com⁩> wrote: > > [image: image.png] Images are stripped; please copy the text of the error you are seeing and post that. Barry > -- > https://mail.python.org/mailman/listinfo/python-list > --

Re: Simple TCP proxy

2022-07-30 Thread Barry Scott
Morten, As Chris remarked you need to learn a number of networking, python, system performance and other skills to turn your project into production code. Using threads does not scale very well. Its uses a lot of memory and raises CPU used just to do the context switches. Also the GIL means

Re: Python 3.9 pidfd_open

2022-07-08 Thread Barry Scott
> On 5 Jul 2022, at 19:47, Weatherby,Gerard wrote: > > python introduced os.pidfd_open(), which works as documented. > > My development environment, PyCharm, complains about it being undefined. > > Should it be in > https://raw.githubusercontent.com/python/cpython/3.9/Lib/os.py ? When

Re: Building on Windows

2022-07-02 Thread Barry Scott
> On 2 Jul 2022, at 15:41, Sam Ezeh wrote: > > To add to this, my process was > > 1. Setup the VM > 2. Install Git > 3. Clone CPython > 4. Run `PCbuild\build.bat -d -e` > 5. Notice the error, then install visual studio community 2022 Try running this: call "C:\Program Files\Microsoft

Re: Subtract n months from datetime [Why?]

2022-06-22 Thread Barry Scott
> On 22 Jun 2022, at 17:59, Paulo da Silva > wrote: > > Às 05:29 de 21/06/22, Paulo da Silva escreveu: > > As a general response to some comments ... > > Suppose we need to delete records from a database older than ... > Today, it's usual to specify days. For example you have to keep some

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

2022-06-22 Thread Barry Scott
> On 22 Jun 2022, at 11:06, Lars Liedtke wrote: > > Could be unrelated and only a part of a solution, but if you are on a unixoid > system, you could use logrotate, instead of TimedRotatingFileHandler. > logfrotate ensures that the logging service does not realize, its logs have > been

Re: How to replace characters in a string?

2022-06-08 Thread Barry Scott
> On 8 Jun 2022, at 18:01, Dave wrote: > > Hi, > > This is a tool I’m using on my own files to save me time. Basically or most > of the tracks were imported with different version iTunes over the years. > There are two problems: > > 1. File System characters are replaced (you can’t have

Re: How to test characters of a string

2022-06-08 Thread Barry Scott
> On 7 Jun 2022, at 23:24, Dave wrote: > > Yes, it was probably just a typeo on my part. > > I’ve now fixed the majority of cases but still got two strings that look > identical but fail to match, this time (again by 10cc), “I’m Mandy Fly Me”. > > I’m putting money on it being a utf8

Re: tail

2022-05-08 Thread Barry Scott
> On 8 May 2022, at 17:05, Marco Sulla wrote: > > I think I've _almost_ found a simpler, general way: > > import os > > _lf = "\n" > _cr = "\r" > > def tail(filepath, n=10, newline=None, encoding=None, chunk_size=100): >n_chunk_size = n * chunk_size Why use tiny chunks? You can read

Re: tail

2022-05-08 Thread Barry Scott
> On 7 May 2022, at 22:31, Chris Angelico wrote: > > On Sun, 8 May 2022 at 07:19, Stefan Ram wrote: >> >> MRAB writes: >>> On 2022-05-07 19:47, Stefan Ram wrote: >> ... def encoding( name ): path = pathlib.Path( name ) for encoding in( "utf_8", "latin_1", "cp1252" ):

Re: tail

2022-05-08 Thread Barry Scott
> On 7 May 2022, at 14:40, Stefan Ram wrote: > > Marco Sulla writes: >> So there's no way to reliably read lines in reverse in text mode using >> seek and read, but the only option is readlines? > > I think, CPython is based on C. I don't know whether > Python's seek function directly

Re: convenience

2022-03-23 Thread Barry Scott
> On 22 Mar 2022, at 18:00, Avi Gross via Python-list > wrote: > > An earlier post talked about a method they used for "convenience" in a way > they apparently did not understand and many of us educated them, hopefully. > > That made me wonder of teh impact on our code when we use various

Re: virtualenv and make DESTDIR=

2022-03-06 Thread Barry Scott
> On 5 Mar 2022, at 19:56, Hartmut Goebel wrote: > > Am 05.03.22 um 17:34 schrieb Barry Scott: >> Have the RPM install all the pythone code and dependencies and also install >> a short script that >> sets up PYTHONPATH, LD_LIBRARY_PATH, etc and execs the

Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott
> On 5 Mar 2022, at 19:56, Hartmut Goebel wrote: > > Am 05.03.22 um 17:34 schrieb Barry Scott: >> Have the RPM install all the pythone code and dependencies and also install >> a short script that >> sets up PYTHONPATH, LD_LIBRARY_PATH, etc and execs the python3 .py

Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott
> On 5 Mar 2022, at 19:56, Hartmut Goebel wrote: > > Am 05.03.22 um 17:34 schrieb Barry Scott: >> Have the RPM install all the pythone code and dependencies and also install >> a short script that >> sets up PYTHONPATH, LD_LIBRARY_PATH, etc and execs the python3 .py

Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott
> On 5 Mar 2022, at 16:59, Marco Sulla wrote: > > On Sat, 5 Mar 2022 at 17:36, Barry Scott wrote: >> Note: you usually cannot use pip when building an RPM with mock as the >> network is disabled inside the build for >> security reasons. > > Can't he previou

Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott
> On 4 Mar 2022, at 13:03, Hartmut Goebel wrote: > > Hi, > > How can I make installing a virtual environment honor DESTDIR? How can I > install a virtual environment in $(DESTDIR)$(PREFIX), which behaves as being > set-up in $(PREFIX)? (Of course, this virtual environment can not be used.

Re: Getting Syslog working on OSX Monterey

2022-03-05 Thread Barry Scott
> On 4 Mar 2022, at 21:23, Peter J. Holzer wrote: > > On 2022-02-28 22:05:05 +0000, Barry Scott wrote: >> On 28 Feb 2022, at 21:41, Peter J. Holzer wrote: >>> On 2022-02-27 22:16:54 +, Barry wrote: >>>> I have always assumed that if I want a logger sy

Re: Getting Syslog working on OSX Monterey

2022-03-03 Thread Barry Scott
g > logging.handlers.SysLogHandler with a config in /etc/asl/ to define how it > should be routed and the rollover/cleanup frequency. > > Thanks for replying, just having trouble understanding. > > > On Mon, Feb 28, 2022 at 2:07 PM Barry Scott <mailto:ba...@barrys-emac

Re: Behavior of the for-else construct

2022-03-03 Thread Barry Scott
> On 3 Mar 2022, at 13:24, computermaster360 > wrote: > > I want to make a little survey here. > > Do you find the for-else construct useful? No. I always have to look up what condition the else fires on. > Have you used it in > practice? No. > Do you even know how it works, or that

Re: Getting Syslog working on OSX Monterey

2022-02-28 Thread Barry Scott
> On 28 Feb 2022, at 21:41, Peter J. Holzer wrote: > > On 2022-02-27 22:16:54 +, Barry wrote: >> If you look at the code of the logging modules syslog handle you will see >> that >> it does not use syslog. It’s assuming that it can network to a syslog >> listener. >> Such a listener is

Re: ping script

2022-02-27 Thread Barry Scott
> On 27 Feb 2022, at 13:53, Byung-Hee HWANG wrote: > > simple ping check script with python3 (Python 3.9.2) > tested under Debian 11 Bullseye: > > soyeomul@penguin:~/gitlab/test$ ./fping.py localhost > ok > soyeomul@penguin:~/gitlab/test$ ./fping.py python.org > ok >

Re: One-liner to merge lists?

2022-02-27 Thread Barry Scott
> On 22 Feb 2022, at 09:30, Chris Angelico wrote: > > On Tue, 22 Feb 2022 at 20:24, Frank Millman > wrote: >> >> Hi all >> >> I think this should be a simple one-liner, but I cannot figure it out. >> >> I have a dictionary with a number of keys, where each value

Re: Best way to check if there is internet?

2022-02-25 Thread Barry Scott
> On 25 Feb 2022, at 18:07, Abdur-Rahmaan Janhangeer > wrote: > > Normally people put Python in the scripting category. > I learnt typed languages like C++ and Java at first. > People who learn languages like these tend to put > Python in a non-serious category. The post was > more ironic

Re: venv and executing other python programs

2022-02-15 Thread Barry Scott
> On 15 Feb 2022, at 12:36, Martin Di Paola wrote: > > I did a few experiments in my machine. I created the following foo.py > > import pandas > print("foo") > > Now "pandas" is installed under Python 3 outside the venv. I can run it > successfully calling "python3 foo.py". > > If I add

Re: venv and executing other python programs

2022-02-14 Thread Barry Scott
> On 15 Feb 2022, at 05:35, Mirko via Python-list > wrote: > > Hi, > > I have recently started using venv for my hobby-programming. There > is an annoying problem. Since venv modifies $PATH, python programs > that use the "#!/usr/bin/env python" variant of the hashbang often > fail since

Re: Data unchanged when passing data to Python in multiprocessing shared memory

2022-02-02 Thread Barry Scott
> On 1 Feb 2022, at 23:40, Jen Kris wrote: > > Barry, thanks for your reply. > > On the theory that it is not yet possible to pass data from a non-Python > language to Python with multiprocessing.shared_memory, I bypassed the problem > by attaching 4 bytes to my FIFO pipe message from

Re: Puzzling behaviour of Py_IncRef

2022-01-27 Thread Barry Scott
> On 27 Jan 2022, at 07:46, Tony Flury wrote: > > > On 26/01/2022 22:41, Barry wrote: >> >> >> Run python and your code under a debugger and check the ref count of the >> object as you step through the code. >> >> Don’t just step through your code but also step through the C python code.

Re: How to test for maildir 'folder' in Python?

2022-01-23 Thread Barry Scott
> On 22 Jan 2022, at 21:26, Chris Green wrote: > > I have a script that walks a quite deep tree of mail messages to find > and archive old messages. I'm trying to convert it from mbox to > maildir (as I now store my mail in maildir format). > > So I need to test whether a point I have

Re: Puzzling behaviour of Py_IncRef

2022-01-19 Thread Barry Scott
> On 19 Jan 2022, at 10:57, Tony Flury via Python-list > wrote: > > I am writing a C extension module for an AVL tree, and I am trying to ensure > reference counting is done correctly. I was having a problem with the > reference counting so I worked up this little POC of the problem, and I

Re: Why There Is No Python Compressed Archive or Binaries ?

2022-01-17 Thread Barry Scott
> On 17 Jan 2022, at 19:53, Sina Mobasheri wrote: > > Consider scenario that I want run python 3.10 in CentOS 8, I think last > python version in CentOS repository is 3.6, if I use epel I can get 3.8 so > ..., I think (correct me if I'm wrong ) the only way that I can run python > 3.10 is

Re: Who wrote Py_UNREACHABLE?

2022-01-02 Thread Barry Scott
> On 2 Jan 2022, at 16:17, Marco Sulla wrote: > > #if defined(RANDALL_WAS_HERE) > # define Py_UNREACHABLE() \ >Py_FatalError( \ >"If you're seeing this, the code is in what I thought was\n" \ >"an unreachable state.\n\n" \ >"I could give you advice for what to do,

Re: recover pickled data: pickle data was truncated

2022-01-02 Thread Barry Scott
> On 1 Jan 2022, at 16:13, Marco Sulla wrote: > > I agree with Barry. You can create a folder or a file with > pseudo-random names. I recommend you to use str(uuid.uuid4()) At work and personally I use iso-8601 timestamps to make the files unique and easy to find out when they where created.

Re: recover pickled data: pickle data was truncated

2021-12-26 Thread Barry Scott
> On 26 Dec 2021, at 13:44, Marco Sulla wrote: > > Use a semaphore. > > On Sun, 26 Dec 2021 at 03:30, iMath wrote: >> >> Normally, the shelve data should be read and write by only one process at a >> time, but unfortunately it was simultaneously read and write by two >> processes, thus

Re: Uninstall old python version(Python 3.9.7)

2021-12-26 Thread Barry Scott
> On 25 Dec 2021, at 06:13, Công Huy wrote: > > I had uninstalled Python 3.9.7 before but it wasn't uninstalled > completely. I found it still in my computer and when I click "uninstall", > it sent me a board "No Python 3.9 installation was detected". Of course, > it won't be an issue

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

2021-12-26 Thread Barry Scott
> On 26 Dec 2021, at 13:48, Marco Sulla wrote: > > I have to use _PyObject_GC_IS_TRACKED(). It can't be used unless you > define Py_BUILD_CORE. I want to avoid this. What macro or function can > substitute it? Why is this needed by your code? Surely the GC does its thing as an

Re: Selection sort

2021-12-24 Thread Barry Scott
> On 24 Dec 2021, at 14:22, vani arul wrote: > > Hello, > I am trying write a code.Can some help me find the error in my code. > Thanks! > > > def selectionsort(arr): > # le=len(arr) >for b in range(0,len(arr)-1): >pos=b >for a in range(b+1,len(arr)-1): >if

Re: Py_TRASHCAN_SAFE_BEGIN/END in C extension?

2021-12-22 Thread Barry Scott
> On 22 Dec 2021, at 08:14, Marco Sulla wrote: > > Yes, it's deprecated, but I need it for Python 3.7, since there was > yet no Py_TRASHCAN_BEGIN / END Hopefully the bug report will makes clear what you have to do in your code to get things working. Barry > > On Tue, 21 Dec 2021 at 23:22,

Re: Python child process in while True loop blocks parent

2021-12-09 Thread Barry Scott
> On 8 Dec 2021, at 17:11, Jen Kris wrote: > > I started this post on November 29, and there have been helpful comments > since then from Barry Scott, Cameron Simpson, Peter Holzer and Chris > Angelico. Thanks to all of you. > > I've found a solution that works for m

Re: Python child process in while True loop blocks parent

2021-12-06 Thread Barry Scott
> On 6 Dec 2021, at 21:05, Jen Kris wrote: > > Here is what I don't understand from what you said. "The child process is > created with a single thread—the one that called fork()." To me that implies > that the thread that called fork() is the same thread as the child process. > I guess

Re: threading and multiprocessing deadlock

2021-12-06 Thread Barry Scott
> On 5 Dec 2021, at 23:50, Johannes Bauer wrote: > > Hi there, > > 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 >

Re: Python child process in while True loop blocks parent

2021-12-06 Thread Barry Scott
> On 6 Dec 2021, at 17:09, Jen Kris via Python-list > wrote: > > I can't find any support for your comment that "Fork creates a new > process and therefore also a new thread." From the Linux man pages > https://www.man7.org/linux/man-pages/man2/fork.2.html, "The child process is > created

Re: Python child process in while True loop blocks parent

2021-12-04 Thread Barry Scott
> On 1 Dec 2021, at 16:01, Jen Kris wrote: > > Thanks for your comment re blocking. > > I removed pipes from the Python and C programs to see if it blocks without > them, and it does. > It looks now like the problem is not pipes. Ok. > I use fork() and execv() in C to run Python in a

Re: Python child process in while True loop blocks parent

2021-11-30 Thread Barry Scott
> On 29 Nov 2021, at 22:31, Jen Kris wrote: > > Thanks to you and Cameron for your replies. The C side has an epoll_ctl set, > but no event loop to handle it yet. I'm putting that in now with a pipe > write in Python-- as Cameron pointed out that is the likely source of > blocking on C.

Re: Eventfd with epoll BlockingIOError

2021-11-27 Thread Barry Scott
> On 25 Nov 2021, at 22:29, jenk...@tutanota.com wrote: > > Thanks very much for your reply. > > I am now getting a single event returned in Python, but it's not the right > event, as I'll explain below. > > I rearranged the Python code based on your comments: > > #!/usr/bin/python3 >

Re: pyinstaller wrong classified as Windows virus

2021-11-25 Thread Barry Scott
> On 25 Nov 2021, at 09:20, Ulli Horlacher > wrote: > > When I compile my programs with pyinstaller, Windows classifies them as > virus and even deletes them! Microsoft will fix the malware detection if you provide the info they need. Submit false positive info to:

Re: Eventfd with epoll BlockingIOError

2021-11-25 Thread Barry Scott
> On 24 Nov 2021, at 22:42, Jen via Python-list wrote: > > I have a C program that uses fork-execv to run Python 3.10 in a child > process, and I am using eventfd with epoll for IPC between them. The eventfd > file descriptor is created in C and passed to Python through execv. Once the >

Re: Using astype(int) for strings with thousand separator

2021-11-14 Thread Barry Scott
> On 14 Nov 2021, at 15:41, Mahmood Naderan via Python-list > wrote: > > Hi > > While reading a csv file, some cells have values like '1,024' which I mean > they contains thousand separator ','. Therefore, when I want to process them > with > > row = df.iloc[0].astype(int) remove the

Re: Unable to compile my C Extension on Windows: unresolved external link errors

2021-11-14 Thread Barry Scott
ange any conflicting symbols of course. Barry > > On Sat, 13 Nov 2021 at 12:17, Marco Sulla > wrote: >> >> . Sorry, the problem is I downloaded the 32 bit version of VS >> compiler and 64 bit version of Python.. >> >> On Sat, 13 Nov 2021 at

Re: Unable to compile my C Extension on Windows: unresolved external link errors

2021-11-13 Thread Barry Scott
> On 13 Nov 2021, at 09:00, Barry wrote: > > > >> On 12 Nov 2021, at 22:53, Marco Sulla wrote: >> >> It seems that on Windows it doesn't find python3.lib, >> even if I put it in the path. So I get the `unresolved external link` >> errors. > > I think you need the python310.lib (not sure

Re: Definitive guide for Regex

2021-10-02 Thread Barry Scott
ry > > Regards, > > David > > On Thu, 30 Sept 2021 at 22:02, Barry Scott <mailto:ba...@barrys-emacs.org>> wrote: > > > > On 30 Sep 2021, at 19:35, dn via Python-list > <mailto:python-list@python.org>> wrote: > > > > On 01/10/202

Re: Definitive guide for Regex

2021-09-30 Thread Barry Scott
> On 30 Sep 2021, at 19:35, dn via Python-list wrote: > > On 01/10/2021 06.16, Barry Scott wrote: >> >> >>> On 30 Sep 2021, at 12:29, Shaozhong SHI wrote: >>> >>> Dear All, >>> >>> I am trying to look for a definitive gu

Re: Definitive guide for Regex

2021-09-30 Thread Barry Scott
> On 30 Sep 2021, at 12:29, Shaozhong SHI wrote: > > Dear All, > > I am trying to look for a definitive guide for Regex in Python. > Can anyone help? Have you read the python docs for the re module? Barry > > Regards, > > David > -- >

Re: basic auth request

2021-08-25 Thread Barry Scott
> On 22 Aug 2021, at 12:03, Chris Angelico wrote: > > On Sun, Aug 22, 2021 at 8:30 PM Barry Scott <mailto:ba...@barrys-emacs.org>> wrote: >> >> >> >> On 22 Aug 2021, at 10:37, Chris Angelico wrote: >> >> When it comes to security, on

Re: basic auth request

2021-08-22 Thread Barry Scott
> On 22 Aug 2021, at 10:37, Chris Angelico wrote: > > When it comes to security, one thing I'm very curious about is why we > don't have any sort of certificate renewal verification. My browser > could retain the certificates of some web site (or of all web sites, > even - they're not THAT

Re: basic auth request

2021-08-17 Thread Barry Scott
On Tuesday, 17 August 2021 10:20:37 BST Robin Becker wrote: > While porting an ap from python2.7 to python3 I see this > > base64string = base64.b64encode('%s:%s' % (wsemail, wspassword)) > request.add_header("Authorization", "Basic %s" % base64string) > > in python3.x I find this

Re: Cyclic imports

2021-08-17 Thread Barry Scott
On Monday, 16 August 2021 16:13:47 BST Dan Stromberg wrote: > Hi folks. > > I'm working on a large codebase that has at least one cyclic import. > > In case I end up needing to eliminate the cyclic imports, is there any sort > of tool that will generate an import graph and output Just the

Re: Optimizing Small Python Code

2021-06-24 Thread Barry Scott
> On 24 Jun 2021, at 16:58, Avi Gross via Python-list > wrote: > > Now a has a length of 53! > > It now looks like this: > > b'x\x9c3\xe4R\x00\x03\x03.#8\x0bB\x1br\x19c\x88(\x18q\x99p!q\xc1\x00\xa6\xd1\x98\xcb\x14S\x03\x9a\n\x13.3\x82j > \xb4\t\x94\x86\x99\t\x00\xdc\x87\x14\xb7' > > So

Re: Interpreter Bug

2021-06-02 Thread Barry Scott
> On 2 Jun 2021, at 10:34, Alice Braim wrote: > > Good morning- > > > > I am having some very serious issues with Python, and I was hoping you > could help? > > I downloaded both Python and PyCharm, and the 2 do not seem to be working. > Every time I select Python as an

Re: 3.7.6 struggles a bit

2021-06-02 Thread Barry Scott
> On 2 Jun 2021, at 18:18, Luke wrote: > > When i wrote a program, i tried to open it but it struggles to open. I'm guessing you are a Windows user. Does this help? https://docs.python.org/3/faq/windows.html Barry --

  1   2   3   >