python-3.9

Date time difference in minutes python

Date time difference in minutes python Question: I’m new to python and tiring to calculate time difference in minutes. Times are in slightly two different formats. I have tried below to format but did not got it correctly from datetime import datetime start = "2023-05-21T11:40:54.532203+00:00" end = "2023-05-21T11:45:00+00:00" starttime=datetime.strptime(start , "%Y-%m-%dT%H:%M:%S:%f%z’") endtime=datetime.strptime(end , "%Y-%m-%dT%H:%M:%S:%f%z’") Asked …

Total answers: 2

PySide2 – Widget above a widget with a shadow effect moves under the second

PySide2 – Widget above a widget with a shadow effect moves under the second Question: I am writing a virtual keyboard for an app that will be using with touch screen. If you wanna ask me, why i don’t use pyqt virtual keyboard, i’ll answer that my keyboard must have some additional buttons and function. …

Total answers: 1

Dataclasses and slots causing ValueError: 'b' in __slots__ conflicts with class variable

Dataclasses and slots causing ValueError: 'b' in __slots__ conflicts with class variable Question: I don’t understand the error message and also couldn’t find other SO questions and answers helping me to understand this. The MWE is tested with Python 3.9.2. I’m aware that there is a slots=True parameter in Pythons 3.10 dataclasses. But this isn’t …

Total answers: 2

How do I import a .pyd module written in C++ to Python using PyBind11

How do I import a .pyd module written in C++ to Python using PyBind11 Question: I am working on Windows 10 with Python 3.9.7 and have anaconda setup on my laptop. I have compiled a C++ code calcSim.cpp where the module name is calJaccSimm and am able to successfully generate a .pyd file with the …

Total answers: 1

Run event loop until all tasks are blocked in python

Run event loop until all tasks are blocked in python Question: I am writing code that has some long-running coroutines that interact with each other. These coroutines can be blocked on await until something external happens. I want to be able to drive these coroutines in a unittest. The regular way of doing await on …

Total answers: 5

Store results of nested for loop as single concatenated string

Store results of nested for loop as single concatenated string Question: I’m trying to store the values of the function below to a single string that I can input into a query leveraging an F-string. The output looks correct but is really just a few separated print statements. How can I store the output of …

Total answers: 2

Copying a table from an in-memory database to a on-disk database in sqlite3

Copying a table from an in-memory database to a on-disk database in sqlite3 Question: I want to copy one specific table from an in-memory sqlite database, using Python (3.9). Looking in the documentation, I should be able to simply attach the in-memory database to the file database, however while attaching throws no error, when I …

Total answers: 1

Change directory in python – os.chdir('/tmp') vs os.system("cd " + backup_location)

Change directory in python – os.chdir('/tmp') vs os.system("cd " + backup_location) Question: I’m experimenting with using Python for backups, because my Bash script became too big and complicated. I’m totally new in Python, I’m not fan of it, but it seems like Python is perfect tool for such complicated scripts. I have found something to …

Total answers: 1

How to get a file using %APPDATA% in python 3.9?

How to get a file using %APPDATA% in python 3.9? Question: I want to store in a variable this path APPDATA%/Roaming/FileZilla/sitemanager.xml. When i use: file = "C:/Users/MyPC/AppData/Roaming/FileZilla/sitemanager.xml" it works, but when i use: file = "%APPDATA%/Roaming/FileZilla/sitemanager.xml" the file cannot be stored and i cant send via paramiko. Anyone helps? Asked By: Chead1988 || Source Answers: …

Total answers: 2

Resize images while preserving aspect ratio

Resize images while preserving aspect ratio Question: I have a small problem that could have a simple solution, but unfortunately I’m not very good at math. I have three images that need to be stacked on top of each other and their heights add up to more than the screen height. So to fix, I …

Total answers: 1