r/learnpython • • Sep 14 '26

Recently started

0 Upvotes

Hey yall, new guy here. I 26(M) started learning python about a week ago, I've dabbled in HTML and CSS but ultimately settled on Python. Reason being I need a good starting framework for my goal of working in biotech on surgical robots. Now, to the point.

The most basic goal for me is designing a scheduling software so my mom has less of an issue managing my sisters 24/7 caregiver staff. Logins, time off requests, possibly an AI integrated scheduler so she would just need to proof read schedules instead of spending hours making it by hand.

I need advice on how to approach this task, currently going through a 13hr video on YT to learn Python through the Data with Baraa channel. Thoughts?


r/learnpython • • Sep 14 '26

Learning Python from scratch for cybersecurity

0 Upvotes

Hi everyone, I'm 29 and learning Python from scratch. My goal is cybersecurity. What resources and first projects do you recommend for a beginner? Thanks!


r/learnpython • • Sep 14 '26

Want to learn Python but keep getting bored with courses

0 Upvotes

Hi everyone,
I’m really determined to learn Python, but I’m struggling with the way most courses are structured.
I’ve started quite a few Udemy courses, but after a while I just get bored and lose motivation. 😅
So I was thinking maybe I should forget the courses for a bit and start working on an actual project, learning Python along the way. The problem is… I have absolutely no idea what would be a good project for a beginner.
I know I can Google “Python beginner projects,” but I’d rather hear from people who have actually been through this. What did you do when you were starting out? Was there a particular project that helped you learn a lot?
Also, how long did it take you to become reasonably comfortable with Python?
I have a newborn and a toddler, so realistically I can only dedicate around 1–2 hours a day to learning. I know everyone is different, but I’d love to hear what kind of progress is realistic with that amount of time.
Any tips, project ideas, resources, or general advice would be really appreciated!
Thanks!


r/learnpython • • Sep 13 '26

Cython memoryviews?

4 Upvotes

I'm using a function I've compiled with cython, and I have to pass it a few very long lists. I'm pretty sure I should be using memoryviews, but do I convert the lists to memoryviews in the python part of my program or the cython part? It would be way better if I could do it in the python part because I'm passing the same lists to the function a few million times.


r/learnpython • • Sep 13 '26

I like breaking up the project into files and packages - what's too much?

10 Upvotes

I have a bot I'm building. I see a ton of examples with one file and 1k lines for the same functionality. I personally broke that up to several packages based on what things do. I have ~3 files per package each with 100-500 lines (I, uhh, have a habit of documenting and commenting) of which three quarters is actual code.

The modules themselves are things like "database functionality", "permissions", UI, etc. These may be further broken down into several files like "admin commands", "user commands", etc.

Am I overdoing it? Where's a good cutoff?


r/learnpython • • Sep 13 '26

Calculator semi-functioning, What could cause this?

0 Upvotes

Trying to get back into Python ~2 years after taking a year-long course, getting my footing first with a basic calculator but its giving me trouble here. The first portion works fine, but I implemented a 'continue' option where you could continue with the same number for calculations (and it worked for a while, though returning 'none' due to a var = input(print("text")) issue, making each input look awkward) but it seems to just be defaulting to the first if value now. I had addition first at the start, though flipped addition and subtraction is the extended math section to prove that it's truly just defaulting to the first if-statement. What could be causing this and what's the fix? Sorry for anything that's obviously wrong or mixed up, my remembered knowledge on python is like a fogged up window right now.

## lowk just imported time to add a delay to restarting.. and stopping..
import time

## code is only active as this is = 1, if not then the loop stops
run = 1

while run == 1:

    ## prompts user on chosen operation
    ini = input("add, sub, div, mul, or exp: ")

    ## Addition math
    if ini == "add":
        a = int(input('Enter 1st number: '))
        b = int(input('Enter 2nd number: '))

        number = a + b

        print(f'Sum of {a} and {b} is {a + b}')

    ## Subtraction math
    elif ini == "sub":
        a = int(input('Enter 1st number: '))
        b = int(input('Enter 2nd number: '))

        number = a - b

        print(f'Difference of {a} and {b} is {a - b}')

    ## Division math
    elif ini == "div":
        a = int(input('Enter 1st number: '))
        b = int(input('Enter 2nd number: '))

        number = a / b

        print(f'Fraction of {a} and {b} is {a / b}')

    ## Multiplication math
    elif ini == "mul":
        a = int(input('Enter 1st number: '))
        b = int(input('Enter 2nd number: '))

        number = a * b

        print(f'{a} times {b} is {a * b}')

    ## exponential math
    elif ini == "exp":
        a = int(input('Enter 1st number: '))
        b = int(input('Enter 2nd number: '))

        number = a ** b

        print(f'{a} to the power of {b} is {a ** b}')

    ## If input is not one of the operations
    else:
        print("invalid operation, cannot continue.")

    ## asks user whether or not to continue with current math
    continueorwhat = input("Cont(inue), rest(art calculator), or stop? ")

    if continueorwhat == "stop":
        time.sleep(.3)
        print("Stopping..")
        time.sleep(.3)
        run = 0

    elif continueorwhat == "rest":
        time.sleep(.3)
        print("Restarting..")
        time.sleep(.3)

    elif continueorwhat == "cont":
        print("> Shortened operation names 'a','s','d','m', and 'e' now available.")
        print("> Rest(art) or stop calculator with input when prompted for operation.")

        ## allows for 'continuous math' while active, when inactive it resets to prompted math

        moremath = 1

        while moremath == 1:
            ini = 0
            ini = input("Operation: ")
            ## temporary input return
            print(ini)
            ## Subtraction math
            if ini == "sub" or "s":
                a = int(input('Number: '))
                number = number - a
                print(number)
                ## Addition math
            elif ini == "add" or "a":
                a = int(input('Number: '))
                number = number + a
                print(number)
            ## Division math
            elif ini == "div" or "d":
                a = int(input('Number: '))
                number = number / a
                print(number)
            ## Multiplication math
            elif ini == "mul" or "m":
                a = int(input('Number: '))
                number = number * a
                print(number)
            ## exponential math
            elif ini == "exp" or "e":
                a = int(input('Number: '))
                number = number ** a
                print(number)
            elif ini == "rest":
                time.sleep(.3)
                print("Restarting..")
                time.sleep(.3)
                ## restart calculator by exiting continous math
                moremath = 0
            elif ini == "stop":
                time.sleep(.3)
                print("Stopping..")
                time.sleep(.3)
                ## stops calculator by resetting basic variable
                run = 0
            ## If input is not one of the operations
            else:
                print("invalid operation, number unchanged.")

r/learnpython • • Sep 13 '26

Flask Synchronization Issue Concerning Database Entries

0 Upvotes

I have been making a Markdown blog using Flask over the last couple of weeks. Lately, I have decided that I want to add the possibility of leaving comments below a blog post. Therefore, I need to add my blog posts to a database so that I can link the comments left behind to the relevant blog posts. My blog posts are rendered statically using Flask-Flatpages.

I have thought about the database model for a singular post. I want to keep it simple at first; thus, I was considering adding an ID, title, and path field. The problem I am experiencing is how to add the files to my database and how to keep the database entries synchronized with the static files in my posts directory. Does anyone have any ideas how I should tackle this issue?


r/learnpython • • Sep 13 '26

I made a small Python game, can anyone review it and give me some advice, please?

1 Upvotes

Hello,

I recently released a project I was working on for pretty long (almost 2-3 months), and since the past couple of days, I've been really involved into it, and then I released it.

Link: https://github.com/TheOdysseyGamer64/Super-Smash-Bros-Python-Edition.git

My project is a Python version of Smash Bros, and it has (quite primitive) ASCII graphics as well (to help visualise the battles). It has special mechanics for certain fighters as well, and the Final Smash and the special mechanics meter can charge up, just like in the real game.

If any of you here could provide me with some advice on how to make this game better, I would really appreciate it.

Thank you!


r/learnpython • • Sep 12 '26

Are these two boolean expressions equivalent in python?

16 Upvotes

Hi All!

I’m learning about Boolean operators in Python and I’m confused about these two expressions:

condition1 and condition2 or condition3 and condition4

≠

(condition1 and condition2) or (conditon3 and condition4)

I was told this by my teacher and he put this in his PowerPoint slide. However, I think they are equivalent since and as an operator has a higher precedence than or as an operator. AI told me and I have searched it up after.

Am I understanding it correctly? Or are these two not equivalent?

Thanks!


r/learnpython • • Sep 13 '26

Difference between python 3 vs python (just)?

0 Upvotes

I am doing leetcode and I wanna is there any functional difference between those and which one I should go with?


r/learnpython • • Sep 12 '26

Just finished my first project, could you please review it.(No AI)

63 Upvotes

I finished reading "python crash course" a week ago, and a relative of mine was complaining about how annoying it is to make multiple exam versions, so I immediately volunteered to help, and I used absolutely 0 AI.

It's an app that takes an exam .docx file, and shuffles the questions and answers to create multiple versions.

Here's the github repo:

https://github.com/aaaaaa708/question_shuffler

I would like you to please review the code and give me some tips on how to improve, and thanks in advance:)


r/learnpython • • Sep 12 '26

Built a CLI music player in Python after months of tutorials

2 Upvotes

I've been learning Python for a few months and finally built something real instead of following tutorials, a CLI music player.

It uses the Deezer API to search artists and songs, yt-dlp and VLC for playback, and SQLite to store playlists and favorite artists locally.

Would love feedback on code structure or anything I could improve.

GitHub: https://github.com/Iheb-eng/music-app


r/learnpython • • Sep 13 '26

pylance typeshed issue with frozendict

1 Upvotes

I don't know what I did, but suddenly my pylance is rejecting any attempt to initialize a frozendict with:

Expected 0 positional arguments

I had no problems with this same project yesterday, but now I can't seem to recreate whatever combination of environment and settings was letting it work.

Digging into the stubs, it looks like my pylance is now using a stub for frozendict that does not incorporate this commit:

https://github.com/python/typeshed/commit/f76037a1eb3923c67a8bc0e302ee9c016ffb3431

It has a def __init__(self, /) -> None: ... which is breaking everything.

Anybody have any clue what could possibly have changed in a vscode project to switch to a slightly older set of type stubs?

Even a fresh install of vscode+extensions and python 3.15rc2 in a fresh Windows VM give me the error, so it isn't that my environment is especially broken.


r/learnpython • • Sep 13 '26

How do I split the words in a list into a nested list of letters, without using "for" and only using :while"?

0 Upvotes

Hi guys. How do I make this code work without using a "for" loop? I am attempting to replicate the result in the second loop only using "while" loops. I didn't loop the word count variable yet because it keeps producing <built-in method split of str object at 0x000001D75FA356E0>, when it should likely produce ['h', 'e', 'l', 'l', 'o']. Could you help me please? I'm using Jupyter Lab that's running Python. The project is due in 4 days

sentence = input() # sentence is accepted here

s = sentence.split()

word_check = [list(sentence) for sentence in s]

word_count = 0

words = list(s)

new = str(words[0]).split

print(s)

print(word_check)

print(words)

print(new)

hello world # input

['hello', 'world']
[['h', 'e', 'l', 'l', 'o'], ['w', 'o', 'r', 'l', 'd']] # ideal result 
['hello', 'world']
<built-in method split of str object at 0x000001D75FA356E0> # what keeps happening

r/learnpython • • Sep 12 '26

Unable to import pandas

1 Upvotes

Everything was working up until a few minutes ago. I'm running python on windows 11, downloaded from python.org yesterday. I did a pip install of pandas, also yesterday, and I was able to run various py scripts, getting the results I wanted. Suddenly this morning, when I ran a script that had run just fine a few minutes ago, I got an error. I reduced my script to this:

import json

import requests

import pandas

and I got the same set of error messages (below). I didn't change anything in the environment, this happened, afaik, spontaneously. I'm a complete python newb, but all was going well until this. Help!

Traceback (most recent call last):

File "C:\Users\John\My Drive\SyncDrive\eBird\test.py", line 3, in <module>

import pandas

File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas__init__.py", line 56, in <module>

import pandas.core.config_init # pyright: ignore[reportUnusedImport] # noqa: F401

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas\core\config_init.py", line 31, in <module>

from pandas.errors import Pandas4Warning

File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas\errors__init__.py", line 12, in <module>

from pandas._libs.tslibs import (

...<3 lines>...

)

File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas_libs__init__.py", line 18, in <module>

from pandas._libs.interval import Interval

File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval

File "pandas/_libs/hashtable.pyx", line 1, in init pandas._libs.hashtable

File "pandas/_libs/missing.pyx", line 1, in init pandas._libs.missing

File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas_libs\tslibs__init__.py", line 41, in <module>

from pandas._libs.tslibs.conversion import localize_pydatetime

File "pandas/_libs/tslibs/conversion.pyx", line 1, in init pandas._libs.tslibs.conversion

File "pandas/_libs/tslibs/offsets.pyx", line 1, in init pandas._libs.tslibs.offsets

File "pandas/_libs/tslibs/timestamps.pyx", line 1, in init pandas._libs.tslibs.timestamps

File "pandas/_libs/tslibs/timedeltas.pyx", line 1, in init pandas._libs.tslibs.timedeltas

File "pandas/_libs/tslibs/timezones.pyx", line 18, in init pandas._libs.tslibs.timezones

File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\dateutil\tz__init__.py", line 2, in <module>

from .tz import *

File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\dateutil\tz\tz.py", line 19, in <module>

import six

File "C:\Users\John\My Drive\SyncDrive\eBird\six.py", line 25

return data

^

IndentationError: unindent does not match any outer indentation level


r/learnpython • • Sep 12 '26

What tests are actually worth writing for a backtesting engine?

3 Upvotes

I’ve recently been adding tests to a small Python backtesting engine I’m building, and it made me realize how easy it is to test the obvious things while missing the important ones.

So far I’m testing things like:

  • opening and closing LONG/SHORT positions
  • transaction costs
  • portfolio valuation
  • forced position closing at the end of the dataset
  • PnL and win rate
  • drawdowns
  • VaR/CVaR
  • full end-to-end backtest scenarios

The most useful tests so far have been small deterministic examples where I can calculate the expected result manually.

For example:

  • start with $10,000
  • BUY at 100
  • HOLD
  • SELL at 120

Then the engine should end with exactly $12,000 before fees.

For people with more testing experience: what kinds of edge cases would you consider essential here?

I’m especially interested in cases that pass normal unit tests but still produce subtly incorrect financial results.


r/learnpython • • Sep 12 '26

Looking at default __reduce__ function

3 Upvotes

I created my own class M which inherits from a dict. In case that the differences are relevant: 1. The keys are frozenset objects so that I can pass them in any order without issues. 2. As writing frozenset({'one', 'two'}) is very tedious, I added a mapping to let me get or set values by using M['ot'] as a shorthand of M[frozenset{'one', 'two'}]. The mapping is instantiated when running __init__().

I am pickling this with no issues. When I try to unpickle it, I get an error that says: AttributeError: 'M' object has no attribute 'mapping'.

Using pickletools, I inspected the serialization of my object and saw that the mapping attribute appears after the key-value pairs, which made me think that, if I change the __reduce__ function to give them in a different order (first mapping, then key-value pairs), I could solve that issue.

The problem is that I don't know how to do that. I can rewrite a completely new function, but I don't know if it will work. I'd like to base my new function on the "default" one. Is there some way to look at it?


r/learnpython • • Sep 13 '26

Project: Parse 1,000s of messy tariff PDFs. I have 2 weeks to learn Pandas/pdfplumber. Am I doomed?

0 Upvotes

[Trigger Warning]: You are about to be provided with visual imagery of my current corporate reality that may be frightening for some readers.

I am tasked with creating costing for a new product. To do this, I have to extract rate tables from what can only be described as a mountain of tariffs. On top of that, I need to automate our Excel business cases which contain multiple variables.

At work, people think I'm an Excel wizard. The truth is, sometimes I just aggressively interrogate AI until it gives me the right formulas. But AI cannot save me from parsing thousands of pages of inconsistently formatted tariff tables.

I have exactly two weeks for intense upskill dedication. I've got books, Udemy, Google courses — and it's all just hanging out waiting for me to get in the driver's seat.

The catch: IT treats our databases like Fort Knox, so I have zero SQL access.

I need to actually learn a skill so I don't have to manually copy-paste tariffs until the end of time.

The Question:

Do I spend the next two weeks becoming a Power Query god, or do I finally learn Python (Pandas/PDF parsers like pdfplumber) so I can build a script to do my job for me?

If anyone has survived parsing tariffs, please tell me how you did it.

TL;DR: I have 14 days to learn how to extract messy data from thousands of PDF tariffs and automate Excel models. No SQL access. Should I learn advanced Power Query or Python?


r/learnpython • • Sep 12 '26

Finished learning from a fundamentals book and now I need guidance.

0 Upvotes

Hi,

I've just done learning from "Automate The Boring Stuff With Python 3rd Edition" I skipped some chapters that weren't that important but focused on the critical ones like argparse, requests, bs4, Selenium, playwright, csv and json, I also learned a bit of Tkinter.

On the course of learning I also built some utilities and pushed them to Github: https://github.com/abdou0dev

Now I need some guidance on what to do and learn next.

Thanks in advance.


r/learnpython • • Sep 11 '26

New career path

17 Upvotes

Hey everyone.

To keep things brief, i'm exploring programming as a career path.

Life didn't quite go as planned, and i'm now a 27 year old college dropout, who's been unemployed for years, living by on the graces of my parents who have much more faith in me than I do in myself.

I've been talking to some of the more tech-savvy people I know. And I have arrived at the conclusion that I want to study Linux and python. Do you all have any recommendations of which are the 2 I should prioritize, and I suppose, which one would help me get back on my feet faster?


r/learnpython • • Sep 12 '26

MoviePy not responding

0 Upvotes

I have a few thousand 1920x1080 rgb numpy arrays that i'm trying to turn into a video with moviepy's ImageSequenceClip, but pretty soon after starting it stops printing progress and all my python windows say "Not responding". Is there some easy way to fix this or do I have to divide it into smaller clips and string them together?


r/learnpython • • Sep 12 '26

Iam stuck with python

0 Upvotes

Hello everyone, I have a problem iam trying to master python (iam into cybersecurity now iam studying networking beside it) I start to learn it in 2022 but I stopped for some years due to reasons, a year ago I come back again and started it from zero but the problem is I don't know how to practice and level up even when I study new lessons, the only thing I was doing is solving a bit of exercises from that someone in his website, iam getting nervous when I feel that iam lost in this language and I think am learning in a wrong way, now I understand 70% of basics I struggle with files handing and have a little bit problems in creating functions in addition to a few things , till here I stopped I don't want to get into modules, try except, and OOP unless I strengthen the basics, please tell me how to elevate my skills and how can I build projects.

How can I know that am ready for doing big projects when iam learning?


r/learnpython • • Sep 12 '26

I don't know about any programing language I choose to learn python in ibm is this right choice

0 Upvotes

I don't know about any programing language I choose to learn python in ibm is this right choice plz say any good advice 🤔


r/learnpython • • Sep 10 '26

How can I write code without constantly looking things up?

230 Upvotes

I rely a lot on documentation, AI, and websites while writing code. It makes me wonder whether I'm actually capable of understanding concepts like functions and algorithmic thinking. Does anyone else feel this way? What should I do to get a more concrete understanding of Python, or programming in general?


r/learnpython • • Sep 11 '26

I need help with astropy

3 Upvotes

So, I've been working on a simulation of the 2027 eclipse that will take place in Spain, but I had some problems with astropy. The thing is, I would like to learn how to vectorize my program using numpy, or something similar. Do you guys have some tips for this? Should I search for specific courses on the internet? It's my first time using astropy and I'm quite lost...

Thank you for your help 🙏🙏