Skip to content

How to check status of long lasting ibm_db connection in python

I’m developing and API that reads data from DB2 and returns corresponding result (using Flask on Python). Initially I had connection open on each API call but since number of connections per second is growing I thought it’s better to open DB connection once and re-open it only if it closed/failed …

Replace character in file name with regex python

My script should replace the “|” character of a file it finds via regex in a directory with an “l”. The code runs but filenames are not replaced. What is wrong? Answer Joshua’s answer and the many comments, especially the suggestions from ekhumoro, already pointed out issues and …

PyPy and Python version

I have installed latest version of PyPy using sudo apt install pypy pypy-dev on my Xubuntu. When I try python –version I see that I have Python 3.8.10 installed. When I try pypy –version I got Thats a problem because my script is written in Python 3 and I want to use pandas library in this script.…

Problems regarding “key” in the min() function

scores = {1:20, 2:40, 3:0, 4:25} min_score = min(scores, key=scores.get) I don’t quite understand the parameters that can be passed into the key. Running the above code gives me 3 which is what I wanted. scores.get return me a dict object at certain memory address. Calling scores.get() raised me an Erro…

how to send string to python file and display it using terminal

I want to know how can I get the string from terminal or command prompt and make lower case that string and display it on terminal or command promptI used this code but it’s not working and in terminal when I used this in my terminal I got this error File “C:UsersmiladmAppDataLocalProgramsPythonPy…