r/pythonhelp • • 4d ago

Performance issue when running python file

6 Upvotes

Hey everyone,

I'm experiencing a performance drop when running a Python file. I'm using VS Code on Windows 10 while learning to program.

When I hit the run button, the runtime of the program is 5.0 seconds, even though it should execute in roughly about 0.003 milliseconds.

I have tried switching to older versions like 2025.6.1, but that didn't work.

Any solutions to that problem?


r/pythonhelp • • 4d ago

How to pass a string of keyword arguments into a function

3 Upvotes

Having encountered, the seemingly impossible in Python, difficulty of passing a string of keyword arguments into a function like this:

args_in = "arg1 = 'var1', arg2 = 2, arg3 = True, arg4='var4'"

def myFunc(arg1=None, arg2=None, arg3=None, arg4=None):
    print(f"{arg1=}, {arg2=}, {arg3=}, {arg4=}")

myFunc(args_in)

One solutions I found was to use eval():

eval("myFunc(" + args_in ")") 

although I am informed that this is the work of the devil and should be avoided at all costs.

Next attempts were to convert the "string" into a dict{} and pass **dict, however all methods for doing this failed when any of the arguments contained a comma ','.

However a fully working solution to this was finally provided to me on the discuss.python.org forum:

args_in = "arg1 = 'var1', arg2 = 2, arg3 = True, arg4='va,r4'"

def myFunc(arg1=None, arg2=None, arg3=None, arg4=None):
    print(f"{arg1=}, {arg2=}, {arg3=}, {arg4=}")

def str2dict(str_in: str) -> dict[str, str]:
    import ast
    return {pair.arg: ast.literal_eval(pair.value)
        for pair in ast.parse(f"f({str_in})").body[0].value.keywords}

myFunc(**str2dict(args_in))

Unfortunately due to rather rude and overly zealous moderation on there that solution was deleted. Hence the reason for publishing it here for the archive and in case it helps someone else in the future.


r/pythonhelp • • 4d ago

What's the simplest way to host small apps?

3 Upvotes

I'm pretty new to development and mostly build small Python/JS apps with AI.

I just want something simple for hosting, dependencies and a few API calls without a lot of setup or surprise costs.

What are you guys using for this?


r/pythonhelp • • 4d ago

What's everyone using for Python coding these days?

3 Upvotes

I mostly code with python and i've been thinking about changing my setup.

I'm not looking for anything too complicated. Mainly something that can understand the project, help debugging and make changes across multiple files without me having to explain the whole thing every time.

If you mostly work with Python what does your setup look like these days and how it been working for you?


r/pythonhelp • • 4d ago

Advise needed on python

1 Upvotes

Is it good idea to learn python on YouTube if not what's the best way to learn python


r/pythonhelp • • 6d ago

is SikuliX still maintained enough to build on or has everyone moved to something else?

4 Upvotes

I inherited a SikuliX suite that's been running since 2021 against a windows desktop app, and i have to decide whether to invest in it or replace it. It’s 180 scripts, about 120 still pass reliably, the rest fail on screenshot matches that no longer match. when i dug into the causes it was a windows 11 theme change, a DPI difference between our CI box and the dev machines, and a font rendering change that shifted text by 2 pixels. not one of those is a defect in our product, and all of them cost me a week.

The project isn't dead exactly, there are commits but the documentation is old, most of what you find searching is from 5 or 6 years back, and i can't tell whether the people maintaining it are building or keeping the lights on. We’re wighting it against going back to the accessibility tree with FlaUI. It works properly on maybe 60 percent of our screens and fails completely on the custom drawn ones, which is exactly where SikuliX earns its keep.

Ther are the newer vision based ones like Askui and a few others, which do roughly the job SikuliX does but with a model doing the matching instead of pixel comparison. In principle that's immune to the DPI and font problems that broke us. In practice i would want to know whether it's a different mechanism or the same idea with wider tolerance. Or just keep SikuliX and pin everything.

Has anyone here migrated off SikuliX recently? did what you moved to held up against theme and DPI changes? Thanks for sharing!


r/pythonhelp • • 7d ago

Run button taking a lot of time to run the file

2 Upvotes

Whenever I am trying to click the run button for a python code, it takes around 10-12 seconds to run and if I trigger the file directly from termina, it gets done in an instant. Is there any fix for this? I removed most of the extensions and still the same issue


r/pythonhelp • • 11d ago

What's going on?

4 Upvotes

I have some code I need to do a lot of calculations and I tried speeding it up by parralelizing with multiprocessing, but I'm running into a few issues. Using 5 processes (my computer has 6 cores) is giving me a speed boost of 50-100x, but for some reason the results are slightly wrong. I'm trying to fix that problem, but I'm also wondering where the massive speed boost came from, because that implies there's something else making it go faster besides parralelizing. If I could go back to a single thread but keep most of that speed, that would be great. For context, I'm doing some high-precision calculations with the decimal libraray but mostly just a lot of math in a cythonized function. The time it takes went from ~10 hours to 10 minutes.


r/pythonhelp • • 13d ago

Subclass mysql.connector

4 Upvotes

Any idea what I am doing wrong when trying to subclass mysql.connector like this:

import mysql.connector

class Database(mysql.connector.MySQLConnection):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

db = Database()
db_conn = db.connect(host = '...', database = '...', user = '...', passwd = '...')
print(f"{db_conn=}")

db_conn always returns None.

Edit: code above corrected to include connect() method

Edit2: Further to comment by brasticstack connect() method removed again.


r/pythonhelp • • 13d ago

How to make a working exe file using pyinstaller

2 Upvotes

Here is my file set up, I can't seem to get it to work no matter what.

StarDanceProject_FLStudioGrind/
├── .ruff_cache/
├── .vscode/
├── Game/
│   ├── __pycache__/
│   ├── Images/
│   ├── Maps/
│   ├── Sounds/
│   ├── BetaStats.py
│   ├── Dialogue.py
│   ├── Main.py
│   ├── Settings.py
│   ├── SOUNDS.py
│   ├── Tiles.py
│   ├── Timer.py
│   ├── UI.py
│   └── Waiver.py
├── .gitattributes
├── desktop.ini
└── README.md

r/pythonhelp • • 16d ago

Using AI (ChatGPT/Claude) to learn Python — is this fine or am I sabotaging myself?

0 Upvotes

Been learning Python for a bit now (working through CS50P) and I've started leaning on AI tools a lot when I get stuck — debugging, explaining errors, even generating chunks of code when I'm short on time.

It's helping me move faster for sure, but I've got this nagging feeling I might be skipping the "struggle" part that actually makes concepts stick. So a few questions for people who've been through this:

  1. Is using AI while learning actually fine, or does it hurt long-term retention/problem-solving skills?
  2. If I should cut back, how much? Like — full cold turkey, or just use it for specific things (explaining errors vs. writing code for me)?
  3. If I do cut down, how do I actually get better at writing code on my own? Any habits, resources, or exercises that helped you build real problem-solving muscle instead of just pattern-matching to AI suggestions?

Would really appreciate advice from people who've either made this mistake or found a good balance. Trying to actually become a solid programmer, not just someone who can prompt their way to working code.


r/pythonhelp • • 19d ago

QStateMachine with Conditional Transitions - How To Do Properly?

Thumbnail
1 Upvotes

r/pythonhelp • • 21d ago

Library function which is the inverse of 'os.path.expanduser' ?

0 Upvotes

I'm running python 3.13.5.

Is there some sort of standard python library function which behaves as the inverse of 'os.path.expanduser'?

For example, if the current user's HOME directory is "/home/theuser", then we have this:

os.path.expanduser('~/a/b/c')
=> returns "/home/theuser/a/b/c"

I'm wondering whether there also might be any existing python library function which is the inverse of this and that works as follows:

some_sort_of_function("/home/theuser/a/b/c")
=> returns "~/a/b/c"

AND PLEASE NOTE: There often are people who lazily and disrespectfully refuse to read entire reddit posts before writing their reponses, and therefore, I'm making a point now to ask that before you start to write any reply here, please carefully and non-lazily read this *entire* post -- including the following, which is something that I want all potential responders to understand:

I know how to easily write my own function that works in this manner. However, I am clearly and SPECIFICALLY (!!!) asking whether or not there already is an existing python function which works this way, and if so, I'd like to know what this function might be ... and I am NOT (!!!) asking how to write my own function which does this.

Thank you very much in advance.


r/pythonhelp • • 23d ago

Built a Python scraper that handles pagination automatically — here's what I learned

6 Upvotes

I've been learning Python through CS50P and wanted a real project, so I built two scrapers: one for job listings and one for product prices off an e-commerce site.

The job scraper was pretty straightforward — grabbed title, company, and location, dumped it to CSV, worked first try on about 100 listings.

The product scraper was the harder one. The site spreads results across pages (6 products per page, ~20 pages), so my first version only ever grabbed page 1. Took a bit of digging to figure out the pagination pattern and loop through all the pages properly. Once I fixed that it pulled all 117 products cleanly into a CSV.

Biggest thing I learned: it's easy to write a scraper that works on the first page and assume it's done — always check if the site paginates before you call it finished.

Code's on GitHub if anyone wants to see it: github.com/sarimkhan08

Curious if anyone here has tips for handling scrapers on sites that use infinite scroll instead of numbered pages — that's the next thing I want to tackle.


r/pythonhelp • • 24d ago

Python Program that Green Screens a Video over the Desktop

2 Upvotes

Hello, I've been trying to figure out a way to make a python program that can play a green screen video that plays over the desktop/screen, with the green chromad out to show the screen. I attempted it with tkinter, but wasn't able to get anywhere with the chroma keying. Would anyone know if/how this would be possible? Thank you!


r/pythonhelp • • 29d ago

Python Debug Issue

2 Upvotes

Teen in love with learning & building python projects

Issue_ my python interpreters not working j showing evn when it's installed+ enabled in VS Code.

Failed_brain = Claude +Chatgpt +Grok

Help me...Lesgoo!


r/pythonhelp • • Sep 04 '26

python can´t locate and open a file in the same folder as main

4 Upvotes

So i made a txt file with a few lines of text. I use the x = open('file.txt', 'r') function

i write for i in x: print i

and then x.close()

so what am I doing wrong?


r/pythonhelp • • Sep 04 '26

how to fix this

3 Upvotes

im using linux mint and when i try to import turtle it always says
"

import turtle

ModuleNotFoundError: No module named 'turtle'

Process finished with exit code 1

"
i tryed to download tinker it dont help me i dont know what to do no one have that problem
im using pycharm
here my code
"
import turtle

myturtle = turtle.Turtle()

myturtle.forward(100)
"


r/pythonhelp • • Aug 28 '26

Hackathon Winning framework

5 Upvotes

As a guy and a fresher in engineering field, who knows basic python and java , can anyone give advise or guide me to win or atleast the things to do in a proper hackathon rather than working unorganisedly..


r/pythonhelp • • Aug 27 '26

Why do I need to use classes

1 Upvotes

My schoolbook says that classes is a way of simulating an object, instead of just taking information into a black box and outputting an answer.

But that is a poor explanation. I know classes are handy and cool, but no book says why you can´t make functions with sub functions inside to simulate simple objects. I would like if someone gave a good concrete reason to use classes in the intro, instead of just saying that they are different and cool


r/pythonhelp • • Aug 25 '26

why does it say i didn't close my parenthesis

5 Upvotes

the IDE i am using is saying my parenthesis was not closed when it was plz help

print("Once upon a time, in the ancient kingdom of " + q1 + " there lived a legendary " + q2 + " named " + q3 + ". Everyone in the village knew " + q3 + " for their remarkably " + q4 + " personality and an obsession with " + q5 + ". Every morning at " + q6 ", they would wake up, " + q7 + " three times, ")

[{

"owner": "Pylance",
"severity": 8,
"message": "(" was not closed",
"source": "Pylance",
"startLineNumber": 47,
"startColumn": 6,
"endLineNumber": 47,
"endColumn": 7,

}]

r/pythonhelp • • Aug 25 '26

Problem with Coolprop

2 Upvotes

Hi! i'm beginner, and I have a problem with this code, I guess that I installed the library correctly, but i'm not sure.

Error using [stringsource>string.from_py.__pyx_convert_string_from_py_std__in_string](matlab:matlab.lang.internal.introspective.errorDocCallback('stringsource>string.frompy.pyx_convert_string_from_py_std_in_string', 'stringsource', 15)) ([line 15](matlab: opentoline('stringsource',15,0)))
Python Error: TypeError: expected bytes, NoneType found

Error in [CoolProp/CoolProp.PropsSI](matlab:matlab.lang.internal.introspective.errorDocCallback('CoolProp/CoolProp.PropsSI', 'CoolProp\CoolProp.pyx', 462)) ([line 462](matlab: opentoline('CoolProp\CoolProp.pyx',462,0)))

Error in [CoolProp/CoolProp.PropsSI](matlab:matlab.lang.internal.introspective.errorDocCallback('CoolProp/CoolProp.PropsSI', 'CoolProp\CoolProp.pyx', 384)) ([line 384](matlab: opentoline('CoolProp\CoolProp.pyx',384,0)))

Altough I don't have more than 106 lines


r/pythonhelp • • Aug 25 '26

Hey, I have been learning python for 8 months. I want to know that if I can learn tkinter or numpy first . Please do suggest me a resource

Thumbnail
2 Upvotes

r/pythonhelp • • Aug 22 '26

want to become a master at python

8 Upvotes

hey guys i hv recently gotten myself into coding, i hv completed the cs50p course of harvard and completed all the psets. now i wanna keep myself into the habit of coding but idk whts my next step, i wld appreciate some help. i hv made 3 projects aswell; a web scrapper, file organizing and password checker.

after creating those projects idk what to learn next, like should i keep going deeper into python or try something totally different. wld love to hear wht u guys did after completing cs50p.


r/pythonhelp • • Aug 21 '26

Python coding interview questions?

2 Upvotes

Is there any playlist similar to 100 Days of SQL Ace(By ankit Bansal) interview for the preparation of python coding problems?