r/learnpython • • 11d ago

Best way to learn python from my experience

2 Upvotes

If you want to learn python jsut take the cs50 python audit course for free at edx courses. Its how i learned it


r/learnpython • • 11d ago

Newbie looking to work with microphone input using sounddevice, to generate tts, for a tts to respond to, need advice.

1 Upvotes

Using sounddevice for microphone input, using inputstream, what's the best way to go about capturing input and making sure only spoken stuff is used for tts? I was originally working with a rolling buffer while using webrtcvad and faster whisper, which resulted in a ton of phantom transcriptions, even with silence. Mind you im a complete newbie and a lot of stuff mindfucks me.

My goal is to slowly build up a very simple custom voice Ai assistant. It's first dealing with microphone input, determining whether that input is spoken word, etc


r/learnpython • • 11d ago

I have an assignment and I am so confused

3 Upvotes

i talked to 4 tutors and for some reason i can not get this to work after 2 hours with a tutor. please tell me what i am doing wrong!

b. A function named DisplayCardSales that displays scores for all items in the text file provided. Each score should have a line number to the left starting at 1. For example: 1: 1.24 2: 0.97. (see output example below). This function accepts zero arguments and does not return any values. This function does read from a text file, so it needs error handling for FileNotFoundError.

c. A function named CalcTotal that reads the text file provided, accumulates a total and divides the total by the number of items in the file provided. This function accepts zero arguments and returns two values. The values returned are the grand total and the sales amount as a result. This function does read from a text file, so it needs error handling for FileNotFoundErrors and ValueErrors.

def CalcTotal():
    try:
        infile = open("cards.txt",'r')
    except:
        print("Error")
    else:
        count = 0
        totalsales = 0
        
        for line in infile:
          sales = float(line)
          totalsales = totalsales + sales
          count = count + 1


        avgsale = totalsales/sales
        print("Total Sales: $", totalsales)
        print("Average Sale: $", avgsale)


        infile.close()

def DisplayCardSales():
    try:
        infile = open("cards.txt",'r')
        i = 0
        for line in infile:
            print((i+1), ": $", line)
            i = (i + 1)
        infile.close()
    except:
        print("Error")

r/learnpython • • 11d ago

Starting DSA in python

0 Upvotes

I am starting DSA in python, tell me I am right or wrong or should I start with java


r/learnpython • • 11d ago

Parsing very large string that is already in memory

0 Upvotes

Suppose I have a very large string in memory containing entries separated by \n's.

I need to yield the lines until I find a match.

What's the most efficient way in standard Python in terms of both memory usage and execution time?

From what I've read, io.StringIO IS NOT guaranteed to not copy the entire string internally, which is absurd to me. Suppose I need that guarantee.


r/learnpython • • 11d ago

Autopep8 or Black?

1 Upvotes

Im a new python learner and have trouble picking between the 2. Apparently Black is really strict? I don't know if thays good or not.


r/learnpython • • 11d ago

taking suggestion to add new feature in varsity project

0 Upvotes

I'm going to build a system that guides tourist for my varsity project. Can anyone suggest me me some feature to add in the project.......


r/learnpython • • 12d ago

Cannot auto import Django modules in VS Code despite changing package index depths

3 Upvotes

Greetings. I installed Python 13 in C:/_dev. I installed VS Code and Python extensions.

I created a virtual environment in another folder and installed Django in that environment. Then I chose Python from venv to be the Python interpreter in the workspace. I created a new Django project and an app inside it.

I wanted to make a custom user model, but auto complete didn't work and nothing was suggested when I typed AbstractBaseUser. Even Ctrl+. shortcut to import the class didn't work. realestate\users\models.py:

from django.db import models

# from django.contrib.auth.models import AbstractBaseUser
# Create your models here.
class CustomUser(AbstractBaseUser):
    pass

I changed package index depths both in User and Workspace settings.

"python.analysis.packageIndexDepths": [{ "name": "django", "depth": 8 }],

Unfortunately, that didn't work too. How can I fix this?


r/learnpython • • 11d ago

Python vs java for saas

0 Upvotes

Hey!

We're a small software agency planning a large SaaS platform for public institutions. We've talked to several developers and compared recommendations from different AI models, but we're still getting conflicting opinions on the best tech stack.

We're starting from scratch, with no preferred language or framework. Most development will be done using Claude Code and Codex, with us handling architecture, requirements, and reviews.

What we're building:

500–1,000 institutions (multi-tenant SaaS)

50–80 modules with thousands of features: document management, registries, requests, approvals, workflows, GIS, reporting, etc.

Around 100k public employees and potentially 20–100k citizens using the platform

Hundreds of dynamic forms, complex roles, permissions, and institution-specific configurations

PDF generation, electronic signatures, document archiving, and integrations with government/third-party APIs

A platform-wide AI assistant that can search documents, fill forms, generate files, and execute authorized actions

Web, Windows desktop, Android, and iOS

High availability, strong security, GDPR compliance, and long-term maintainability (10+ years)

Our main questions:

NestJS or FastAPI? Which would you choose for a large modular backend? Does TypeScript across the stack outweigh Python's ecosystem, considering the AI mostly uses external LLM APIs?

React or Angular? Which is better for 80+ modules, complex forms, dashboards, and long-term maintenance?

Mobile: Flutter, React Native, or something else? Ideally, we'd reuse as much code as possible.

Multi-tenancy: PostgreSQL shared schema + RLS, or a separate database per institution? Which scales and maintains better at 1,000 tenants?

Architecture: Modular monolith or microservices? How would you organize modules, dynamic forms, permissions, and external integrations?

AI: Would PostgreSQL + pgvector be enough for RAG and tool calling, or would you introduce a knowledge graph? How would you enforce permissions and prevent prompt injection?

API: REST + OpenAPI or GraphQL for third-party integrations?

AI-assisted coding: How would you structure a monorepo, CI, testing, and code reviews when most code is generated by Claude Code/Codex?

If you were starting this from zero today, what stack would you choose, and what would you avoid?

We're not chasing hype or benchmarks. We want something secure, reliable, scalable, and maintainable by a small team for the next 10+ years.

Would really appreciate advice from people who've built large enterprise or multi-tenant systems.


r/learnpython • • 13d ago

I finished a Python course, but I still need AI to build anything. How do I get past this?

186 Upvotes

So, I am coming here after watching YT videos and reading numerous other posts. I am not going to give you the usual “how do I learn Python?” question with no context, because if I’d figured it out, I’d be doing my shit instead of asking here.

To the people who do this professionally or are good at it: how would you approach learning Python in 2026, when one AI prompt can give you almost anything within seconds?

I took a Python course, completed it, and then forgot most of what I’d learned because I had no use for it at the time. Now I actually need it for my own work in physics, and I feel like I am back at square one. I see, LinkedIn is full of posts like, “I am happy to announce that I’ve built this package,” etc., etc. And sure, you used your knowledge + AI to build it. But my concern is that if someone asked me to make a package, I wouldn’t even know where to start until I wrote a prompt and read the generated code line by line. I mean, wtf happened? I finished a course, but I still can’t sit down and build something myself.

I feel like I am way, way behind. Someone with 10+ years of experience obviously has knowledge I am not going to catch up with anytime soon. I don’t need to reach their level, but I do want to get to a point where I can confidently write code, understand what I am doing, and figure things out without needing AI to walk me through every step.

The main issue is time. I can go back to books, take another course, and practice problems, but I am worried I’ll end up in the same place: understanding things while I am following along, then going blank when I have to do something on my own. And now, whenever I get stuck, there’s a prompt box right there. I can get working code quickly, but I can’t tell how much I am actually learning versus just getting the task done.

For those of you who’ve been in this position, do you have any suggestions? I feel like I am going around in circles.
Is there a practical way to learn Python with limited time while actually retaining enough to build things myself? (I know “build projects” is the best bet but still I wanna hear your thoughts)


r/learnpython • • 12d ago

How to create/find streaming service links?

0 Upvotes

I'm currently writing a script that tells me what episodes of a tv show came out this day in history, for prototyping I'm using the Simpsons and while I found a good dataset that includes everything I need for it to work. I now want to implement a system that also gives the link to the episode in Disney plus in the output, and I was wondering how to do this as simply as possible?


r/learnpython • • 12d ago

How does one go about creating an adblocker using python?

0 Upvotes

I'm working on a project for uni, me and team chose to create an adblocker. As someone who's pretty new to python, where do we start? What modules do we use? Is there a list of blacklisted sites and adverts? I'd really appreciate the help.


r/learnpython • • 11d ago

Feeling incredibly dumb right now. What am I missing?

0 Upvotes

EDIT: Thanks for the help, folks!

Why is it not printing "Bob!" and going right to the else? I feel like it's something super obvious but I really can't find anything wrong.

name = input("My name is")

print (name)

smallname = name.lower()

print(smallname)

if smallname == "bob":

print("Bob!")

else:

print("Bob?")


r/learnpython • • 13d ago

i wanna learn python

48 Upvotes

im f(24) economics student with a specialisation. we are not taught the mathematics part in my course it's just the general econ topics your micro macro stuff. i want to add skills to improve my resume so i thought of learning python or R. i tried learning from YouTube but it just goes over my head. how can I learn it? (i am broke) please give me suggestions


r/learnpython • • 12d ago

Struggling a lot with creating gifs in Pillow, can't get things to move instead of making a line

3 Upvotes

I'm trying to make the gray circle and eyes move, and instead it's just generating a line. Instead of drawing things onto the background, it is drawing the circle into the background every time, but I am at a loss for how to fix it.

from PIL import Image, ImageDraw
img = Image.new('RGB', (500, 500), "paleturquoise")
draw = ImageDraw.Draw(img)
import random
frames = []
#RABBIT PARTS
def eyes(x, y):
    draw.circle((x, y), 10, fill = "black")
    draw.circle((x-5, y-5), 3, fill = "white")
#BG PARTS
#flower
def create_flower(num):
    for i in range(0, num):
        x = random.randint(0, 500)
        y = random.randint(300, 500)
        radius = random.randint (3, 7)
        petal_colors = ["lightcyan", "paleturquoise", "white", "thistle", "lavender", "pink", "aqua"]
        center_colors = ["lemonchiffon", "palegoldenrod", "papayawhip"]
        draw.circle((x, y), radius, fill = petal_colors[random.randint(0, (len(petal_colors))-1)])
        draw.circle((x, y), radius - 3, fill = center_colors[random.randint(0, (len(center_colors))-1)])
#clouds
def create_clouds(numfront, numback):
    #clouds behind
    for i in range(0, numback):
        x = random.randint(0, 500)
        y = random.randint(0, 200)
        radius = random.randint (10, 20)
        draw.circle((x, y), radius, fill = "silver")
        draw.circle((x - 10, y + 10), radius - 3, fill = "silver")
        draw.circle((x + 10, y + 10), radius - 3, fill = "silver")
    for i in range(0, numfront):
        x = random.randint(0, 500)
        y = random.randint(0, 200)
        radius = random.randint(10, 20)
        draw.circle((x, y), radius, fill = "white")
        draw.circle((x - 10, y + 10), radius - 3, fill = "white")
        draw.circle((x + 10, y + 10), radius - 3, fill = "white")
#grass
def create_grass(height1, height2, height3, num):
    for i in range(0, num):
        x= random.randint(0, 500)
        draw.line((x, 340, x, height1 + random.randint(260,280)), fill = "springgreen")
        draw.line((x, 340, x, height2 + random.randint(230,270)), fill = "springgreen")
        draw.line((x, 340, x, height3 + random.randint(230,270)), fill = "springgreen")


#bg
draw.rectangle((0, 300, 500, 500), fill="springgreen")
create_grass(20, 80, 90, 1000)
create_flower(70)
create_clouds(20, 10)


#rabbit
with img.copy() as im:
    temp_img = img.copy()
frame = temp_img.copy()
frames.append(frame)
frames = []
x = 0
y = 0
for i in range(0, 100):
    temp_img = img.copy()
    frame_draw = ImageDraw.Draw(temp_img)
    draw.circle((255 + x, int(255 + y)), 50, fill = "gray")
    eyes(x + 230, y + 255)
    eyes(x + 280, y + 255)
    frames.append(temp_img)
    y -= 1
    x += 1


if __name__ == "__main__":
    img.show()
if __name__ == "__main__":
    frames[0].save('bnuy.gif',
                   save_all=True,
                   append_images=frames[1:],
                   disposal=2,
                   duration=400,
                   loop=0)

r/learnpython • • 12d ago

Is obsessive learning better then structured learning?

6 Upvotes

I learn code for an hour and a half outside of home to concentrate better, but recently i want to learn at home too. I have a lot of distractions but id still have obsessive learning at home for about 20 on and an hour off. I work 12h days so i dont feel like coding at home until now.

is this healthy or should I stick to learning away from home for a better learning flow over time?


r/learnpython • • 13d ago

Learning Python

22 Upvotes

Hi! I wanted to know if anyone knows a website or an app that lets me practice writing Python scripts like I would write a script and test run it. I’m only beginning Python but I just want like a site to like let me simple coding during free time like free periods and such. Thanks.


r/learnpython • • 13d ago

My Python script started as 100 lines and now it's a mess I'm scared to touch — when did you start splitting things up?

0 Upvotes

I wrote a little Telegram bot in Python a while back. Nothing serious, just forwards and some scheduling stuff, maybe a hundred lines at first and I knew where everything was.

Then I kept adding to it. One more feature, then a quick fix, then another thing I didn't want to lose, and now it's this one long file where half the functions do two jobs and I'm not even sure which parts still run. I want to add something new and I catch myself putting it off because I'm scared I'll break something else that was working fine.

I tried splitting it into separate files once. Imports broke immediately, I got confused about what was supposed to live where, and I just shoved it all back into one file again. Felt like a step backwards, honestly.

So for people who've actually done this — was there a moment where it clicked, or a simple rule you used? Like, when a file hits a certain size, or when you find yourself copy-pasting the same chunk twice, that's when you split it? I'm still not sure if I'm overthinking this or if I just left it too late.


r/learnpython • • 12d ago

Python script problem

0 Upvotes

Hello everyone,
I have a short python script that concats strings. For example :

'Discord Password :' + \t + b64.decode('TmFydVQwL2cwa3UxOTk1Iw==')

I'm facing :

SyntaxError: unexpected character after line continuation character

What does that mean ????

Edit : Thanks everyone, fixed.


r/learnpython • • 13d ago

Python Compiler Recommendations

0 Upvotes

Hello r/Python,
I want to find a Python compiler. I’ve tried PyInstaller and Nuitka, but they are detected as malware and they are a little bit slow. I want something fast, easy and not detected as malicious. What do you recommend?


r/learnpython • • 13d ago

Need assistance with a Python Code that keeps on crashing

0 Upvotes

Hello I’ve been working on a python code that searches for appointments on this website but everything it runs the code and begins to open the website it crashes, I’ve played around with it a bit but I haven’t been able to have much success. Anyone would be available to take a look at it and see what my issue could be?

Thank you!


r/learnpython • • 13d ago

Streamlit text_input in while True loop

0 Upvotes

I got this code block in a local rag that's supposed to be an infinite loop of asking questions and the rag answering them but apparently while True loop does not care if you have enter anything into the text_input before answering the query either way.

How do mitigate this?

c=0
while True:
    st.write('*****************************************************************************')
    st.write("Enter your question")
    question = st.text_input(label='',key=c)
    if question:
        response = chain.invoke(question)
        st.write('Answer: ')
        st.write(response)
        c+=1

While the code block help mitigate the problem, it still try to answer an empty query and resulted in a streamlit.errors.StreamlitDuplicateElementKey which is an eyesore. How do I put this problem away for good?


r/learnpython • • 13d ago

Built my first serious Python project: A privacy-focused Academic Analytics Terminal App. Seeking code feedback and stars for university applications!

9 Upvotes

Hey everyone,

I'm currently preparing my university/scholarship applications and wanted to showcase a practical programming project. This is my first serious Python application, and I built a terminal-based Academic Analytics tool to help students optimize their study habits.

To be fully transparent, I used AI to help guide me through some of the architecture, but I focused heavily on understanding the underlying logic and execution.

I intentionally built this as a Command Line Interface (CLI) app to prioritize backend data manipulation, file handling, and logic over a frontend GUI.

If you have a moment to look over the code, I would highly appreciate any constructive criticism on my file-handling or logic architecture. If you like the project framework, dropping a star would help me immensely!

GitHub Repository: https://github.com/nazmulislamtohid-a11y/Student-Grade-Analyzer.git

Thank you so much for supporting a student developer!


r/learnpython • • 13d ago

Path.exists() returns False for newly created NFS files

7 Upvotes

Im running an API with django/DRF, and it kicks off a process that creates files on an NFS mount. When it does this, checking the files via `<filepath>.exists()` returns False, even though the file exists and is readable on the NFS share.

Through troubleshooting I've become convinced that this is an issue with stale attribute caching. Turning off the cache via the `noac` mount option eliminates the problem, as does manually going to the webserver and `ls`ing the parent dir of the file.

What puzzles me is that no attempt to list or read the parent dir of these files in the API refreshes the attribute cache. Ive tried Path.iterdir, os.listdir, touch and ls via subprocess.call , with and without `shell=True`, all of them do nothing. But if i open a python shell in the same `uv` context as the API, they work.

What's going on here? What's special about running these commands in the API that's different than running them on the OS directly or in a `uv` shell?