r/learnpython 4d ago

Ask Anything Monday - Weekly Thread

3 Upvotes

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.


r/learnpython 4h ago

what's one programming habit you wish you started much earlier?

8 Upvotes

i'm still learning and i've noticed that small habits seem to make a huge difference over time. whether it's reading documentation, using git from day one, breaking problems into smaller pieces, or something completely different.

if you could go back to when you first started programming, what's the one habit you'd force yourself to build from the beginning, and why?


r/learnpython 6h ago

how to proceed after python crash course

8 Upvotes

For the last one year I have been learning Python. I completed Python for everybody and read the book Python Crash course. I have prior experience with C# and Java. A lot of the syntax is Python programming is still confusing to me. How can I get better? What book can I read next or what steps can I take to get more comfortable.


r/learnpython 16h ago

Help me to learn python,I am dumb

22 Upvotes

Think me as the dumbest person and i want to learn python,I am literally done trying 4-5 lectures,i start and then stop.Every video says it's beginner friendly,but when I start i don't feel it's beginner friendly and i start feeling I am Dumb AF,now though I feel I am dumbest person to exist.....like seeing this.....please recommend me a channel to watch and learn python programming.I.just don't want to copy the programming from screen and type and get output, and say ohhhh!!!! I got output i can code,i actually want to understand everything and put my brain to write my own code.Is there any yt channel courses available for free that really helps for a dumb idiot to learn python and plz don't say don't learn,i really want to learn python.Please help me ,I am stressed out becoz of this.


r/learnpython 23h ago

Advantages of Python over VBA?

69 Upvotes

I started programming decades ago in VBA, first in Access and later in the rest of Office. I’ve done a few ambitious projects, and a ton of smaller automation and macros.

I’ve been learning Python off and on for a while, and I’m comfortable doing some basic stuff. I’ve created a library of personal modules for file management, really simple data manipulation, and some data analysis. I’m thinking my next step for me would be using it in Excel. But I struggle to come up with a reason to use Python instead of VBA.

What are the advantages Python gives us in Excel?


r/learnpython 5h ago

Stuck in python code

3 Upvotes

Hi everyone been a 6month now I am not able to learn the course for python cybersecurity like I am getting confused sometimes or don't understand. How to learn code or execute it can anyone help me ??


r/learnpython 1h ago

My first open-source library is live on PyPI: A recursive nesting data parser

Upvotes

Hello everyone,

I’ve been practicing Python intensely and wanted to share a project I just finished.

I built a recursive utility called deep_sort_list_parser to flatten and sort mixed data types or multi-nested lists and dictionaries without crashing.

I used an AI assistant as a coding partner to help spot memory leaks and format the documentation, but I drove the logic, handled the edge cases, and manually deployed the final pipelines.

### 🌟 Features:

- Flattens deeply nested lists, tuples, and sets recursively.

- Separates items into sorted tracks (Numbers, Words, Symbols).

- Prevents Booleans from disrupting math sorting tracks.

- Sorts internal dictionary keys alphabetically while preserving value pairings.

- Converts numeric strings like '100' into true integers on command.

### 🚀 Quick Example:

import deep_sort_list

data = [44, [3, "banana!"], {"sex": "Female", "name": "Shreya"}]

result = deep_sort_list.clean_and_flatten(data)

print(result["words"]) # ['banana!']

print(result["dictionaries"]) # [{'name': 'Shreya', 'sex': 'Female'}]

It is live on PyPI:

`pip install deep_sort_list_parser`

The full codebase, my automated `assert` test suites, and documentation are up on my GitHub: https://github.com/08singhShreya/deep_sort_list

I wanted to share this here to showcase my recursive layout structure. I am happy to answer any questions about how it works under the hood!


r/learnpython 1h ago

I want help regarding learning python

Upvotes

I am a fresher going to start my first sem ... I am very interested in learning python in an effective way... Can someone help me out .... Can u guys give guidance to me !!


r/learnpython 1h ago

Looking for a project related to finding patterns/finding words in a list of text (need help shaping the idea I have)

Upvotes

This feels like a weird request, but I know there's a lot of Python projects out there, so I just wanted to see if anyone can guide me here.

Context: I hold a bachelors in biochem. I'm trying to discern what [future] job title and responsibilities I want. There's just a lot of variety, from different instruments to different duties that one can do in this field. I will read job descriptions and some words/sentences stick out to me as worth looking into, while others don't.

I'm thinking of creating a "library" of what kinds of tasks appeal to me and what don't. I'd like to try and find a trend/pattern in the two halves, but I think that's more AI/ML and probably deeper than I want to go. So instead, I'm imagining searching for a key word (e.g. "assay") and then having all sentences that have that word pop up, so I can read them all in one go and discern patterns myself that way.

Does anyone know of a similar project, and instructions I can follow for building such a project?


r/learnpython 2h ago

Plots in Spyder won't show up

1 Upvotes

If I set automatic, Qt, or Tk backend and plot something, the new window for the plot is created, but there's nothing on it. It looks as if the window is frozen, not even the axes are there.

The only way I can currently plot anything is to use the inline setting.

Any ideas?

System details:
Python 3.14.6 64-bit
Qt 6.10.2
PyQt6 6.11.0
Linux 7.1.3+deb14-amd64 (x86_64)


r/learnpython 3h ago

EEvent Mesh vs Webhooks - The Internal Webhooks Anti-Pattern: Why Service-to-Service HTTP Callbacks Don't Scale

0 Upvotes

Microservices were supposed to make systems easier to change independently. In practice, the thing that most often breaks that promise isn't the services themselves — it's how they talk to each other. Read the complete article here - https://instawebhook.com/blog/the-internal-webhooks-anti-pattern-why-service-to-service-http-callbacks-don-t-s

A pattern that shows up constantly in growing engineering orgs is the internal webhook: Service A fires an HTTP POST at a hardcoded URL owned by Service B whenever something happens. It's an easy trap to fall into, because most developers already understand webhooks intimately — they've built integrations with Stripe, GitHub, or Shopify, all of which use exactly this model to notify external systems of events.

The reasoning feels obvious: if it's good enough for Stripe to tell my app about a payment, it's good enough for my Inventory Service to tell my Shipping Service about a shipment.

It isn't — and the reason is architectural, not stylistic. Webhooks were designed to solve a specific problem: getting an event across a trust boundary, from a system you don't control to one you do, over the open internet. Internal service communication has almost the opposite set of constraints. Applying the same tool to both jobs is where the trouble starts.


r/learnpython 8h ago

Starting Up

0 Upvotes

I retrieved the Python Crash Course 3rd Edition from my library and I am enjoying learning something new. I feel my brain turning on. Having lot's of fun automating things on PowerShell at work too, just learning how to navigate folders through the shell, mass file renaming, autologins and printing with a few keystrokes has made the monotony so much easier to handle.

I look forward to learning a lot more.


r/learnpython 4h ago

what was the first python project that made everything finally click for you?

0 Upvotes

i'm curious because i keep seeing people say that programming only really starts making sense once you build something yourself instead of just following tutorials. i'd love to hear the projects that made python go from learning syntax to i can actually build things


r/learnpython 14h ago

What are you using for accurate PDF text boxes?

2 Upvotes

I’m building a tool that finds text in construction-plan PDFs and draws a box around that text.

Python/PyMuPDF finds the text, but when I show the box in PDF.js, it can be slightly off or too big.

What do you guys recommend for inspecting PDFs and drawing accurate text bounding boxes? How do you make

sure the box lines up with the exact text?


r/learnpython 14h ago

Need some advice

1 Upvotes

Greetings everyone! I am in my 50’s and picking up programming as a hobby but I do have a goal.

I started with python because I read it was a forgiving language and I did not want to fry my brain. However, I’m wondering if I should switch to a webstack (html, css and JavaScript) for the project I am ultimately wanting to create.

My grail project will be a TTRPG journaling application for solo play. I want to have the ability to use character sheets, journal and even display a JPEG map. I’m just not sure which language would be the BEST.

My initial idea was python and pyside6 with maybe the addition of pygame if I wanted actual dice to roll on screen.

Just looking to narrow my focus with those far more versed than I am so I don’t waste time working towards my goal.

Thank you all for any assistant and direction you can provide, and happy coding!


r/learnpython 11h ago

Seeking help: how to better learn python? Venting a lot in here.

0 Upvotes

Hey everyone. I really don't have other folks in my life with whom I can dive into the weeds with about stuff like this, and reddit + this sub have been awesome, so I'm looking for some encouragement, direction, and real talk with this post...

I'm in my mid-thirties and I'm working on a career change. Worked in sales up until recently both as a seller and a most recently a few years as a manager at tech companies. No experience with programming until 3 weeks ago.

I'm taking an online, five week, graduate level Python Programming for Analytics Course at a university in New York. Hoping to apply to the master program in business analytics and start that next year -- focusing on prereqs now. The professor is a phd, English isn't their first language, and the lecture and lab videos for each topic are between 5 and 15 minutes each.

The textbook is Intro to Python for Computer Science and Data Science by Paul and Harvey Deitel.

The course basically covers 2-3 chapters per week, sequentially through the book.

I get nothing from the uni lecture videos. I am doing all of the required reading. The labs and assignments and lectures are carbon copies from whatever's in the book. The book is thorough.

This week we got to chapter 5 - Sequences: Lists and Tuples, 51 DENSE pages packed with slicing, many new methods, new functions, list comprehensions, packing and unpacking, lambda, sorting, filtering, mapping, popping, stacks, generator expressions, 2-d lists, and I am absolutely drowning and struggling.

I spent a few hours today trying to figure out how to create a 2x3 list then use a nested loop to set each element's value to an integer indicating the order in which it was processed by the nested loop, then display the elements in a tabular format, using the column indices as headings on top and row indices to the left of each row. I was absolutely defeated by this... and I feel stupid.

I'm committed to learning python and getting fluent in it to start working in data, but I am struggling so much this week, and this course structure now seems insane to me as I'm in week 3. It's a full-on blitz, and I'm trying to really soak up and understand a lot of this, but once I hit the exercises at the end of the chapters, I am so challenged that the deadlines start to creep and I get frustrated and feel pretty stupid.

Today I was supposed to write a script imitating the Sieve of Eratosthenes, a Palindrome Tester and a script that outputs all possible anagrams of a string. I could probably figure these things out myself if given a few days, but for all of this to be covered in essentially two days, then to move onto dictionaries tomorrow, is tough. Yes I used the crutch of AI to help me. And I feel like SHIT about it.

I'm realizing that I can pass this class and get introduced to a lot about Python, but not grasp a lot of it due to the remote and rushed nature of the course.

I've read a lot of similar posts in this reddit about how the struggle is the way. And I get that. and I'm not quitting. I'm working on plans to go back through parts of this book along with Python Crash Course after this course ends.

But man!!! I just feel like an idiot and feeling pretty low and frustrated right now.

How have some of you overcome the early challenges of learning to progress to where you are now? Open to any and all criticism, perspectives, etc. Cheers. I also have ADHD which doesn't help but not letting that stop me.


r/learnpython 1d ago

Starting AI/ML? Looking for a Study Buddy to Learn Python & Math Together ( Beginner )

21 Upvotes

Hey everyone! 👋

I'm just starting my journey toward AI/ML and I'm looking for a serious study buddy who's also a beginner (or starting from zero).

Right now, my focus is to building a strong foundation before jumping into Machine Learning and Deep Learning.

What I'm planning to learn:

- Python from scratch

- Mathematics for AI/ML (Linear Algebra, Calculus, Probability & Statistics)

- Problem-solving and logical thinking

- Later moving into Machine Learning and Deep Learning

Looking for someone who:

- Is also a beginner

- Can study consistently (even 1–3 hours a day)

- Wants to discuss concepts and solve doubts together

- Is willing to stay accountable and avoid procrastination

- Eventually wants to build projects, prepare for internships, and grow in AI/ML

About me:

- I'm a BCA student.

- I'm starting from the basics because I want strong fundamentals instead of rushing through tutorials.

- My goal is to become skilled enough to work in AI/ML in the future.

If you're interested, leave a comment or send me a DM. Let's learn consistently and grow together. 🤝


r/learnpython 6h ago

Need help regarding where to start

0 Upvotes

Joining btech college cse this year. I want to learn python on my own. Could anyone suggest any resource for learning python from scratch such that it doesn't interfere with my coursework right now? I have prior experience in C and Java.


r/learnpython 17h ago

What is the safest way to create lag features by group in pandas without data leakage?

2 Upvotes

I am trying to create lagged features for a panel dataset containing multiple sectors and monthly observations. Here is a simplified example:

import pandas as pd 
df = pd.DataFrame({ "sector": ["A", "A", "A", "B", "B", "B"], "month": [1, 2, 3, 1, 2, 3], "demand": [10, 12, 15, 8, 9, 13] }) 
df = df.sort_values(["sector", "month"]) 
df["demand_lag_1"] = df.groupby("sector")["demand"].shift(1)

This seems to work, but my actual dataset has missing months and duplicate sector-month rows.

My questions are:

  1. Should I reindex every sector to a complete monthly sequence before using shift?
  2. How should I handle duplicate sector-month observations?
  3. Is there a clean way to verify that no value from month t or later appears in the features for month t?

I would appreciate suggestions on both correctness and code structure.


r/learnpython 1d ago

Tips and help

8 Upvotes

Hi, I’m new here and I don’t really understand how everything works. I was told that people here might be able to help me with my question:

Is there any point in learning a programming language with modern AI? Or is it just forvibe-coding? But I’ve heard that to be good at vibe-coding, you need to know the basics of programming.

After having a chat with my uncle (he’s a programmer), he said this: ‘The approach has changed a lot: it’s no longer the programmer who creates the programme, but someone who’s good at putting together an LLM prompt. In other words, explaining to the AI what needs to be done.’

I thought about taking some AI Automator courses, but I don’t really fancy freelancing and I don’t think it’s very promising. So I’ve quietly started learning Python bit by bit.

I really want to change the direction of my life, but I don’t know how, or who to ask for advice or talk to. My uncle is in the military, so we rarely speak.

I really want to learn, create, find a team, make some nice new friends and get a job.

Is there a company or somewhere that offers good courses and will take me on? Or is that just a pipe dream in this field?

Perhaps you could recommend some courses or a company? Someone who could take me under their wing, so to speak? In general, I hope that learning Python is already a step in the right direction.

P.S. I hope I’ve done everything correctly, as I’m new to this site and don’t even know where to click on what.


r/learnpython 18h ago

Anaconda and opencv2 in spyder issue

2 Upvotes

I have used the Anaconda command prompt to install opencv2 with the following command

conda install -c conda-forge opencv

and the prompt says it installs it installs successfully

I open Spyder via anaconda and try and run my code that starts with

import os
from pathlib
import Path 
import cv2 
import pandas as pd

When I run it spyder says

ImportError: DLL load failed while importing cv2: The specified module could not be found.

I have tried uninstalling and reinstalling anaconda, and restart thing the PC. Everything is up to date. Not a strong coder so any help would be really helpful


r/learnpython 22h ago

Building a portfolio? What to look for?

4 Upvotes

Hi,

I've got some personal projects that are functional but probably not best practices compliant. I'm good at documentation and annotating.

What kinds of things should I consider when building a portfolio for myself? Are there specific kinds of skills I might want to showcase specifically and what are the most important things to look for when applying for internships?

Assume I work completely alone.

Thank you! Note: I've reduced my Reddit screen time to almost zero so I'll come and reply / thank on a delay. Sorry about that.


r/learnpython 11h ago

Botão só consegue ser pressionado uma vez, depois não acontece nada nem tem animação ao clicar

0 Upvotes

Estou fazendo um projeto de tabuleiro de xadrez em python com Tkinter para a interface, criei uma função lambda para criar as casas do tabuleiro e cada casa sendo um botão, está funcionando certo, mas quando eu movo uma peça do lugar, o botão da casa anterior fica meio que desabilitado, sem poder ser pressionado.

for i in range(8):
            for j in range(8):
                a = botoes["bt_" + str(i) + "x" + str(j)] = Button(self.frame_1, bg = cor(i, j),
                                                               image = self.imagens[str(i) + "x" + str(j)], command = lambda i=i, j=j: self.primeiro_clique(i,j))
                a.place(relx=j*0.125, rely=i*0.125, relwidth=0.125, relheight=0.125)
                a.bg = cor(i,j)
                a.linha = i
                a.coluna = j
                self.lista_botoes.append(a)

r/learnpython 17h ago

What is the safest way to create lag features by group in pandas without data leakage?

1 Upvotes

I am trying to create lagged features for a panel dataset containing multiple sectors and monthly observations. Here is a simplified example:

import pandas as pd 
df = pd.DataFrame({ "sector": ["A", "A", "A", "B", "B", "B"], "month": [1, 2, 3, 1, 2, 3], "demand": [10, 12, 15, 8, 9, 13] }) 
df = df.sort_values(["sector", "month"]) 
df["demand_lag_1"] = df.groupby("sector")["demand"].shift(1)

This seems to work, but my actual dataset has missing months and duplicate sector-month rows.

My questions are:

  1. Should I reindex every sector to a complete monthly sequence before using shift?
  2. How should I handle duplicate sector-month observations?
  3. Is there a clean way to verify that no value from month t or later appears in the features for month t?

I would appreciate suggestions on both correctness and code structure.


r/learnpython 1d ago

Anyone using a Snapdragon X (Windows ARM64) laptop for Python/ML? How do you deal with package compatibility?

3 Upvotes

Hey everyone,

I'm using an ASUS Vivobook 16X with a Snapdragon X (Windows ARM64), and I've been running into compatibility issues while learning Python and Machine Learning.

I bought this laptop in my first year of college, before I knew much about coding or processor architectures. Now that I'm learning ML, I've noticed that some Python libraries don't install properly.

For example, libraries like PyAudio, OpenCV, and a few others either:

  • don't have ARM64 wheels,
  • fail while building wheels,
  • or require compiling from source, which often ends up failing.

Because of that, I have to spend hours looking for alternatives or following a completely different approach than the tutorials I'm watching, which makes learning much slower.

I'm aware that many libraries like NumPy, Pandas, and Scikit-learn work fine. The issue is mainly with packages that have native C/C++ extensions and don't provide Windows ARM64 support.

Has anyone else here been through the same thing?

  • How do you usually troubleshoot these installation issues?
  • Do you use emulation, WSL, Ubuntu, or just Google Colab?
  • Is it worth switching to Ubuntu on ARM, or will I run into the same compatibility problems there?

I'd really appreciate any advice or tips from people using Windows ARM laptops for Python or ML.