Skip to main content

Questions tagged [python]

Python is a dynamically typed, multi-purpose programming language. It is designed to be quick to learn, understand, and use, and enforces a clean and uniform syntax. Note that Python 2 reached end-of-life on January 1st, 2020. For version-specific Python questions, add the version tag (e.g. [python-3.x] or [python-3.9]). When using a Python variant (e.g. Jython, PyPy) or library (e.g. Pandas, NumPy), please include it in the tags.

0 votes
0 answers
2 views

pymssql package '_bcp_batch' in Mac M3 chip

I have a Mac with M3 chip and I get an error when I use python3.10^: File "src/pymssql/_pymssql.pyx", line 1, in init pymssql._pymssql ImportError: dlopen(/Library/Frameworks/Python....
Itamar's user avatar
  • 31
0 votes
0 answers
4 views

How can I manage to run a single processor project with all processor cores?

import multiprocessing, time mpCores=multiprocessing.cpu_count() print("This PC has", mpCores,"cores. Currently only utilising 1, upgrades to follow") tic = time.perf_counter() ...
Yusuf's user avatar
  • 1
0 votes
0 answers
5 views

aws sam common layer cant find the modules

I have the follow directory structure common => __init__.py common.py customer => app.py template.yaml My template looks like this AWSTemplateFormatVersion: '2010-09-...
user4447899's user avatar
0 votes
0 answers
7 views

Load 2 Tkinter windows simultaneously. one with animation

The following script runs standalone to run a scenario. the results are printed first and then closing this the plot with an animation. import numpy as np import matplotlib.pyplot as plt ...
Nick's user avatar
  • 765
0 votes
3 answers
26 views

What is the correct way to unpack a tuple composed of a TreeNode and an Integer?

I'm implementing an algorithm that requires appending and popping nodes from a Tree in python (in a FIFO way). queue = [] # empty list root = TreeNode() # a standard TreeNode with val, left and ...
user13079354's user avatar
-1 votes
0 answers
15 views

Problem with the dual variable when I fix the value of a variable in the primal constraint

I am pretty new to Pyomo. I am sorry if the question is trivial, but I do not understand. I have the following LP: S = pyo.ConcreteModel() S.dual = pyo.Suffix(direction=Suffix.IMPORT_EXPORT) S.x = pyo....
user2695795's user avatar
0 votes
0 answers
8 views

Python3: How to grab Alt key without swallowing it?

Overview I'm implementing Alt-Tab functionality for i3wm. To do so, I'm writing a Python3 program communicating with i3 using the i3ipc package. I use the Xlib package to grab "Alt-Tab", so ...
tanjeff's user avatar
  • 11
0 votes
0 answers
5 views

netCDF polygons to fixed sized raster image

Im trying to convert data from netCDF files, the data contains polygons and values for methane concentrations. from matplotlib.patches import Polygon import cartopy.crs as ccrs import cartopy.feature ...
sapphire's user avatar
1 vote
1 answer
28 views

SQL not allowing deletion of related data

In SQL I have: CREATE TABLE Customer( cust_id INT NOT NULL PRIMARY KEY CHECK (cust_id > 0), full_name TEXT NOT NULL, phone TEXT NOT NULL, ...
Moran's user avatar
  • 11
0 votes
2 answers
42 views

Why is My Python Solution For Trapped Rain Problem so slow?

I have been working on the Leetcode version of the Trapped Rain Problem (See below). My solution passes almost all of the test cases, but I get a "Time Limit Exceeded" failure on test 318, ...
Kris Howerd's user avatar
0 votes
0 answers
13 views

How to make exclude for checking black formatter in github actions for folders from main branch?

I learn python and I'd like to use github actions, but I have an issue with black formatter, because it checks all files in pull-request (also from main branch), but I don't need it. I've tried any ...
A. Serguta's user avatar
-2 votes
0 answers
28 views

Why do I get "NoneType object is not iterable" when filtering a list of dictionaries with list comprehension and handling None?

In Python, I am filtering a list of dictionaries with a key using list comprehension. I am handling None but still get an error "NoneType object is not iterable". I know this must be a ...
Harold's user avatar
  • 7
-3 votes
1 answer
43 views

Dictionary Update Stops at Index 35

I'm trying to iterate through a list (config_patterns) and add each element as a key to a dictionary (predefined_patterns) with a value of 0. There are 40 elements in this list. However, the final ...
Chi Pham's user avatar
-3 votes
0 answers
20 views

while making a change in a price ecommerce app by selecting the different size i get error in unsupported operand type

unsupported operand type(s) for +: 'int' and 'str' Internal Server Error: /product/t-shirts/ Traceback (most recent call last): File "C:\Python311\Lib\site-packages\django\core\handlers\...
Ashish Kumar Thakur's user avatar
0 votes
0 answers
13 views

Simple DiffSharp example

How to convert this simple PyTorch snippet to DiffSharp? It's supposed to be similar but many functions are not to be found. # Define tensors with requires_grad=True to track computation history x = ...
Loco Barocco's user avatar

15 30 50 per page
1
2 3 4 5
146876