2,204,260 questions
Score of 0
1 answer
42 views
Do I need a try/finally clause when calling cv2.VideoCapture.release()?
I'm learning how to capture video from camera using opencv for Python. The official tutorial provides the following example (modified):
import cv2 as cv
cap = cv.VideoCapture(0)
if not cap.isOpened():...
Score of -3
1 answer
54 views
Dog Bark Emotion Analysis: Should I include a breed classification pre-model? [closed]
I am a Computer Science student working on a project that analyzes dog barks to determine the underlying emotion.
Aside from the complex data collection process (recording barks and their associated ...
Score of -4
1 answer
128 views
Python 2 vs. Python 3: what does "not backward compatible" mean exactly?
According to Wikipedia:
Python 3.0 was released on 3 December 2008, and was a major revision and not completely backward-compatible with earlier versions, with some new semantics and changed syntax.
...
Score of -6
0 answers
38 views
modifying one inner list in `[[0]] * 3` changes all three. How to avoid it? [duplicate]
In Python, when I create a nested list with grid = [[0]] * 3 and then run grid[0][0] = 5 or grid[0].append(1), the change appears in all three inner lists at once, even though they print as three ...
Score of 3
1 answer
100 views
Python 3.14: NameError for a self-referencing annotation, but only when it’s read in __init_subclass__
The Python 3.14 docs say annotations are now evaluated lazily, so forward references work without from __future__ import annotations. I removed that import from my mini ORM. Now defining any model ...
Score of -3
1 answer
130 views
Why can't I use key.A and key.B after importing Pyglet?
This Pyglet program doesn't seem to understand the key function and gives a NameError every time it runs. Does anyone know a solution to this?
import random
import pyglet
p=0
de=0
#opens window
window ...
Score of -7
0 answers
193 views
forecast the future price of a stock based on the past prices of other stocks [closed]
company1 = ['10', '11', '13', '15', '17', '19', '20']
company2 = ['20', '21', '23', '25', '27', '29', '30']
company3 = ['40', '41', '43', '45', '47', '49', '50']
The lists (company1, company2, ...
Score of -2
1 answer
116 views
Python command not working in a particular project [closed]
I'm practicing on how to develop python programs with graphical interfaces, but the issue is the following: when I double click the program it works fine, but when I try to execute it in the terminal ...
Score of 3
1 answer
218 views
Why does Python return True when comparing two datetime objects with different UTC timestamps?
I'm developing a Python application that stores scheduled events using timezone-aware datetime objects.
I encountered an unexpected behaviour when handling Daylight Saving Time (DST).
from datetime ...
Score of 4
1 answer
184 views
How to idiomatically map data (in my case prime numbers) to a reusable class in Python?
I am working with a standard FrenchDeck class.
This is the exact example from the book Fluent Python:
import collections
Card = collections.namedtuple("Card", ["rank", "suit&...
Score of -5
0 answers
161 views
Install Python3.15 in brew [closed]
I want to install fastfetch on brew, but it stops immediately and show this error, I try to fix that error on Google and YouTube, but nothing happens.
Last 15 lines from /Users/khang/Library/Logs/...
Score of 5
1 answer
203 views
Buggy implementation of Knuth's Mastermind algorithm in Python
I have been trying to implement a randomized variant of Knuth's 1977 minimax algorithm for the 1971 board game "Mastermind". I wanted to make it able to be adaptable to different code ...
Score of -3
0 answers
190 views
How do I implement different modified objects by using classes? [closed]
I have a basic understanding of how classes/objects work and how to make new objects using the established class, but I am a bit confused on how to implement that concept for a far more complex and ...
Score of -2
0 answers
81 views
How to iterate a dictionary which has custom objects defined by a class for keys? [duplicate]
I'm not quite sure whether this is even the correct question to ask, I'm just assuming so by imagining: if <object> in <dictionary> iterates it and returns True if it's there.
In my code, ...
Score of 3
0 answers
134 views
Netbox Plugin with Template Extension does not take account of PluginTemplateExtension.models
I break down my issue in a generic netbox plugin stub arranged this way:
.
└── my_plugin_name
├── __init__.py
└── template_content.py
my_plugin_name/template_content.py is based on ...