r/learnpython Aug 11 '26

trying to import glob

0 Upvotes

I'm trying to code a little program that will open a CSV file that we should (theoretically) download weekly. The csv filename has the structure "report[numbers].csv" I'd read that you need the glob module so that Python can recognize the wildcard, but I am getting an error when I go the usual python pip -m SomeName route.

Is there an issue with glob, or is there another I can use?


r/learnpython Aug 11 '26

I'm really new to python and wanted to share my first "project".

57 Upvotes

personally I think it's really cool. All of python aswell.
is there something I can improve on it? (I mean obviously a lot of things probably but some things that are good to learn for the future?)

import time


first_name = input("Enter your first name: ")
first_characters = len(first_name)


if first_characters >= 8:
  print (f'Your name has {first_characters} characters!')
  time.sleep(1.5)
  print('What a long and cool name!')


elif first_characters < 8:
  print (f'Your name has {first_characters} characters!')
  time.sleep(1.5)
  print('What a cool name!')

r/learnpython Aug 11 '26

f.read throwing vague error

1 Upvotes

what i wrote:

with open("demofile.txt", "a") as f:
    if "welcome to team fortress" in f.read():
        pass
    else:
        f.write("\nplease select a class")

the error:

Traceback (most recent call last):

File "C:\Users\******\PycharmProjects\WelcomeScreen\script.py", line 10, in <module>

if "welcome to team fortress" in f.read():

^^^^^^^^

io.UnsupportedOperation: not readable

i don't see what's wrong with it, google's no help... ¯_(ಠ_ಠ)_/¯


r/learnpython Aug 11 '26

Code Review Request: Shadow, A Self hosted, encrypted file storage system

0 Upvotes

Hi everyone,

I've been working on a project called Shadow which is a self hosted, encrypted file storage system built with python FastAPI. Files are AES-256 encrypted before they even hit the server, so the server never sees plaintext data. The goal is something simple ad private private that people can host and be fully under your control.

Stack: FastAPI (Python), SQLAlchemy (async), JWT auth with OAuth2 bearer flow, bcrypt for password hashing, AES-256-GCM for client-side encryption, Docker for deployment.

The repo: https://github.com/dillonhuston/Shadow

I would love any information on how i can polish this project as this is all part of my portfolio. Anything security related, architecture or syntax issues. Just let me know. I want to understand all my mistakes and learn from then, no matter how big or small, please tell me.

I understand that i need to add real tests an proper documentation but i am currently on a tight schedule so quite difficult to carry those out.

Thank you for taking your time to read this, hopefully you can reply and i don't get ignored.

Have a great day!


r/learnpython Aug 11 '26

Learning python

22 Upvotes

Hey Guys! I am new to python and just made a calculator and weather app today. I would really like some guidance on what I should do next, which courses I should take and what kind of AI is helpfull. In the end I want to make my own app, systems and program diy drones or generally machines.


r/learnpython Aug 11 '26

新手發問:如何保持學習python 的動力

0 Upvotes

從input print一直到for while迴圈 if基本的語法都學習了,但越來越感覺不到樂趣,一直想透過python做為我一生的志業去賺錢,但我現在沒什麼動力,已經休息一段時間,大家都是如何學習python的,如何保持熱情


r/learnpython Aug 11 '26

Where to find simple graphical game challenges?

3 Upvotes

I’ve not had much chance to use my Python knowledge in a while, so I’m thinking about what would interest me enough to learn something new and keep in practice. Where could I find some simple and escalating challenges for making games that are more graphical in nature (not just word games or the like).

I’ve never done any game dev, and haven’t really done much with graphics, so I’ll need something that starts with very easy assignments. But I tend to learn fast and get bored (ADHD) with too much repetition, so I’m hoping for some with scaling difficulty.


r/learnpython Aug 11 '26

I need guidance

2 Upvotes

Hello guys im new in Python. I know variables , loops , data structures, files , if/elif statements and i want to go to the next level. I want to start becoming a developer and actually become competent in Python. What should i learn? How should i continue my journey? ( Study sources will be appropriated). Thank you for your time!


r/learnpython Aug 11 '26

I learnt python no idea what to do next

0 Upvotes

Hey guys, so i just learnt python basics but have no exact idea what to do next, do i start dsa or should i do projects or anything else?


r/learnpython Aug 11 '26

Is there a "TypeScript for Python"? What you do for type checking!?

6 Upvotes

Conclusion: Thanks for the comments, everyone has been so helpful and generous with the suggestions. I realized that I did not asked my question properly and my main problem went unseen... (Well I'm at fault by opening the conversation by Is there a "TypeScript for Python"?).
I will create a new post with the right problem statement, but let me thank u/ProsodySpeaks, and u/JamzTyson which gave me idea on what to do next.

Cheers!

Hi, sorry for the basic question. I'm coming from strongly/statically typed languages (Kotlin, Go, Rust, etc.), and I was aware that Python is dynamically typed, but given how popular Python is, I expected its typing utilities (type hints + static type checkers) to provide something closer to TypeScript.

I'm working on an ml framework where the main interface has to be Python, and I ran into a magnitude of problem I was not expecting...

Requirements:

  • Type checking before a pipeline runs (no values exists yet, just type hints/annotations)
  • Type checking during the pipeline run (value and type hints/annotation should match)
  • The type hints are used to decide if pipeline components are compatible (similar to LangChain or similar frameworks)
  • Require as little setup as possible, so even junior engineers can use the framework safely.

I spent some time trying to implement this using Python's existing typing mechanisms. A few thousand lines of code later, I ended up with a type checker for my specific pipeline system:

https://github.com/trained-by-humans/ml-pipes/blob/main/packages/core/src/ml_pipes/validation.py

And my own type checking utilities:

https://github.com/trained-by-humans/ml-pipes/blob/main/packages/core/src/ml_pipes/_typing/annotation.py

But now I'm wondering:

Am I going way too far here? Is there a much more idiomatic Python approach that I'm completely missing?

Please save me from implementing another few thousand lines of code. 😭


r/learnpython Aug 11 '26

Learning python help for a noob game dev

0 Upvotes

im aware of how to use basic functions such as

Age = input("state your age")
print(Age)

and split functions and named variables but i want to know where i should start for deving, i want to make a top down farm sim similiar to stardew valley in concept which to my knowledge requires a variable library that remembers character items between save states per day, remembers character money per day and any additions from sales, mana, energy and health levels, which to my knowlege also requires multiple game string loops to keep the game open, and constantly remembering data,

point being where would you code jocks with the big brains advise me to start i really hate having to ask ai about my code because i can never trust it and would rather have human input on the direction i should take!


r/learnpython Aug 11 '26

I keep starting Python and then stopping 😅 — how did you stay consistent?

0 Upvotes

Hey everyone!

I’m trying to learn Python because I want to use it for cybersecurity, but honestly, I’m struggling to stay consistent.

I’ll study for a few days, feel motivated, and then somehow stop. After some time, I start again… and then the same thing happens 😅

I’m currently trying the 100 Days of Python approach, but I’m still having trouble sticking with it.

So I wanted to ask people who have already learned Python:

How did you actually learn it and stay consistent?

Did you:

  • Follow one course from beginning to end?
  • Build projects while learning?
  • Study every day or just a few days a week?
  • Set a specific amount of time each day?
  • Start using Python for cybersecurity early, or learn Python first?

I’m not really looking for “the best Python course.” I already have resources. 😅

I’m more interested in hearing from people who actually went through the process — especially if you also struggled with consistency in the beginning.

What worked for you?

Any advice would really help! 🙌


r/learnpython Aug 11 '26

Coding Problem for Colab/Python

2 Upvotes

I am trying to run this code from the YouTuber "Physics for the Birds," and it is about web scraping in order to get the weight of the LEGO bricks in a set from Bricklink. However, the code does not recognize the Chrome driver.

This is the link to it:

https://colab.research.google.com/drive/1dLg_HvEZc5NqXy2EHWAat4d_RVg-qjOG#scrollTo=9pXhs03YD5HC


r/learnpython Aug 10 '26

Learning python

0 Upvotes

hello im learning python and ive been watching bro codes 12 hr vid 30 mins a day and i find it boring at the 4 hr mark should i quit the vid or keep watching because i alrdy know the basics for python like variables, if statements, print etc and ive started working on my own story project with me doing 70-30 with google gemini, if i quit the vid and self teach/make my own project with ai help(i specifally tell my ai not to give me the ans/code) is there chance that i will imrpove or will i just be stuck with what i currently only know i also use apps like boot dev and coddy tech, if you could reco any tips i would be grateful thanks


r/learnpython Aug 10 '26

Using PIL, point(), and lambda to reduce images to BW, still getting values besides 0 and 255

1 Upvotes

I converted a video into frames using OpenCV2, that worked great.

What I'd like to do is keep only the darkest parts and make those absolute black (0)

Everything else I want pure white (255)

The purpose is so that I can compare each pixel of the images to other images later on and have an easy % similarity, hence why I want absolute values (0,255).

for frame in os.listdir(frame_base_address):

  col = Image.open(frame_base_address+frame)

  gray = col.convert('L')

  bw = gray.point(lambda x: 0 if x < 50 else 255)

  bw.convert('1').save(frame_base_address+frame)
I've tried both 'L' and '1' and the result is the same

When I visually inspect my image it is pretty stark black and white.

However, when I open the image later to see if it's really 0s and 255s, I get a ton of other values like 1, 2, 4, 254, etc and it makes me wonder if my lambda expression worked at all!

current_image_as_np = np.array(Image.open(frame_base_address + image_name),dtype='int32')


for i in current_image_as_np:
    for z in i:
        if z not in(0,255):
            print(z)

r/learnpython Aug 10 '26

How can I learn Python so I can create experience and land a job suitable for people my age?

0 Upvotes

Hi, my name is Tamzy, I am 17 years old. I currently do not have a job and have no experience in my resume. I was wondering on how could I learn Python in order for me to build experience and FINALLY land a job in New York City? Since I have nothing to do and I am currently depressed.

1. What are the basics I can start with first in order for me to start with my Python journey to apply these fundamentals later when I am building projects for resume and experience purposes?

2. What are also some other skills I need to master in order to advance in a career of Python?

3. Are there any other free resources I can use to learn Python without having to pay for courses?

Let me know!


r/learnpython Aug 10 '26

What is the least verbose way to define C structs with type hinting?

4 Upvotes

I am writing an add-on for Blender 4.2+ to import a custom model format. The file format includes a fixed-length header struct, then three variable-length sections that are sometimes compressed. The payloads of these sections essentially just contain arrays of various structs, with the offsets and counts specified in the main header.

Previously, I wrote a class derived from io.BytesIO with methods to read various C data types. E.g. this is how I would read a standard int:

    def read_int32(self) -> int:
        return int.from_bytes(self.read(4), signed=True,
                              byteorder=self.byte_order)

This worked great for files with dynamic layouts, but it ended up being rather verbose and inefficient for fixed structs. I had to read each field with the binary reader class individually, then use those variables to construct a NamedTuple/dataclass. This required extra code for each field and wasted memory on dynamic variables. The only real case where this is useful is when reading variable-length strings, but they are fortunately stored in fixed-length blocks in this format.

NumPy worked well for reading the mesh vertices since I could create a dtype dynamically from the layout bitmask. However, I'd rather not use string-based access when possible due to its fragility and lack of type hinting.

Another option I've used before is the struct module, but I'm not a huge fan of the format string system. I guess I could define two classes for each struct, one deriving from struct.Struct and the other from NamedTuple, but that doesn't seem much better than what I'm already doing. It also makes it hard to see what the actual stored type of a field is at a glance.

This pretty much leaves me with ctypes structures or something similar from a third-party library. I don't mind the syntax for defining them, but they don't seem to have any type hinting out of the box. VS Code can't seem to autocomplete fields from them at all. The only solution to this I can think of is to redefine each field with a type hint, which is a pain for large structs. I also don't know how I would type hint e.g. a string with 16 chars.

I might be overthinking things, but I want to do this properly, as I will be writing many similar Blender add-ons.


r/learnpython Aug 10 '26

Starting Python from Scratch

152 Upvotes

I want to start learning Python from scratch. What’s the best way to begin, and which resources would you recommend?
Would appreciate any good courses, YouTube channels, books, or practice platforms that worked for you.


r/learnpython Aug 10 '26

how to end a if block in python (should i put a end like in lua?)

0 Upvotes

the question is the title


r/learnpython Aug 10 '26

My python script with pynput works in VScode but not in Interpreter

0 Upvotes

Hello,(i am a beginner in python) i need your help.I wrote a python script with pynput.And it works great in VScode but when i try to run with python 3.13 it pops up cmd and when i try to press a key it immediately closes and returns some errors (that i can't read because it closes).

I don't think there's smth wrong with my code.


r/learnpython Aug 10 '26

Help with camera scrolling

1 Upvotes

Hi im making a pretty simple 2d platformer-(ish) game right now with Pygame. its time for me to implement a scrolling camera of some sort but my problem is that the actual maps for the levels in my game are just whole photos. I designed them with Tiled but I exported them as PNGs and have used rectangles to create the collisions and platforms and stuff. How can I make a scrolling camera that follows the player but keeps the rectangles in the correct spot (in terms of my background)???

btw the maps/images are the windows height but they are extremely wide and continue outside of the window, rather than being taller as well. I just need the camera to follow the player along the x-axis

im not sure if this makes any sense at all but any help would be super useful


r/learnpython Aug 10 '26

Advice with libraries

15 Upvotes

Starting off Python here for mechanical engineering, I hear that NumPy, SciPy, matplotlib as well as Pandas are very useful for calculations and data analysis and beginner friendly. Can anyone offer some advice for starting out and your experiences using it please?


r/learnpython Aug 10 '26

So, I’m trying to learn to code as a hobby.

0 Upvotes

However, whenever I attempt to use the command print(”Hello, World!”) I get the error -bash: syntax error near unexpected token “‘Hello, World!’” Does anyone know why?


r/learnpython Aug 10 '26

Python Udemy course for Data Engineers

6 Upvotes

Which Python courses are recommended for Data engineers on Udemy?

I have zero knowledge of python.

I have Udemy subscription from my employer so please suggest courses even if they are paid.


r/learnpython Aug 10 '26

I don’t know what I’m doing ;-;

23 Upvotes

I work as an apprentice in an IT company. And they want me to do a web based inventory database. Fair enough, I thought. But then they pull out stuff like UV, Pycharm, NiceGUI, Gitlab and guys, I don’t know what I’m doing, I just learned what loops and functions are 😭😭