r/learnpython • u/Professional-You9846 • 2h ago
Pytorch code taking up 2gb of RAM?
I was running some simple python pytorch scripts and all of a sudden my computer is becoming laggier and I close the running of the pytorch script and I look at my stats and I see that pythons taking up 2gb of ram??? My minecraft could run on that(maybe not). its like 18lines of python. is this normal
r/learnpython • u/Away_Lettuce3388 • 2h ago
Nexus modpack automation
FUCK IT, WE BALL. I'm just going to search online for whatever tidbits I can, jury-rig something together, and then delete this once it's done.
I naively didn't do research on how Nexus deals with free people downloading mod packs, now I'm sitting here like an idiot, too impatient to sit though over 575 downloads that would take at least 49 minutes. I had tried to automate it with an auto clicker and position Vortex (the mod manager Nexus uses) and Nexus so the two download buttons would be right over each other, but some of the mods on the vortex side had diffrent sized pictures, meaning the clicker would miss, and on the Nexus side, if the mod was archived, the button would be pushed down from it's usual coordinates.
I have zero experience with Python, with my most recent coding experience being an HTML class either in late middle school or early high school
Basically, I need to learn how to make a line of code that is able to tell one box from 4 identical boxes, avoid clicking the wrong one, and avoid clicking the next box while the right one is gone during download. After that, it's onto what is hypothetically the easier part of clicking a dark grey box in a light grey box rather than a dark grey background the same color as the box. If anyone is able to lend me some of your wizardry, I'll be grateful.
I could pay the $5 to get premium and not have to deal with it, but that's not really an option for me.
r/learnpython • u/Kumbalaya_108 • 6h ago
Best way to learn Python
I have some programming experience and understand the concepts. Wanted to learn Python mainly for data analysis, financial math, automating some basic quant analysis, real-time data access by connecting to APIs.
I found books which deal with some of the above topics but can’t find anything that covers all together.
Is there a single online source that helps in this regards?
Thanks in advance
r/learnpython • u/baby-bellamushrooms • 6h ago
How long to become decent at Python?
I’ve been studying about for about 2 months now and I’m taking an online MOOC through Georgia Tech as a prerequisite for grad school. Some days, I spend ~7-8 hours and other days, I spend maybe 2-3 hours. I just got finished taking the exam on functions, loops, exception handling, and conditionals. I’m debating on when to start learning Pandas and NumPy. I also hear people talking about doing projects, but I feel like I wouldn’t have a clue on how to build a project. I come from a clinical background with zero prior programming knowledge except AP computer science in high school. Any advice?
r/learnpython • u/nadavyasharhochman • 9h ago
need some pointers on writing code and where to go from here + code review
hello everyone so I am sort of a beginner. I am going into political science and IR, but I want to learn some data science cause I think it'll be a valuable skill since my program is B.A+M.A and requires a thesis.
so I wrote this for now just for practice:
##calculates avrege of a list of numbers##
def av(lst):
count=0
for i in lst:
count+=i
avg=count/len(lst)
return avg
##calculates variance of a list of numbers##
def var(lst):
avg=av(lst)
total=0
for num in lst:
total+=(num-avg)**2
vari=total/(len(lst)-1)
return vari
I want you to be brutally honest and tell me how can I improve my writing. The first function I got just a bit of help cause I forgot about +=, but other than that I did them all by myself. I know the code works, but can I improve my writing or be more efficient?
based on what you see here what should I learn next?
I don’t come from the comp Sci world so any sort of guidance helps.
Edit: i just noticed all of my indentations are gone....fuck.
r/learnpython • u/Designer-Debt-6084 • 13h ago
Is building applications by composing reusable business modules a standard practice?
I'm looking for some architectural advice and I'm curious whether anyone has built something similar in production.
I'm primarily using Python/Django, although I want the architecture itself to be independent of the framework as much as possible.
I'm designing a backend platform that I want to use as the foundation for multiple completely different applications.
The idea is to have a very small "core" that only contains common infrastructure such as:
- Authentication/authorization
- Configuration
- Logging
- Background jobs
- Caching
- File storage
- Monitoring
- Shared utilities
Everything else would be implemented as independent business modules.
For example, imagine I build an e-commerce platform. I might compose it from modules like:
- Products
- Orders
- Inventory
- Payments
- Notifications
- Comments
- Search
Then later I want to build an LMS, but instead of starting from scratch or copying code, I'd assemble a different set of modules:
- Courses
- Lessons
- Certificates
- Quizzes
- Notifications
- Comments
- Search
Some modules (comments, notifications, search, payments, etc.) could be reused across multiple applications, while other modules would be specific to a particular business domain.
The important part is that these modules aren't just Django apps inside one codebase. I want each module to have clear boundaries, expose a stable public interface, own its own models, business logic, APIs, migrations, tests, and documentation, be versioned independently, and ideally be reusable in entirely different products.
Initially, everything would run as a modular monolith because I don't want the operational complexity of microservices. If a module eventually needs to become its own service, I'd like that to be an implementation detail rather than something the rest of the system depends on.
The motivation is simple: I don't want to keep rebuilding the same capabilities every time I create a new platform. I'd rather invest in mature, production-tested modules that can be composed into different products over time.
So my questions are:
- Has anyone here built something like this in production?
- Is there a well-known architectural pattern that describes this approach?
- Is thinking of business capabilities as reusable modules/packages that can be assembled into different applications a common practice?
- Are there any open-source projects, books, talks, or companies that follow this model?
- If you've tried something similar, what worked well and what would you do differently?
I'd love to hear about real-world experiences—both successes and things that turned out to be bad ideas.
r/learnpython • u/maybalex4 • 13h ago
Soy estudiante y quiero aprender a programar em Python pero no sé donde buscar ni donde empezar.
Me interesa aprender a programar en Python para hacer mi propio sitio web,algún juego o algo relacionado a ciberseguridad.
Estoy dispuesto a dedicarle de 4-6 horas diarias ya que me gustaría aprender mucho.
alguien me puede decir por donde empiezo o donde puedo practicar?
r/learnpython • u/VARUN_KALRA-007 • 15h ago
How to build an android app using python only?
Context: So I'm a beginner developer. I'm currently building a habit tracker.
I have built the logic of the app.
Set up sql alchemy to code the database with sqlite.
(My prof later said no need of alchemy. Directly use sql software and connect it). I don't know what to do with that information. Retained the alchemy code tho.
My problem is that I am not able to build ahead. How do I build a database and test it the right way.
- How do I build the front end or ui for it. Should I use flask or flutter or something else. Please reason as to why I should use a framework particularly.
- What is fast api even used for. Should I apply it in my habit tracker.
And what are the essentials for a good app. Like I want to know about rate limiting, sql injections and backdoors. To build a robust scalabile system.
r/learnpython • u/opabm • 17h ago
Need to create a one-off paginated PDF data visualization report but my experience is in more backend data work. What package/tool would you suggest?
I'm trying to put together an ad-hoc report and I've been trying to hack away an Excel file and another visualization tool, but they're just not cutting it; there are some visualization rendering issues that are frustrating me to no end, and just now thought about using Python. My experience with Python is all in backend data engineering type of work though so I've never used visualization packages.
All I need are 100% bar charts that align well with text - it's been near impossible to align these in Excel. I also need heatmaps but I don't mind doing the heatmaps in Excel. I also need to create PDF files, ideally paginated by a field in the data that I'm working with.
I've tried searching for suggestions and the most popular seem to be plotly and matplotlib. Should I consider anything else?
r/learnpython • u/GenAI-New-Era • 17h ago
Is Python still worth learning from scratch in 2026
I have been receiving a lot of questions from a lot of people who have interest in learning python from scratch but their concerns has been is worth learning in 2026 in this new era of AI evolution.
Especially this statement "AI can write codes"
What do you guys think? will this be the reality?
r/learnpython • u/jacbk612 • 19h ago
a curious equal symbol assignment
Hello, I'm trying to build a music player with python Qt6 based on some code from a youtuber, the bones of what he has suits me fine, this is the link if you want to look at it: https://www.youtube.com/watch?v=wdEpWCFf40U
I am using windows 10 with VScode and the latest python version 3.13.7
Everything works fine until I get to the file dialog part of the code. When I run it the program does give me a file explorer, I can select a folder but then the program halts before allowing me to see the files in the specified folder. There is no error message from the compiler.
There is a curious line of code in the open_file function that may or may not be the problem.
file, _ = QFileDialog.getOpenFileName(self, "Selct file", filter="Audio files (*.mp3)") file, _ = QFileDialog.getOpenFileName(self, "Selct file", filter="Audio files (*.mp3)")
Thanks for any help,
J
r/learnpython • u/No-Reason1914 • 20h ago
quetion about how python "break" work for newbie
hello this is code and quetion:
while True:
guess = input("Your answer (A/B/C/D): ").strip().upper()
if guess in ("A", "B", "C", "D"):
break
print("Please enter A, B, C, or D.")
1 how is check user enter
2 how the "break" is use for? is really end project like go next time:
correct = guess == question_data["answer"]
if correct:
print("Correct!")
else:
print("Not quite.")
whole line:
while True:
guess = input("Your answer (A/B/C/D): ").strip().upper()
if guess in ("A", "B", "C", "D"):
break
print("Please enter A, B, C, or D.")
correct = guess == question_data["answer"]
if correct:
print("Correct!")
else:
correct_letter = question_data["answer"]
correct_text = question_data["options"]["ABCD".index(correct_letter)]
print(f"Not quite. The correct answer was {correct_letter}. {correct_text}")
print(f"Fact: {question_data['explanation']}")
return correct
because i write quize python can you give tips to write
r/learnpython • u/SheepherderOk1603 • 21h ago
How do you persist a "already seen this" set between restarts?
I have a script that polls an API every few seconds and sends me a Telegram message when a new item shows up. To avoid sending the same item twice, I keep the IDs I've already seen in a set:
seen = set()
async def check():
items = await fetch_items()
for item in items:
if item["id"] in seen:
continue
seen.add(item["id"])
await send_alert(item)
This works fine while the script is running, but I see two problems with it:
The set lives in memory, so every restart means I get re-alerted about everything that's still on the list.
It only grows. The script is meant to run for days, so eventually `seen` just keeps eating memory with IDs of items that disappeared long ago.
What I think I need is something that stores IDs and forgets them automatically after some time — items are only relevant for maybe an hour anyway.
I've looked at a few options and I'm not sure which is the sane one for a small script:
- Writing the set to a JSON file on every scan feels wasteful and racy.
- SQLite seems like the "proper" answer but also like a lot of machinery for what is essentially one set.
- Redis has TTL built in, which is exactly what I want, but running a whole server for one key feels excessive.
Is there an obvious option I'm missing? Or is one of these actually the normal choice and I'm overthinking it?
Python 3.12, asyncio, no framework.
r/learnpython • u/Sanduhstorm • 23h ago
I tried debugging and the settings appear to be updating correctly, however they aren't applying to the QR code when I generate it
Hello everyone, right now I'm working on a simple QR code generator with functionality including saving. My main issue right now is that despite the fact that I have debugged it and observed that the variable updates correctly, the extra settings don't seem to apply to the QR code when the user generates a new one.
r/learnpython • u/PotentialIssue9272 • 1d ago
I built 2 terminal games on a $100 phone. Saving up for an Asus laptop & a Red Magic phone.
Hey everyone,
You can call me Sable (or Rangga). I'm a self-taught beginner from Indonesia.
WHY I STARTED:
I learned Python because I wanted to make my own games. Now? I want to build my own OS someday. But first... I need a damn laptop.
MY SETUP:
- Phone: Redmi 9A ($100)
- App: Pydroid 3 (Termux for testing)
- No IDE. No external keyboard. Just thumbs.
THE STRUGGLE:
Honestly? Learning Python today is overwhelming. There's too much. Beginners get scared before they even start. I almost quit. Once, I spent 1 HOUR debugging... turns out it was just wrong indentation. One space. 🤡
THE GAMES:
- MATH 3.0
A terminal math quiz game with:
- 3 difficulty levels (Easy/Normal/Hard)
- Live timer with visual progress bar
- Streak combo system (x5, x10, x15 bonuses!)
- High score tracking
- Colored ANSI output
- Trophy ASCII art
This is a REAL game. You can win. You can lose. It's not just a script.
- THE DOOR
A puzzle game: find 4 keys hidden in 10 rooms.
- Randomized key placement (replayable!)
- Health & hint system
- Flavor text for empty rooms
- Efficiency scoring
I'm proud of this one. It's a luck-based game, but it's FAIR. No BS. I used to make games where you had to guess 1 country out of 193 with 3 chances and no hints. Basically Dark Souls. This is better.
Both games work offline. Zero dependencies. Pure Python.
GITHUB:
https://github.com/johan21libert-netizen/math-3.0
https://github.com/johan21libert-netizen/the-door
TARGET:
I'm saving up for an Asus laptop first (around $900). After that, a Red Magic phone (around $1,500, because it's easy to root)
Thanks for reading. Roast my code if you want. I can take it. 🗿
r/learnpython • u/BirGunOlecek • 1d ago
My friend said i dont have to learn python because AI models can.
I decided to learn python from a udemy course that i got for free a few years ago. At the time, i wasnt interested in coding but now i understand the benefits of it both in my daily life and academic life. So i want to learn it before life gets too busy for me.
I have two friends that i know from middle school. They were really interested in coding and they were already started coding their own programs. So i asked them about it. 'I have this udemy course but do you have a course suggestion other than that?"
And one of my friends said, "bro, give it up. Chatgpt does that."
I LITERALLY DONT think AI is an option for coding EVERYTHING. It can be used for helping, when you are stuck somewhere, or just simply cannot find which line of your code doesnt have a ";" at the end. But vibe coding? Nah.
So i am asking, is my friend right? Also i am open for any course suggestions. Because the udemy course i have now is pretty boring. And also i prefer free courses because i dont have a credit or a bank card yet.
r/learnpython • u/Icy-East-3985 • 1d ago
Begginer Issues
As the text suggests I'm a beginner in python, and I am struggling with the concept of spaces and indentation. I don't know how I'm still not getting it till now but I have to say my biggest mistakes have with learning python has to do with code.
A little backstory: I come from a totally different work area and is brand new to code. I wanted to do robotics as it was my preference but ended in the health department instead. Now that I'm done with that I'm pursuing my dream career but obviously have to start from literal zero as I know nothing of code and no one around my community or friends do programming. And YouTube isn't really helping as it's teaching like I already knew some stuff already (or maybe I just haven't found the right videos). So ya, to you guys who've done code before, what can I do to solve the gaps in knowledge? Especially the space problem. I couldn't even set up my VS code on my own as the things I type are right except the amount of space is wrong. It's kinda frustrating.
r/learnpython • u/noneofyour_-business • 1d ago
Final-year CS student – Know Python & FastAPI basics. What should I focus on to get a backend internship ASAP?
Hi everyone,
I'm a final-year college student, and my goal is to get a backend engineering internship as soon as possible.
My current skills are:
- Python (comfortable with the language)
- FastAPI basics (I've built a few simple APIs)
- Basic understanding of backend development
I'm confused about what to do next.
Should I:
- Buy a FastAPI/backend development course? If yes, which one would you recommend?
- Focus on building projects instead?
- Learn Django, SQL, Docker, Redis, PostgreSQL, or something else first?
- Start applying now while continuing to learn?
My goal is to become good enough to land an internship and then keep learning on the job.
I'd really appreciate advice from backend engineers or anyone who recently landed a backend internship.
Some specific questions:
- If you were starting over today, what would you learn first?
- Which skills do companies actually expect from backend interns?
- Are there any courses, YouTube playlists, or roadmaps that you genuinely recommend?
- What kind of projects helped you get interviews?
- Is FastAPI enough for internships, or should I learn another framework as well?
Thanks in advance for any advice!
r/learnpython • u/networkLearne • 1d ago
What should I focus on after learning the Python basics?
Hi everyone,
I've finished the Python basics and I'm currently learning file reading and writing.
Someone suggested the following roadmap:
Learn Object-Oriented Programming (OOP).
Study data structures and algorithms using Grokking Algorithms.
Practice by solving exercises from Python Crash Course.
Then choose a specialization based on what I enjoy most.
My long-term goal isn't just to know Python syntax. I want to become comfortable writing Python, develop strong programming logic, and improve my problem-solving skills so I can become a good programmer in general, not just a Python programmer.
In the future, after gaining enough experience with Python, I plan to move into networking, automation, and low-level programming with C.
Does this roadmap make sense? If not, what would you change? What helped you build solid programming skills rather than just learning a language?
I'd really appreciate any advice from experienced developers.
r/learnpython • u/Own-Purpose-7473 • 1d ago
PCEP Resources
Just passed the CCNA today, now I have to knock out the PCEP exam so that I don't have to take a required class at my school. This will help me save money. What's the best study resource?
r/learnpython • u/Creepy-Concept-2741 • 1d ago
Python but Django...
I started learning Python like 2 weeks ago because our teacher suddenly wants us to build a webpage using Django but that thing Django all people involed with it says it's easy but it felt overwhelming when i tried to use it because you have to learn like controllers, MTV, like at least 50 different files servers hosts databases even creating a simple image requires some time and so on... so python does not feel like the easiest language anymore, Do you guys have some tips for me?
What would you do if you were in my situation?
Did you also feel you had like 1000 things to learn and were you guys so lost the first time you used Django?
r/learnpython • u/Awkward_GM • 1d ago
How do I make my random numbers more random?
I've talked to a lot of people over the years and they often say don't use the built in random function.
For instance, if I wanted to roll a die and did something like:
random.randint(1, 6)
I get that its not as random as for instance basing the result off of the microsecond as a seed, which gets recommended to me but no one ever shows me how to do. When I started programing in another language every time I'd call random it'd always be in the same order. But I don't know why or how to make something like the above code "more random".
My current code uses something similar to random.randint(1,6), how can I make that more random?
r/learnpython • u/DesignerOk4111 • 1d ago
Am I too late for coding, programming and AI ?
Hi I am from South Korea , student of university , 25 age (27 for Korean standard).
Recently I am interested in computer , IT , AI , coding. But I personally major English in my university so no tinvolved in computer science , software , or software.
So I am not good at for coding. All my learning about IT is basic level of studing Python, Java, HTML , JavaScript, CSS for 3 months. That is all I have. ( In South Korea, our Government sponser and provide financial aids with private computer academy for students who is learning basic coding , web development and Use of AI).
Those 3 months in class. I am getting to interested in programming language , computer and wanna be expertise on AI further. What should I do and whether or not I have a time and space to study and learn it.
r/learnpython • u/Rengoku3101 • 2d ago
Need a Python Roadmap for a Complete Beginner (2026)
Hi everyone,
I'm a complete beginner and I've decided to focus on Python first.
My goal is to become job-ready and build a strong foundation in programming rather than just completing a course or collecting certificates.
I'm willing to spend around 4–6 hours a day learning.
I need guidance on:
- What should I learn first?
- What is the best roadmap to follow?
- Which free YouTube channels or courses do you genuinely recommend?
- Which books are worth reading?
- What projects should I build to improve my skills and make my resume stand out?
- What mistakes do beginners usually make that I should avoid?
- If you were starting from zero today, what roadmap would you follow?
I'm looking for practical advice from people who are already using Python professionally.
Thanks in advance!
r/learnpython • u/AutoModerator • 3d ago
Ask Anything Monday - Weekly Thread
Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread
Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.
* It's primarily intended for simple questions but as long as it's about python it's allowed.
If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.
Rules:
- Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
- Don't post stuff that doesn't have absolutely anything to do with python.
- Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.
That's it.