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

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.

Re: Fwd: Problems Installing and getting started.

2023-05-31 Thread MRAB
On 2023-05-31 08:34, Mark Bass wrote: -- Forwarded message - From: Mark Bass Date: Wed, 31 May 2023 at 08:09 Subject: Problems Installing and getting started. To: Good morning, I installed python several hours ago (from python.org), I then installed the IDE PyCharm. I'm

Re: Module error

2023-05-26 Thread MRAB
On 2023-05-27 01:30, giuseppacef...@gmail.com wrote: I have reinstalled python which reinstalls pip. I have added the path:'C:\sers\Giuseppa\AppData\Local\Packages\PythonSoftwareFoundation.Pytho n.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts and still get the error below.

Re: "Invalid literal for int() with base 10": is it really a literal?

2023-05-26 Thread MRAB
On 2023-05-26 09:29, Chris Angelico wrote: On Fri, 26 May 2023 at 17:56, Roel Schroeven wrote: Kevin M. Wilson's post "Invalid literal for int() with base 10?" got me thinking about the use of the word "literal" in that message. Is it correct to use "literal" in that context? It's correct in

Re: Invalid literal for int() with base 10?

2023-05-25 Thread MRAB
On 2023-05-25 22:30, Kevin M. Wilson via Python-list wrote: Ok, I'm not finding any info. on the int() for converting a str to an int (that specifies a base parameter)?! The picture is of the code I've written... And the base 10 paradigm involved?? years = int('y') # store for

Re: Does os.path relpath produce an incorrect relative path?

2023-05-25 Thread MRAB
On 2023-05-25 16:53, Eryk Sun wrote: On 5/25/23, BlindAnagram wrote: vcx_path = 'C:\\build.vs22\\lib\\lib.vcxproj' src_path = 'C:\\lib\\src\\' rel_path = '..\\..\\..\\lib\\src' [snip] The first of these three results produces an incorrect relative path because relpath does not strip off any

Re: where is requests

2023-05-23 Thread MRAB
On 2023-05-24 01:14, Rich Osborne wrote: I have install Python 3.11.3 but my import requests does not work. I found documentation that refers to C:\python35 but I am on 3.11.3. Where do I find requests? It's not part of the standard library. You can import it using pip. If you're on Windows,

Re: Learning tkinter

2023-05-18 Thread MRAB
On 2023-05-12 09:55, Rob Cliffe via Python-list wrote: I am trying to learn tkinter. Several examples on the internet refer to a messagebox class (tkinter.messagebox). But: Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32 Type "help", "copyright",

Re: Using loguru in a library

2023-05-01 Thread MRAB
On 2023-04-30 16:40, Roy Hann wrote: Is there anyone using loguru (loguru 0.5.3 in my case) successfully in a library? In my __init__.py in mylib I do logger.disable('mylib') which definitely works. I don't get any more logging. I "pip install ." the library, then in mytest.py I do

Re: How to 'ignore' an error in Python?

2023-04-28 Thread MRAB
On 2023-04-28 16:55, Chris Green wrote: I'm sure I'm missing something obvious here but I can't see an elegant way to do this. I want to create a directory, but if it exists it's not an error and the code should just continue. So, I have:- for dirname in listofdirs: try:

Re: Fwd: pip is not installed

2023-04-16 Thread MRAB
On 2023-04-16 21:54, Khoinguyen Nguyen wrote: To whom it may concern, I have tried to reinstall, repair, and run in command prompt, but it seems as though pip won't install. I am using Windows 10 and Python 3.11.3. Are there any other suggestions for troubleshooting? Thank you. Have you tried

Re: Problem with Matplotlib example

2023-04-13 Thread MRAB
On 2023-04-13 19:41, Martin Schöön wrote: Anyone had success running this example? https://tinyurl.com/yhhyc9r When I try I get this error: "TypeError: __init__() got an unexpected keyword argument 'transform'" This is for the line "m = MarkerStyle(SUCESS_SYMBOLS[mood], transform=t)" Yes,

Re: Weak Type Ability for Python

2023-04-12 Thread MRAB
On 2023-04-13 03:21, Cameron Simpson wrote: On 12Apr2023 22:12, avi.e.gr...@gmail.com wrote: I suspect the OP is thinking of languages like PERL or JAVA which guess for you and make such conversions when it seems to make sense. JavaScript guesses. What a nightmare. Java acts like Python and

Re: Weak Type Ability for Python

2023-04-12 Thread MRAB
On 2023-04-13 03:12, avi.e.gr...@gmail.com wrote: As originally written, the question posed has way too many possible answers but the subject line may give a hint. Forget printing. The Python statement 1 + "a" SHOULD fail. The first is an integer and the second is string. These two are native

Re: Christoph Gohlke and compiled packages

2023-04-12 Thread MRAB
from the failure. (xreq) D:\Users\mike\envs\xreq> [snip] C:\Users\mrab>py -3.11 -m pip install psycopg2 Collecting psycopg2 Downloading psycopg2-2.9.6-cp311-cp311-win_amd64.whl (1.2 MB) 1.2/1.2 MB 2.4 MB/s eta 0:00:00 Installing collecte

Re: Weak Type Ability for Python

2023-04-12 Thread MRAB
On 2023-04-12 19:57, Mats Wichmann wrote: On 4/12/23 11:11, Chris Angelico wrote: On Thu, 13 Apr 2023 at 03:05, Ali Mohseni Roodbari wrote: Hi all, Please make this command for Python (if possible): x=1 y='a' wprint (x+y) 1a In fact make a new type of print command which can print and

Re: Windows installer from python source code without access to source code

2023-04-06 Thread MRAB
On 2023-04-06 23:14, Jim Schwartz wrote: Could someone please help Carlos?  I’m not sure how to answer his question Sent from my iPhone On Apr 6, 2023, at 3:53 PM, Carlos Fulqueris wrote:  Hello Jim, How can I unsubscribe to this email list? I'm

Re: Patrick Sheehan: Major Issues with Python

2023-03-26 Thread MRAB
On 2023-03-25 20:03, Patrick Sheehan wrote: Hello, I have been working with the attached book (See photo) to try to learn Python and so far it has been a complete nightmare trying to get python installed and operating correctly. I have received a plethora of error messages and consulted youtube

Re: Debugging reason for python running unreasonably slow when adding numbers

2023-03-20 Thread MRAB
On 2023-03-20 15:21, Edmondo Giovannozzi wrote: > def sum1(): > s = 0 > for i in range(100): > s += i > return s > > def sum2(): > return sum(range(100)) Here you already have the numbers you want to add. Actually using numpy you'll be much faster in

Re: Fwd: Friday finking: IDE 'macro expansions'

2023-03-17 Thread MRAB
On 2023-03-17 17:55, Thomas Passin wrote: On 3/17/2023 1:13 PM, Alan Gauld wrote: Oops! I meant to send this to the group not just Dave. Forwarded Message On 16/03/2023 22:55, dn via Python-list wrote: Do you make use of your IDE's expansionist tendencies, and if-so,

Re: How to exit program with custom code and custom message?

2023-03-13 Thread MRAB
On 2023-03-14 03:29, Thomas Passin wrote: On 3/13/2023 10:34 PM, scruel tao wrote: Lars: I totally understand your reasoning here, but in some way it follows the unix philosophy: Do only one thing, but do that good. I understand, python is not strongly typed, so `sys.exit` will be able to

Re: =- and -= snag

2023-03-13 Thread MRAB
On 2023-03-14 00:28, Gary Herron wrote: On 3/13/23 2:26 PM, morp...@gmail.com wrote: Hi. I was working in Python today, and sat there scratching my head as the numbers for calculations didn't add up. It went into negative numbers, when that shouldn't have been possible. Turns out I had a

Re: Python installation not full and python not working 3.11.0

2023-03-10 Thread MRAB
On 2023-03-10 23:27, Jan Vasko wrote: Hello all, I would like to ask you for help. I have been using Python 3.8 for almost 2 years and I decided to update to 3.11. Initially everything was correct. But at some point Windows shows me that Python is being reinstalled (I don't have a message

Re: Cutting slices

2023-03-05 Thread MRAB
On 2023-03-06 00:28, dn via Python-list wrote: On 06/03/2023 11.59, aapost wrote: On 3/5/23 17:43, Stefan Ram wrote:    The following behaviour of Python strikes me as being a bit    "irregular". A user tries to chop of sections from a string,    but does not use "split" because the separator

Re: hi

2023-03-04 Thread MRAB
On 2023-03-04 17:13, Tom wrote: Bonjour je suis français et je ne comprend pas comment je peux acceder a python merci de me repondre CORDIALEMENT Lilian Go to https://www.python.org/downloads/ and download the installer for your operating system (Windows or MacOS). For Windows I'd

Re: How to escape strings for re.finditer?

2023-02-27 Thread MRAB
On 2023-02-27 23:11, Jen Kris via Python-list wrote: When matching a string against a longer string, where both strings have spaces in them, we need to escape the spaces. This works (no spaces): import re example = 'abcdefabcdefabcdefg' find_string = "abc" for match in

Re: TypeError: can only concatenate str (not "int") to str

2023-02-26 Thread MRAB
On 2023-02-26 16:56, Hen Hanna wrote: On Sunday, February 26, 2023 at 6:41:01 AM UTC-8, Thomas Passin wrote: On 2/25/2023 8:12 PM, Hen Hanna wrote: > 2. the rude guy ('dn') hasn't offered a single word of comment that's directly relevant to it. > > but he did offer related stuff

Re: File write, weird behaviour

2023-02-19 Thread MRAB
On 2023-02-19 19:31, Chris Angelico wrote: On Mon, 20 Feb 2023 at 06:24, Thomas Passin wrote: On 2/19/2023 1:53 PM, Chris Angelico wrote: > On Mon, 20 Feb 2023 at 03:41, Azizbek Khamdamov > wrote: >> >> Example 1 (works as expected) >> >> file =

Re: File write, weird behaviour

2023-02-19 Thread MRAB
On 2023-02-19 14:03, Azizbek Khamdamov wrote: Example 1 (works as expected) file = open("D:\Programming\Python\working_with_files\cities.txt", 'r+') ## contains list cities # the following code adds new record to the beginning of the file, expected behaviour file.write("new city\n")

Re: Comparing caching strategies

2023-02-18 Thread MRAB
On 2023-02-18 23:04, avi.e.gr...@gmail.com wrote: [snip] Note how this can cause problems with the original idea here of caching strategies. Imagine a function that checks the environment as to what encoding or human language and so on to produce text in. If you cache it so it produces

Re: Comparing caching strategies

2023-02-18 Thread MRAB
On 2023-02-18 19:59, avi.e.gr...@gmail.com wrote: [snip] I do not know the internals of any Roaring Bitmap implementation so all I did gather was that once the problem is broken into accessing individual things I chose to call zones for want of a more specific name, then each zone is stored in

Re: Comparing caching strategies

2023-02-16 Thread MRAB
On 2023-02-14 22:20, Rob Cliffe via Python-list wrote: On 11/02/2023 00:39, Dino wrote: First off, a big shout out to Peter J. Holzer, who mentioned roaring bitmaps a few days ago and led me to quite a discovery. I was intrigued to hear about roaring bitmaps and discover they really were a

Re: bool and int

2023-01-24 Thread MRAB
On 2023-01-24 20:32, Weatherby,Gerard wrote: https://peps.python.org/pep-0285/ From: Python-list on behalf of rbowman Date: Tuesday, January 24, 2023 at 3:01 PM To: python-list@python.org Subject: Re: bool and int bool is a subtype of integer. I never dug that deep into Python's guts but

Re: Tkinter GUI freezing, used Thread then encountered RuntimeError: threads can only be started once

2023-01-10 Thread MRAB
On 2023-01-11 00:13, Cameron Simpson wrote: On 10Jan2023 18:32, MRAB wrote: I don't like how you're passing Thread...start as an argument. IMHO, it would be better/cleaner to pass a plain function, even if the only thing that function does is to start the thread. Yes, and this is likely

Re: To clarify how Python handles two equal objects

2023-01-10 Thread MRAB
On 2023-01-10 22:21, Jen Kris via Python-list wrote: There are cases where NumPy would be the best choice, but that wasn’t the case here with what the loop was doing. To sum up what I learned from this post, where one object derives from another object (a = b[0], for example), any operation

Re: To clarify how Python handles two equal objects

2023-01-10 Thread MRAB
On 2023-01-10 20:41, Jen Kris via Python-list wrote: Thanks for your comments.  I'd like to make one small point.  You say: "Assignment in Python is a matter of object references. It's not "conform them as long as they remain equal". You'll have to think in terms of object references the

Re: Tkinter GUI freezing, used Thread then encountered RuntimeError: threads can only be started once

2023-01-10 Thread MRAB
On 2023-01-10 14:57, Abhay Singh wrote: Here is the entire code snippet of the same. Please help def change_flag(top_frame, bottom_frame, button1, button2, button3, button4, controller): global counter, canvas, my_image, chosen, flag, directory canvas.delete('all') button5['state'] =

Re: No module named 'playsound'‏‏‏‏‏‏‏‏‏‏‏‏‏‏‏‏

2023-01-09 Thread MRAB
On 2023-01-09 17:11, Thomas Passin wrote: I wrote "the most likely reason is that it got installed by a different version of python than the one that used pip to install it." That's not quite what I meant to say. Better: "the most likely reason is that you are trying to import it using a

Re: No module named 'playsound'‏‏‏‏‏‏‏‏‏‏‏‏‏‏‏‏

2023-01-09 Thread MRAB
On 2023-01-09 14:40, om om wrote: I'm installing playsound pip install playsound but it keeps saying No module named playsound and this error occurs on other packages What are you typing on the command line? Which operating system are you using? Please copy and post what you're typing (with

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

2023-01-03 Thread MRAB
On 2023-01-03 15:35, c.bu...@posteo.jp wrote: Hello, this posting isn't about asking for a technical solution. My intention is to understand the design decision Python's core developers made in context of that topic. The logging module write everything to stderr no matter which logging level

Re: NoneType List

2022-12-31 Thread MRAB
On 2022-12-31 05:45, Goran Ikac wrote: Happy New Year, everybody! I'm new in the Python List, new in Python world, and new in coding. A few days (weeks?) ago, I faced a problem trying to write a program for an exercise. I asked for help and nobody answered. In the meantime, I found a part of the

Re: Possible re bug when using ".*"

2022-12-28 Thread MRAB
On 2022-12-28 18:42, Alexander Richert - NOAA Affiliate via Python-list wrote: In a couple recent versions of Python (including 3.8 and 3.10), the following code: import re print(re.sub(".*", "replacement", "pattern")) yields the output "replacementreplacement". This behavior does not occur

Re: String to Float, without introducing errors

2022-12-19 Thread MRAB
On 2022-12-19 14:10, Peter J. Holzer wrote: On 2022-12-19 09:25:17 +1100, Chris Angelico wrote: On Mon, 19 Dec 2022 at 07:57, Stefan Ram wrote: > G = Decimal( 6.6743015E-11 ) > r = Decimal( 6.371E6 ) > M = Decimal( 5.9722E24 ) What's the point of using Decimal if you start with nothing more

Re: Subtracting dates to get hours and minutes

2022-12-15 Thread MRAB
On 2022-12-15 22:49, Gronicus@SGA.Ninja wrote: Yes, it works like a charm. On the tupility of it all. Special thanks for the explanation too….. (Originally asked but I found the errors. All is working) Now that the code no longer produces the errors, I see that the year and month not

Re: Single line if statement with a continue

2022-12-15 Thread MRAB
On 2022-12-15 19:05, avi.e.gr...@gmail.com wrote: Multiple returns is not always a problem as it depends on the nature of a task whether it has complex enough cases. I have seen code that instead sets Boolean variables when it is ready to return and everything else keeps checking the variables

Re: Subtracting dates to get hours and minutes

2022-12-15 Thread MRAB
On 2022-12-15 18:14, Gronicus@SGA.Ninja wrote: So far so good , I can now use a variable in datetime.datetime but it only works if I hard-code the time/date information. Now I want to have the code read from a file but I get: TypeError: function takes at most 9 arguments (26 given) I figure

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-06 Thread MRAB
On 2022-12-07 02:23, Jach Feng wrote: s0 = r'\x0a' At this moment it was done by def to1byte(matchobj): return chr(int('0x' + matchobj.group(1), 16)) s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) But, is it that difficult on doing this simple thing? You could try this:

Re: unable to resolve readline issues

2022-12-04 Thread MRAB
On 2022-12-02 22:38, biglee12...@gmail.com wrote: > Dear Sir: > > For whatever reason I have lost functionality of using Python 3.11. While > opening Python (standalone or from CMD prompt) as usual this AM the > following message appeared. Did read that it is not compatible with > Windows but

Re: In code, list.clear doesn't throw error - it's just ignored

2022-11-13 Thread MRAB
On 2022-11-14 00:55, Greg Ewing wrote: On 14/11/22 1:31 pm, Jon Ribbens wrote: On 2022-11-13, DFS wrote: But why is it allowed in the first place? Because it's an expression, and you're allowed to execute expressions. To put it a bit more clearly, you're allowed to evaluate an expression

  1   2   3   4   5   6   7   8   9   10   >