October 22, 2024
Chicago 12, Melborne City, USA
python

How to get user input in Flask and use it as a variable?

I need to make a flask server that allows the user to enter an input then collects and saves that input. In another program I import my flask program to retrieve the variable and print it, but the program does not fetch the user’s input. I have my flask code (app.py): from flask import Flask,

Read More
python

I'm working on a Python script that controls an LED light based on object detection results from a subprocess

I’m working on a Python script that controls an LED light based on object detection results from a subprocess. The goal is: Turn the LED red when a face is detected. Turn the LED another colour (turquoise) when only a person is detected. Face detection should have priority over person detection. So if both a

Read More
python

Why can't a derived class in Python reference inherited attributes in its definition?

I have this snippet: class A(object): def foo(): pass class B(A): bar = foo() As written, this file will fail to run with the error NameError: name 'foo' is not defined. However, since foo is defined in A, and is inherited by B, I should be able to access them. I know I can simply

Read More
python

Python package with python and C components

I’m writing a python project, which have python and C-python components. And I want to use pyproject.toml. I have such file structure: ./myproject | |- pyproject.toml | \-src | |- myproject | | | ...some python code... | \- c_modules | |- compile_c_modules.py | |- module1 | | | ... some c code | \-

Read More
python

How to configure PyConfig for embedded interpreter

I have added an embedded python interpreter to a C program using libpython, complete with defining a custom python module that allows access from python to various variables and built-in functions within the program, the idea being to provide a scripting capability. That appears to have been the easy bit: all that is working fine

Read More
python

approximating logarithm using harmonic mean

here is function to approximate log10(x+1), (x+1) < ~1.2 a = 1.097 b = 0.085 c = 2.31 ans = 1 / (a - b*x + c/x) so it should look like that it works by adjusting harmonic mean to match log10 but the problem is in values of abc the question is how to

Read More
python

This probably means that Tcl wasn't installed properly

I’m using Python and PyCharm on Windows 11. I recently upgraded from Python 3.12 to Python 3.13. When running in PyCharm, I now get the error "_tkinter.TclError: Can’t find a usable init.tcl in the following directories: C:/Users/kbens/AppData/Local/Programs/Python/Python313/lib/tcl8.6 {C:/Users/kbens/OneDrive/Earnie TradeBot/Code/Earnie/.venv/lib/tcl8.6} {C:/Users/kbens/OneDrive/Earnie TradeBot/Code/Earnie/lib/tcl8.6} {C:/Users/kbens/OneDrive/Earnie TradeBot/Code/Earnie/.venv/library} {C:/Users/kbens/OneDrive/Earnie TradeBot/Code/Earnie/library} {C:/Users/kbens/OneDrive/Earnie TradeBot/Code/Earnie/tcl8.6.14/library} {C:/Users/kbens/OneDrive/Earnie TradeBot/Code/tcl8.6.14/library} This probably means that Tcl wasn’t

Read More
python

How can i fix the error – “Bad Colour Sequence” from line 31?

I am making a Python Turtle project that will let me input 3 colour values which then get used as a colour for a circle, then it should print the rgb values of the colour and the hex values in the text output. This is the code: import turtle from turtle import colormode import random

Read More
python

Error while trying to use the picam2 library: module 'kms' has no attribute 'PixelFormat'

I have been facing an issue. I have a project, where I have to use facial recognition from insightface to detect know people. Hardware-wise, I have been given a Raspberry pi 5 and two picams (v1.3, v2.1). I found out that there is an issue with the picam 2 not being detected by the system

Read More
python

Improving runtime of graph computation

I am using pycel to create a graph of an excel calculation. Essentially I have a cell that performs some calculation: E.g., =AVERAGE(I2:X2) Which in turn is a function of other cells in other worksheets E.g., I2 = sheet2!A1/sheet3!B6 And these cells can be functions of other cells etc. pycel builds a graph of this

Read More