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

2024-07-07 Thread MRAB via Python-list
On 2024-07-07 23:27, Barry via Python-list wrote: On 7 Jul 2024, at 22:13, Chris Green via Python-list wrote: a simple file lock can then be used to prevent simultaneous access (well, simultaneous access when the writing process is writing). There is a simple pattern to make this robust.

Re: Decoding bytes to text strings in Python 2

2024-06-23 Thread MRAB via Python-list
On 2024-06-24 00:30, Chris Angelico via Python-list wrote: On Mon, 24 Jun 2024 at 08:20, Rayner Lucas via Python-list wrote: In article , ros...@gmail.com says... > > If you switch to a Linux system, it should work correctly, and you'll > be able to migrate the rest of the way onto Python 3.

Re: Timezone in HH:MM Format

2024-06-18 Thread MRAB via Python-list
On 2024-06-19 00:32, Ivan "Rambius" Ivanov via Python-list wrote: Hello, How can I convert a date, usually datetime.now(), into a format where the timezone is in hours:minutes format. I was able to get that format in shell: $ date +%Y-%m-%dT%H:%M:%S%:z 2024-06-18T19:24:09-04:00 The closest I

Re: win32clipboard writing to clipboard on Windows 11

2024-06-17 Thread MRAB via Python-list
On 2024-06-17 20:27, Rob Cliffe via Python-list wrote: Recently I acquired a new laptop running WIndows 11; my previous one uses WIndows 10.  I encountered a strange problem: I am using the win32clipboard backage (part of pywin32), and when I use SetClipboardData() to write text which consists

Re: Couldn't install numpy on Python 2.7

2024-06-12 Thread MRAB via Python-list
On 2024-06-12 17:31, AVI GROSS via Python-list wrote: I am sure there is inertia to move from an older product and some people need a reason like this where the old becomes untenable. It seems Microsoft is having a problem where something lik 2/3 of Windows users have not upgraded from Windows

Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))

2024-06-09 Thread MRAB via Python-list
On 2024-06-09 22:20, HenHanna via Python-list wrote: Chunk, ChunkC -- nice simple way(s) to write these in Python? (Chunk '(a a ba a a b b)) ==> ((a a) (b) (a a a) (b b)) (Chunk '(a a a a b c c a a d e e e e)) ==> ((a a a a) (b) (c c) (a a) (d) (e e e e))

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

2024-05-29 Thread MRAB via Python-list
On 2024-05-29 15:32, Thomas Passin via Python-list wrote: On 5/29/2024 8:55 AM, Kevin M. Wilson wrote: Please recall, I said the format for the email failed to retain the proper indents. I'll attach a picture of the code! Purpose; to uppercase every other letter in a string. Thanks all, KMW

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

2024-05-29 Thread MRAB via Python-list
On 2024-05-29 05:33, Kevin M. Wilson via Python-list wrote: The following is my effort to understand how to process a string, letter, by letter: def myfunc(name):        index = 0    howmax = len(name)    # while (index <= howmax):    while (index < howmax):        if (index % 2 == 0):         

Re: Terminal Emulator (Posting On Python-List Prohibited)

2024-05-19 Thread MRAB via Python-list
On 2024-05-19 19:13, Gilmeh Serda via Python-list wrote: On Sun, 19 May 2024 08:32:46 +0100, Alan Gauld wrote: I've honestly never experienced this "nightmare". I install stuff and it just works. Hear! Hear! Me too! And all that. I'm on Manjaro, which is a tad finicky about other people

Re: Version of NymPy

2024-05-15 Thread MRAB via Python-list
On 2024-05-15 19:42, Popov, Dmitry Yu via Python-list wrote: What would be the easiest way to learn which version of NumPy I have with my Anaconda distribution? Import numpy and print its '__version__' attribute. -- https://mail.python.org/mailman/listinfo/python-list

Re: Running issues

2024-04-05 Thread MRAB via Python-list
On 2024-04-05 22:32, shannon makasale via Python-list wrote: Hi there, My name is Shannon. I installed Python 3.12 on my laptop a couple months ago, but realised my school requires me to use 3.11.1. I uninstalled 3.12 and installed 3.11.1. Unfortunately, I am unable to run python now. It

Re: Can you help me with this memoization simple example?

2024-03-31 Thread MRAB via Python-list
t in cache: cache[key] = f(args[0], args[1]) return cache[key] return g Anything else is good in my code ? Thanks Le dim. 31 mars 2024 à 01:44, MRAB via Python-list a écrit : On 2024-03-31 00:09, marc nicole via Python-list wrote: > I am creating a memoization example wi

Re: Can you help me with this memoization simple example?

2024-03-30 Thread MRAB via Python-list
On 2024-03-31 00:09, marc nicole via Python-list wrote: I am creating a memoization example with a function that adds up / averages the elements of an array and compares it with the cached ones to retrieve them in case they are already stored. In addition, I want to store only if the result of

Re: xkcd.com/353 ( Flying with Python )

2024-03-30 Thread MRAB via Python-list
On 2024-03-30 11:25, Skip Montanaro via Python-list wrote: > https://xkcd.com/1306/ > what does SIGIL mean? I think its' a Perl term, referring to the $/@/# symbols in front of identifiers. I had a vague recollection of hearing it elsewhere (*Game of Thrones,*

Re: the name ``wheel''

2024-03-21 Thread MRAB via Python-list
On 2024-03-21 11:36, Johanne Fairchild via Python-list wrote: Why is a whl-package called a ``wheel''? Is it just a pronunciation for the extension WHL or is it really a name? Also, it seems that when I install Python on Windows, it doesn't come with pip ready to run. I had to say python

Re: If a dictionary key has a Python list as its value!

2024-03-07 Thread MRAB via Python-list
On 2024-03-07 14:11, Varuna Seneviratna via Python-list wrote: If a dictionary key has a Python list as its value, you can read the values one by one in the list using a for-loop like in the following. d = {k: [1,2,3]} for v in d[k]: print(v) No tutorial describes this, why? What is

Re: Can u help me?

2024-03-05 Thread MRAB via Python-list
On 2024-03-06 01:44, Ethan Furman via Python-list wrote: On 3/5/24 16:49, MRAB via Python-list wrote: > On 2024-03-06 00:24, Ethan Furman via Python-list wrote: >> On 3/5/24 16:06, Chano Fucks via Python-list wrote: >> >>> [image: image.png] >>

Re: Can u help me?

2024-03-05 Thread MRAB via Python-list
On 2024-03-06 00:24, Ethan Furman via Python-list wrote: On 3/5/24 16:06, Chano Fucks via Python-list wrote: [image: image.png] The image is of MS-Windows with the python installation window of "Repair Successful". Hopefully somebody better at explaining that problem can take it from

Re: Can u help me?

2024-03-05 Thread MRAB via Python-list
On 2024-03-06 00:06, Chano Fucks via Python-list wrote: [image: image.png] This list removes all images. -- https://mail.python.org/mailman/listinfo/python-list

Re: Problem resizing a window and button placement

2024-02-25 Thread MRAB via Python-list
On 2024-02-25 21:19, Steve GS via Python-list wrote: SOLUTION FOUND! The fix was to write the code that uses the width value and to place it into the function itself. Kluge? Maybe but it works. Mischief Managed. As for the most recent suggestion, it fails for me:

Re: Problem resizing a window and button placement

2024-02-24 Thread MRAB via Python-list
On 2024-02-25 02:51, Steve GS wrote: import tkinter as tk #global Ww Neither global helps def on_configure(*args): # print(args) #global Ww Neither global helps Ww = root.winfo_width() print("WwInside = <" + str(Ww) + ">") root = tk.Tk() root.bind('', on_configure)

Re: Problem resizing a window and button placement

2024-02-24 Thread MRAB via Python-list
On 2024-02-25 00:33, Steve GS via Python-list wrote: "Well, yes, in Python a variable created inside a function or method is local to that function unless you declare it global." Yes, I knew that. I tried to global it both before the function call and within it. Same for when I created the

Re: Problem resizing a window and button placement

2024-02-23 Thread MRAB via Python-list
On 2024-02-24 01:14, Steve GS via Python-list wrote: Python, Tkinter: How do I determine if a window has been resized? I want to locate buttons vertically along the right border and need to know the new width. The buttons are to move with the change of location of the right-side border. Bind

Re: Using __new__

2024-02-17 Thread MRAB via Python-list
On 2024-02-17 22:35, Jonathan Gossage via Python-list wrote: I am attempting to use the __new__ method in the following code: class SingletonExample(object): _instance = None def __new__(cls, **kwargs): if cls._instance is None: cls._instance =

Re: A question about import

2024-02-16 Thread MRAB via Python-list
On 2024-02-16 20:07, Gabor Urban via Python-list wrote: Hi guys, I need something about modules to be clarified. Suppose I have written a module eg: ModuleA which imports an other module, let us say the datetime. If I import ModuleA in a script, will be datetime imported automatically? Yes.

Re: test-ignore

2024-02-15 Thread MRAB via Python-list
On 2024-02-16 00:29, Skip Montanaro via Python-list wrote: > Test post to see if my Newsgroup post program is working. Aim your test messages at alt.test, please. I agree that basic Usenet connectivity messages should go to alt.test. It's not clear from the original post, but if the

Re: Error pd.set_option('display.width', 10000)

2024-02-03 Thread MRAB via Python-list
On 2024-02-03 23:02, gelukt gelukt via Python-list wrote: Dear, While running a code, I get the error below: What does this error mean? How can I fix this error? C:\Users\brech\Desktop\Crypto\venv\Scripts\python.exe "C:/Users/brech/Desktop/Crypto/Project/aaa Arbitrage.py" Traceback (most

Re: How to create a binary tree hierarchy given a list of elements as its leaves

2024-01-28 Thread MRAB via Python-list
On 2024-01-28 18:16, marc nicole via Python-list wrote: So I am trying to build a binary tree hierarchy given numerical elements serving for its leaves (last level of the tree to build). From the leaves I want to randomly create a name for the higher level of the hierarchy and assign it to the

Re: Extract lines from file, add to new files

2024-01-11 Thread MRAB via Python-list
On 2024-01-11 18:08, Rich Shepard via Python-list wrote: It's been several years since I've needed to write a python script so I'm asking for advice to get me started with a brief script to separate names and email addresses in one file into two separate files: salutation.txt and emails.txt. An

Re: >>> %matplotlib inline results in SyntaxError: invalid syntax

2023-12-25 Thread MRAB via Python-list
On 2023-12-25 19:53, Alan Gauld via Python-list wrote: On 25/12/2023 05:34, geetanajali homes via Python-list wrote: import numpy as np import pandas as pd import random import matplotlib.pyplot as plt %matplotlib inline I get an error on the last line. I am running this code in Idle

Re: IDLE editor suggestion.

2023-12-12 Thread MRAB via Python-list
On 2023-12-13 01:28, Steve GS via Python-list wrote: Does anything from the Visual Studio family of software have a pull down menu that lists previous searches so that I don’t have to enter them every time? SGA Visual Studio search box has a dropdown list that's shown when you press the down

Re: IDLE editor suggestion.

2023-12-12 Thread MRAB via Python-list
On 2023-12-12 08:22, Steve GS via Python-list wrote: Maybe this already exists but I have never seen it in any editor that I have used. It would be nice to have a pull-down text box that lists all of the searches I have used during this session. It would make editing a lot easier if I could

Re: How to enter multiple, similar, dictionaries?

2023-12-11 Thread MRAB via Python-list
On 2023-12-11 15:57, Chris Green via Python-list wrote: Chris Green wrote: Is there a way to abbreviate the following code somehow? lv = {'dev':'bbb', 'input':'1', 'name':'Leisure volts'} sv = {'dev':'bbb', 'input':'0', 'name':'Starter volts'} la = {'dev':'bbb', 'input':'2',

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

2023-12-06 Thread MRAB via Python-list
On 2023-12-06 20:11, dn via Python-list wrote: On 7/12/23 07:12, MRAB via Python-list wrote: On 2023-12-06 12:23, Thomas Passin via Python-list wrote: On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote: On 6 Dec 2023, at 09:32, Chris Green via Python-list wrote: My requirement

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

2023-12-06 Thread MRAB via Python-list
On 2023-12-06 12:23, Thomas Passin via Python-list wrote: On 12/6/2023 6:35 AM, Barry Scott via Python-list wrote: 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.:-

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

2023-12-05 Thread MRAB via Python-list
On 2023-12-05 14:37, Chris Green via Python-list wrote: Is there a neat, pythonic way to store values which are 'sometimes' changed? My particular case at the moment is calibration values for ADC inputs which are set by running a calibration program and used by lots of programs which display

Re: Code improvement question

2023-11-17 Thread MRAB via Python-list
On 2023-11-17 09:38, jak via Python-list wrote: Mike Dewhirst ha scritto: On 15/11/2023 10:25 am, MRAB via Python-list wrote: On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote: I'd like to improve the code below, which works. It feels clunky to me. I need to clean up user-uploaded

Re: Code improvement question

2023-11-16 Thread MRAB via Python-list
On 2023-11-17 01:15, Mike Dewhirst via Python-list wrote: On 15/11/2023 3:08 pm, MRAB via Python-list wrote: On 2023-11-15 03:41, Mike Dewhirst via Python-list wrote: On 15/11/2023 10:25 am, MRAB via Python-list wrote: On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote: I'd like

Re: Code improvement question

2023-11-14 Thread MRAB via Python-list
On 2023-11-15 03:41, Mike Dewhirst via Python-list wrote: On 15/11/2023 10:25 am, MRAB via Python-list wrote: On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote: I'd like to improve the code below, which works. It feels clunky to me. I need to clean up user-uploaded files the size

Re: Code improvement question

2023-11-14 Thread MRAB via Python-list
On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote: I'd like to improve the code below, which works. It feels clunky to me. I need to clean up user-uploaded files the size of which I don't know in advance. After cleaning they might be as big as 1Mb but that would be super rare. Perhaps

Re: xor operator

2023-11-13 Thread MRAB via Python-list
On 2023-11-13 21:03, Barry via Python-list wrote: On 13 Nov 2023, at 17:48, Dom Grigonis wrote: Short circuiting happens, when: xor([True, True, False, False], n=1) At index 1 it is clear that the answer is false. Can you share an example with 4 values that is true? And explain why it is

Re: Beep on WIndows 11

2023-11-12 Thread MRAB via Python-list
On 2023-11-12 11:16, Chris Angelico via Python-list wrote: On Sun, 12 Nov 2023 at 21:27, Y Y via Python-list wrote: I am curious and humble to ask: What is the purpose of a BEEP? There are several purposes. I can't say which of these are relevant to the OP, but some or all of them could

Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread MRAB via Python-list
On 2023-11-07 20:56, Thomas Passin via Python-list wrote: On 11/7/2023 3:29 PM, MRAB via Python-list wrote: On 2023-11-07 19:20, Jim Schwartz via Python-list wrote: Where do you define fCONV_AUSRICHTG? It must be initialized or defined somewhere. Did you leave out a statement from the python 2

Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread MRAB via Python-list
On 2023-11-07 19:20, Jim Schwartz via Python-list wrote: Where do you define fCONV_AUSRICHTG? It must be initialized or defined somewhere. Did you leave out a statement from the python 2 version? It's given its value here: ( fNAME, fLG1, fLG2, fTYP,

Re: fCONV_AUSRICHTG is not defined - Why?

2023-11-07 Thread MRAB via Python-list
On 2023-11-07 18:30, dn via Python-list wrote: On 08/11/2023 06.47, Egon Frerich via Python-list wrote: I've no idea why this happens. In a module there are lists and definitions: ...     ["%s%s%s " % (i[fCONV_AUSRICHTG], i[fLG2], i[fTYP]) for i in Felder])   File

Re: Writing to clipboard in Python 3.11

2023-11-07 Thread MRAB via Python-list
On 2023-11-06 00:51, Rob Cliffe via Python-list wrote: Recently I switched from Python 3.8.3 to Python 3.11.4.  A strange problem appeared which was not there before: I am using the win32clipboard backage (part of pywin32), and when I use SetClipboardData() to write text which consists ENTIRELY

Re: Checking if email is valid

2023-11-06 Thread MRAB via Python-list
On 2023-11-06 08:57, Simon Connah via Python-list wrote: I can see how the truley dim-witted might forget that other countries have phone numbers with differing lengths and formatting/punctuation, but there are tons of sites where it takes multiple tries when entering even a bog-standard USA

Re: PyInstaller value error: Invalid Windows resource specifier

2023-10-30 Thread MRAB via Python-list
On 2023-10-30 19:19, McDermott Family via Python-list wrote: Hello, I am trying to create a one file executable with pyinstaller 6.1.0 and auto-py-to-exe 2.41.0 using Python version 3.10.9 in a virtual environment. Some points before the output of pinstaller is shown. My resource .py file is

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

2023-10-02 Thread MRAB via Python-list
On 2023-10-01 23:04, Jen Kris via Python-list wrote: > > Iwant to write a list of 64-bit integers to a binary file. Everyexample I have seen in my research convertsit to .txt, but I want it in binary. I wrote this code,based on some earlier work I have done: > > buf= bytes((len(qs_array)) *

Re: error of opening Python

2023-09-26 Thread MRAB via Python-list
On 2023-09-27 03:30, Chris Roy-Smith via Python-list wrote: On 26/9/23 22:27, Abdelkhelk ashref salay eabakh via Python-list wrote: Dear Python team, This is my not first time using Python, I tried to launch Python and it showed I'm no expert but "Python 3.11.3 (tags/v3.11.3:f3909b8,

Re: The GIL and PyEval_RestoreThread

2023-09-26 Thread MRAB via Python-list
On 2023-09-26 14:20, Peter Ebden via Python-list wrote: Hi all, I've been working on embedding Python and have an interesting case around locking with PyEval_RestoreThread which wasn't quite doing what I expect, hoping someone can explain what I should expect here. I have a little example (I'm

Re: Tkinter ttk Treeview binding responds to past events!

2023-09-12 Thread MRAB via Python-list
On 2023-09-13 00:40, John O'Hagan via Python-list wrote: On Tue, 2023-09-12 at 20:51 +0200, Mirko via Python-list wrote: Am 12.09.23 um 07:43 schrieb John O'Hagan via Python-list: > My issue is solved, but I'm still curious about what is happening > here. MRAB already said it: When you enter

Re: Tkinter ttk Treeview binding responds to past events!

2023-09-12 Thread MRAB via Python-list
On 2023-09-12 19:51, Mirko via Python-list wrote: Am 12.09.23 um 07:43 schrieb John O'Hagan via Python-list: My issue is solved, but I'm still curious about what is happening here. MRAB already said it: When you enter the callback function, Tk's mainloop waits for it to return. So what's

Re: Tkinter ttk Treeview binding responds to past events!

2023-09-12 Thread MRAB via Python-list
On 2023-09-12 06:43, John O'Hagan via Python-list wrote: On Mon, 2023-09-11 at 22:25 +0200, Mirko via Python-list wrote: Am 11.09.23 um 14:30 schrieb John O'Hagan via Python-list: > I was surprised that the code below prints 'called' three times. > > > from tkinter import * > from

Re: Forward References

2023-09-03 Thread MRAB via Python-list
On 2023-09-03 21:43, Jonathan Gossage via Python-list wrote: I am attempting to use forward references in my program and I am failing. This also does not work with the older way of putting the name of a class as a string. Here is some sample code: from __future__ import annotations from

Re: Passing info to function used in re.sub

2023-09-03 Thread MRAB via Python-list
On 2023-09-03 17:10, Jan Erik Moström via Python-list wrote: I'm looking for some advice for how to write this in a clean way I want to replace some text using a regex-pattern, but before creating replacement text I need to some file checking/copying etc. My code right now look something like

Re: Setup-tools

2023-07-15 Thread MRAB via Python-list
On 2023-07-15 07:12, YOUSEF EZZAT via Python-list wrote: Hey!. i face a problem when i get setup packages by pip when i code this : "pip install numpy" in my command line it gives me error "ModuleNotFoundError: No module named 'distutils'" please, i need help for solving this

Re: Trouble with defaults and timeout decorator

2023-06-24 Thread MRAB via Python-list
On 2023-06-24 17:18, Jason Friedman via Python-list wrote: I'm writing a database connectivity module to be used by other modules and leveraging the jaydebeapi module. From what I can tell jaydebeapi contains no built-in timeout capability, so then I turned to

Re: Assistance Request - Issue with Installing 'pip' despite Python 3.10 Installation

2023-06-07 Thread MRAB via Python-list
On 2023-06-07 15:54, Florian Guilbault via Python-list wrote: Dear Python Technical Team, I hope this email finds you well. I am reaching out to you today to seek assistance with an issue I am facing regarding the installation of 'pip' despite my numerous attempts to resolve the problem.