All Questions
Tagged with python-interpreter or python
2,207,212 questions
0
votes
0
answers
9
views
Drawing LaTeX image in pyside6 using TextObject
I want to draw rendered LaTeX in a pyside6 application using TextObjectInterface where an object is stored as TextObject and LaTeX is painted on it. I wish to avoid TextImage as it works but there is ...
Advice
0
votes
9
replies
49
views
Why does removing elements from a list in a for loop in Python skip values?
I'm new to Python and I'm trying to write a script that removes all even numbers from a list. My logic was to loop through the list and, if a number is divisible by 2, remove it.
Here is my code:
...
-5
votes
0
answers
54
views
I was writing code on an ai browser controller that can control human actions on a browser [closed]
The problem is that the browser does't open at all. My code is all right here if it expires, please let me know and I'll renew it:https://ctxt.io/2/AAD4b3sxEw
0
votes
0
answers
46
views
Why does np.vectorize promotes np.uint8 elements of a 1-d array to int, but leaves types of list elements unchanged?
I have this Python function:
import numpy as np
def f(x):
print(f"x is {x} and has type {type(x)}")
try:
print(f"x.dtype is {x.dtype}")
except AttributeError:
...
Advice
0
votes
6
replies
80
views
Pseudocode / flowchart help needed! (Python Coding Class)
I am completely new to Python and coding in general. I am currently taking a college-level online Python course, but the instructions and book (Zybooks) are proving to be difficult for me to follow.
...
2
votes
0
answers
71
views
Why does summing a complex and a np.float64 value give a complex value instead of a np.complex128 value suggested by the Numerical promotion rules?
I am reading about Numerical promotion in numpy. I copy the main graph here:
Based on the graph, this explanation:
The input dtype with the higher kind determines the kind of the result dtype. The ...
-3
votes
1
answer
50
views
python imported variables working for some functions only [closed]
i need some help to a problem that makes no sense to me.
my code goes like this:
from file1 import*
def func1():
var_from_file1 = anything
def func2():
var_from_file1 = anything #exact same ...
1
vote
1
answer
65
views
Why does numpy warn me about overflow in scalar subtract if it happens with an np.uint8-typed int, but not when the same value is part of a 0-d array?
These two lines:
res0 = np.array(np.uint8(40))-80 # np.uint8(216), no warning
res1 = np.uint8(40)-80 # np.uint8(216), warning
seem to work identically. Both res0 and res1 will be np.uint8(216). np....
2
votes
2
answers
55
views
Why does np.vectorize(function) avoid an integer overflow which the function itself encounters when not wrapped in np.vectorize?
I know that 1.0 * (40-80) results in -40.0. I understand that
1.0 * (np.array([np.uint8(40)])-80)
results in array([216.]). So, it is also not surprising that:
import numpy as np
C = 1.0
def f(x):
...
2
votes
1
answer
26
views
escape circular imports with fastapi
i am learning fastapi and i structure an app like this
app in FastAPI:
models.py file to hold database and other python important methods
routes.py file to hold the routes (URLs)
schemas.py file to ...
Advice
0
votes
1
replies
33
views
Styling widgets inheriting from ttk.Frame or ttk.Labelframe - ok to add your own custom options?
Something I never realized about ttk styles.. You can apparently add custom options to them for whatever purpose you want. My question is... is this against any best practices? Here's a simple example:...
Advice
0
votes
7
replies
52
views
How to create dynamically-named objects in a for loop in Python where the name is based on the items in the list that you are iterating through?
Apologies if this question has been asked before but I have searched all over the internet and Stack and I can't seem to find a comparable question or explanation.
I'm working in Pandas specifically, ...
0
votes
0
answers
34
views
Pycharm: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 1023
When I use Pycharm's debugger and I inspect a dictionary in the debug window, if there are characters in the dictionary which are somewhat unusual, (Greek, for example), sometimes the debugger will ...
5
votes
2
answers
96
views
Why does a function seem to be executed more times than the number of elements passed to np.vectorize(function)?
I am looking into numpy.vectorize. I define a function f, which takes an input, prints hi {input}, and returns the input unmodified.
import numpy as np
def f(x):
print(f"hi {x}")
...
-1
votes
0
answers
53
views
Picking up random items in balanced matter [closed]
I am currently working on idea to build a program with Python that randomly is picking of items, but in balanced way. I have some ideas how to approach this challenge but I was curious what Stack ...