Re: Linux shell to python

2012-07-30 Thread Barry Scott
lspci gets all its information from the files in /sys/bus/pci/devices. You can use os.listdir() to list all the files in the folder and then open the files you want to get the data you need. And of course you can write list comprehensions on as many lines as it take to make the code maintainable.

Re: Linux shell to python

2012-07-31 Thread Barry Scott
On 30 Jul 2012, at 23:56, Dan Stromberg wrote: > > On Mon, Jul 30, 2012 at 9:26 PM, Barry Scott wrote: > lspci gets all its information from the files in /sys/bus/pci/devices. > > You can use os.listdir() to list all the files in the folder and then open > the files y

Re: Python does not take up available physical memory

2012-10-22 Thread Barry Scott
On 21 Oct 2012, at 15:14, Pradipto Banerjee wrote: > I tried this on a different PC with 12 GB RAM. As expected, this time, > reading the data was no issue. I noticed that for large files, Python takes > up 2.5x size in memory compared to size on disk, for the case when each line > in the fil

Re: Missing something obvious with python-requests

2013-01-03 Thread Barry Scott
The shipped python library code does not work. See http://bugs.python.org/issue7291 for patches. Barry On 3 Jan 2013, at 18:53, Ray Cote wrote: > Hello List: > > I seem to be missing something obvious in terms of using proxies with the > requests module. > I'm using requests 1.4 and Python

Re: Using mktime to convert date to seconds since epoch - omitting elements from the tuple?

2013-01-03 Thread Barry Scott
On 2 Jan 2013, at 08:01, Victor Hooi wrote: > Hi, > > I'm using pysvn to checkout a specific revision based on date - pysvn will > only accept a date in terms of seconds since the epoch. > > I'm attempting to use time.mktime() to convert a date (e.g. "2012-02-01) to > seconds since epoch. >

Re: Forcing Python to detect DocumentRoot

2013-01-19 Thread Barry Scott
On 16 Jan 2013, at 13:51, Ferrous Cranus wrote: > When trying to open an html template within Python script i use a relative > path to say go one folder back and open index.html > > f = open( '../' + page ) > > How to say the same thing in an absolute way by forcing Python to detect > Docume

Re: python: HTTP connections through a proxy server requiring authentication

2013-01-28 Thread Barry Scott
The shipped python library code does not work. See http://bugs.python.org/issue7291 for patches. Barry -- http://mail.python.org/mailman/listinfo/python-list

Re: How to call and execute C code in Python?

2012-05-16 Thread Barry Scott
There are many choices rather then raw python C API calls. Boost, PyCXX and ctypes are worth investigating. PyCXX requires you code in C++ but hides lots of the issues of using the Python API from you. It also supports python 2 and 3. Barry - PyCXX maintainer -- http://mail.python.org/mailma

Re: How to import Webkit and object in Official Python (not MacPorts python) without X11.

2012-05-26 Thread Barry Scott
On 26 May 2012, at 14:31, Mr.T Beppu wrote: > I think that I will make a browser in Official Python (not MacPorts Python). > What should I do in order to install Webkit for Official Python (not MacPorts > Python) ? > from tokyo Japan. > -- > http://mail.python.org/mailman/listinfo/python-list

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 call

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 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 4K

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 problem

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

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 go

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 Visual

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 face

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 tha

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 > -- https://mail.python.org/mailman/listinfo/p

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 "s

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 knowledge

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

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(), the

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( encoding=e

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

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 comm

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: 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", so

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 to

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 &std::cout

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 quest

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 quest

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 byt

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 LOAD_FAST

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 acquiri

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

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 v

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-31 Thread Barry Scott
ause 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: 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 wi

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 Window

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: Exploring terminfo

2021-01-14 Thread Barry Scott
> On 14 Jan 2021, at 16:12, Alan Gauld via Python-list > wrote: > > During lockdown I've been digging deeper into the curses module > and lately into the ti family of functions that reside there. > > I've written a short program that is supposed to > - *clear the screen*, > - read some i

Re: Question - problem downloading Python

2021-01-14 Thread Barry Scott
> On 14 Jan 2021, at 06:52, christine tiscareno wrote: > > I installed in my lap-top your latest version of Python (3.9.1), yet when I > go to cmd.exe to check, I get that I have Python 22.7.17 ??? > > Why? What should I do to get the latest version? > > I tried going back to fix problem

Re: sqlite3 cannot detect the version of compiled sqlite version at some point in runtime.

2021-01-20 Thread Barry Scott
> On 20 Jan 2021, at 19:54, panfei wrote: > > System environment: > > Cent OS 7 > Sqlite3 3.34.0 (Compile from source) > Python 3.9.1 (Compile from source) > Django 3.1.5 (Pip install) > > > 1. Compile sqlite3: > ./configure --prefix=/home/felix/.local/sqlite/sqlite-3.34.0 > make && make in

Re: c bindings with non-python thread callback while python exits

2021-01-26 Thread Barry Scott
> On 26 Jan 2021, at 14:35, Paul Grinberg wrote: > > I have a C++ library (luckily with source code, so I know what's going on) to > which I wrote c bindings. The library internally starts an event pthread > which generates callbacks back into python. The c binding for processing > these ca

Re: imalib cant get From: adresses

2021-01-27 Thread Barry Scott
Sigh you use a damaged email address for reply does not work. > On 27 Jan 2021, at 14:30, Bischoop wrote: > > > I don't have much experience with imaplib and for a few days can't > manage to get properly, I followed also some tutorial but also met few > problems. > What I want is to get email a

Re: _Py_FatalErrorFunc not found

2021-01-28 Thread Barry Scott
> On 28 Jan 2021, at 09:48, Klaus Dittrich wrote: > > > I need some help. > > hplip as of late complains : > > File "/usr/bin/hp-scan", line 40, in >import scanext > ImportError: /usr/lib/python3.9/site-packages/scanext.so: undefined symbol: > _Py_FatalErrorFunc > > Which module defi

Re: Best practice for handling exceptions raised at lower levels?

2021-02-02 Thread Barry Scott
> On 2 Feb 2021, at 00:54, Skip Montanaro wrote: > > I'm curious if there are best practices for handling exceptions raised > by lower level modules and packages. For example, I wrote an > application called polly[1] which constructs a personalized dictionary > from email messages using IMAP4.

Re: Best practice for handling exceptions raised at lower levels?

2021-02-02 Thread Barry Scott
> On 2 Feb 2021, at 20:24, Dan Stromberg wrote: > > > > On Tue, Feb 2, 2021 at 12:00 PM Barry Scott <mailto:ba...@barrys-emacs.org>> wrote: > When I write packages I aim to trap the exceptions from the lower levels > and convert into a package specific exc

Re: Venv behaviour change py3.9

2021-02-14 Thread Barry Scott
> On 14 Feb 2021, at 09:42, Abdur-Rahmaan Janhangeer > wrote: > > Greetings all, > > on 3.7 when i do > > $ python -m venv venv > > it creates a venv in venv folder > > but on 3.9 it returns no such file or directory > > os: windows. Any ideas on why the behaviour changes? I did this on

Re: Why assert is not a function?

2021-03-03 Thread Barry Scott
> On 3 Mar 2021, at 17:35, David Lowry-Duda wrote: > >> assert condition, expression >> >> Only is condition is false with expression be evaluated. >> So you can safely do expensive things I the expression with incuring >> and cost if the condition is True. > > I think I've only every used

Re: Why assert is not a function?

2021-03-03 Thread Barry Scott
> On 3 Mar 2021, at 18:41, Chris Angelico wrote: > > On Thu, Mar 4, 2021 at 5:25 AM Barry Scott <mailto:ba...@barrys-emacs.org>> wrote: >> >> >> >>> On 3 Mar 2021, at 17:35, David Lowry-Duda wrote: >>> >>>> asser

Re: Determine what the calling program is

2021-04-19 Thread Barry Scott
> On 18 Apr 2021, at 14:46, Jason Friedman wrote: > > I should state at the start that I have a solution to my problem. I am > writing to see if there is a better solution. > > I have a program that runs via crontab every five minutes. It polls a > Box.com folder for files and, if any are fou

Re: "py.ini" question

2021-04-24 Thread Barry Scott
> On 24 Apr 2021, at 15:23, Gisle Vanem wrote: > > I have a question about the Python launcher; > c:\Windows\py.exe and the py.ini file. > > I have both Python 3.6 (32-bit) and Python 3.8 (64-bit) > installed. And I have a 'c:\Users\Gisle\AppData\Local\py.ini' > with this only: > [defaults]

Re: "py.ini" question

2021-04-26 Thread Barry Scott
> On 24 Apr 2021, at 20:56, Gisle Vanem wrote: > > On that, I'm getting: > Requested Python version (0) not installed > > Is that '-0' some 3.9+ feature? No its a lot older then 3.9 I cannot remember when -0 was first supported but I've been using -0 for a long long time. I using the explo

Re: "py.ini" question

2021-04-26 Thread Barry Scott
> On 26 Apr 2021, at 09:13, Gisle Vanem wrote: > > Thank for confirming what I suspected. And as I wrote earlier: > Since I'm on a 64-bit Python, a 'py -3' totally seems to ignore > 'py.ini', unless it says: >[defaults] >python3=3.6 >python3=3.6-32 You can prove that py.ini is i

Re: async watch directory for new files

2021-04-26 Thread Barry Scott
> On 24 Apr 2021, at 21:12, Zoran wrote: > > As I can see https://pypi.org/project/inotify/ > is not asyncio frendly. > Whatever I use, it should be asynchronous. > Final OS is linux (Centos 7), but I am doing development on Windows 10 > machine, so it wo

Re: Standarize TOML?

2021-05-17 Thread Barry Scott
> On 15 May 2021, at 23:39, Jason C. McDonald wrote: > > During the Steering Committee presentation at PyCon, it was mentioned > that no one has formally proposed TOML be added to the standard library > (emphasis on formal). THe joke went forth that there would be a flood > of proposals to tha

Re: f-strings and internationalisation.

2021-05-24 Thread Barry Scott
> On 24 May 2021, at 19:30, Antoon Pardon wrote: > > I have now come across several occasion where an author advice the use > of f-strings above the %-formatting and the format method. However it > seems these authors were only thinking about rather straight forward > english communication. >

Re: Definition of "property"

2021-05-30 Thread Barry Scott
> On 30 May 2021, at 17:57, Irv Kalb wrote: > > I am doing some writing (for an upcoming book on OOP), and I'm a little > stuck. > > I understand what a "property" is, how it is used and the benefits, but > apparently my explanation hasn't made the light bulb go on for my editor. > The

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 -- https://mail.python.org/

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 interpret

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 th

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 cycles?

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 wor

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 lar

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

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-10-02 Thread Barry Scott
Barry > > 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/1

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 o

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

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: https://www.microsoft.co

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

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

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 child

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 w

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

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 y

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

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

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 i

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 co

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

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

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 the

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

  1   2   3   4   >