r/learnpython • • 19h ago

Is Mimo + Codewars sufficient for learning python?

0 Upvotes

Most stuff like the University of Helsinki courses take 18+ months sooo I wanted to know can I learn python if I do Mimo & after a few beginner chapters I start doing codewars for them would I be able to grasp the same content & knowledge?


r/learnpython • • 13h ago

For each character in name, print character

0 Upvotes

I am totally new to coding and working slowly through the course at futurecoder.io .

On the topic 'Introducing For Loops' we are asked to run the program:

name = 'World'
for character in name: print(character)

I figured character might be some kind of term that python recognises and knows what to do with, like print. Colour me surprised when replacing character with kitten runs, and has the same output. I thought maybe number in place of character might not work, since the characters are all letters, but it works too.

Why is it so? What concept do I need to grasp here?


r/learnpython • • 31m ago

Needed help

• Upvotes

Hi! Everyone, I am new to python and I want to learn it fully and clearly and want to make my fundamentals strong. Is there any specific video or website to learn basics and how many months does it usually takes to learn the python completely?


r/learnpython • • 2h ago

Calling a Script that uses argparse?

3 Upvotes

I wrote a little Python script that reads in a text file that contains a list of fully qualified files, and checks to see if they exist. I originally wrote it using the argparse module. It was set up to take a filename and a switch, so the command looked like:

"Python dplcheck.py --plname "testing.lst” --showexist y"

This worked fine for a single file, but I wanted to run it for every one of hundreds of list files in a directory, so I wrote another script that generates a list of the .lst files in a directory and calls the first script for each one. But I could not get the second script to pass the arguments in the call to the first script. I tried subprocess.run and subprocess.call, with many different syntaxes and quotes, etc. I ended up removing the use of argparse and just using sys.argv[n] -- which I don't particularly like, since it has no defaults or error handling, etc.

Does anyone know how/if I can call a Python script from another Python script and pass the arguments when the called script uses argparse?


r/learnpython • • 19h ago

Best way to learn Python for someone not in CS?

9 Upvotes

Hello, so I'm not a CS major. I'm taking a "Bioinformatics" course that is required but turns out it's literally learning and coding Python. CS doesn't come naturally to me. Unfortunately, I think its crazy boring. I'm actually a Biochem major. Even though it's super insanely boring to me, I really want to get a good grade. But I don't know how. My class is equivalent to a professor reading off the slides, but with coding.

What are some recommended resources for beginner python? Like where I could practice a ton. Practice identifying data types, fixing bugs, understanding and explaining why a code will or wont work etc etc. I'm very willing to spend hours on this.


r/learnpython • • 1h ago

My bot started as one Python file and now it's a mess — how did you learn to split a project into modules without breaking everything?

• Upvotes

I'm a second-year BCA student in Jaipur, learning Python alongside my coursework, and I built a small Telegram bot for myself that started out as one simple file. At first it just did one job, so a single file made sense. Then I kept adding features one at a time — a few more commands, some scheduled messages, a bit of stored data — and now it's a few hundred lines in one file and I'm honestly scared to touch it.

Every change feels risky because everything is tangled together. Functions call each other across unrelated features, I've got similar code copied in two places, and I'm never quite sure what will break if I move something. I've read about modules and packages, but most tutorials use tiny toy examples, and they don't show what the messy middle step looks like on a real, growing project.

So for people who've actually done this refactor: how did you decide where to split? By feature, by layer (commands vs data vs helpers), or something else? Did you move one piece at a time, or rewrite the structure in one go? And without a proper test suite, how did you check after each move that you hadn't broken something quietly?

I'm not looking for the textbook definition of a module — I want to know what your first real split looked like, and what mistake you'd avoid if you did it again.


r/learnpython • • 4h ago

Bro my browser automation agent is stuck in an endless loop and throwing Pydantic errors, how do I actually fix this?

0 Upvotes

So I tried setting up a LangChain Playwright agent to automate posting to Reddit, and man... it is driving me insane.

It starts off fine, navigates to the links, but then it completely loses its mind trying to find input fields. It just keeps looping—retrying get_elements, going back and forth between pages, waiting for 5 seconds over and over again, and getting []every single time. And then to top it all off, it finally crashes completely with a Pydantic validation error (Field required [type=missing, input_value={'element': ...}) because it tried passing weird keys into the click tool instead of a simple CSS selector.

Has anyone actually gotten LangChain's tool-calling agent with Playwright to work reliably on modern dynamic sites like Reddit? Or am I missing something obvious about how it handles selectors and page states? Any advice from people who've dealt with this would be awesome.

code : https://pastebin.com/ZW6nBhGH
typical terminal output : https://pastebin.com/bXY9XftR
im running this in Mac M1 Air (8GB RAM) with Golden Gate.
Suggestions are welcome !


r/learnpython • • 13h ago

Error: failed building wheel for pillow

6 Upvotes

I'm trying to install marker-pdf and then hit with an error,

note: This error originates from a subprocess, and is likely not a problem with pip.

ERROR: Failed building wheel for pillow

Failed to build pillow

error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects

╰─> pillow

I've tried to upgrade pip, reinstalling setuptools, wheel, pillow, and none works, the error remains. What should I do?

OS: Arch Linux
Python: 3.14


r/learnpython • • 16h ago

How to properly break out of an infinite loop inside a multiprocessing child process in Python?

6 Upvotes

I am writing a Python script using the multiprocessing module to launch an external application (Notepad) in a continuous loop. However, I want the loop to stop when a specific condition is met or when a key is pressed.

import os
from multiprocessing import Process 
import time
import keyboard

pid = os.getpid()
print(pid)

callable(os.getpid)
path = r"C:\Windows\System32\notepad.exe"

def process_start(path):
    try:
        while True:
            os.system(path)
    except:
        pass

if __name__ == '__main__':
    # Note: Currently calling the function directly instead of passing the reference
    p = Process(target=process_start(path))
    time.sleep(3)
    p.start()

    if keyboard.press_and_release("q") == "q":
        p.terminate()