r/learnpython • • Aug 23 '26

New to programming. What do you learn?

23 Upvotes

Hi im self taught in python. Ive gotten the basics down (variables, flow control, loops, objects) and ive pushed pasted that into more advanced principles (file handling, async programming, iterators, generators, decorators, and some dunder methods). So far ive only been bouncing around modules and getting certain methods for stuff. Ive learned a little bit about the pvm, Gil, and memory management. Ive only take on class on web design almost a decade ago so I was hoping people could guide me on things to learn. Kinda help me understand where I am in python. Thank you all so much


r/learnpython • • Aug 24 '26

Python web app?

0 Upvotes

Hello r/learnpython,

first post and sort of new to Python as I have done only half a dozen of projects so far, mostly games.

So I'm looking to deploy a server for playtesting. This is my first game designed to be played online, made in Python using Tcl/Tk libraries.

I had this idea to code it when I was making a messaging app that was supposed to be implemented within a CLI game (or actually the game was a feature of the messaging app).

The users would connect using SSH. I think they could use PuTTy or similar and VcXSrv. The host would then send the GUI and CLI as well as audio to the user, but the problem is either the server cannot send or the client can't recieve the Tcl/Tk GUI or in worst case both.

Good news is I got the SSH daemon working and am able to (using X11 Forwarding) display explorer (ssh -X user@localhost && explorer) by running VcXSrv and having X11Forwarding and X11UseLocalhost set to yes in the sshd_config under ProgramData.

Now, the VcXSrv log tells me there's a problem with something called hyperv. From what I gathered it's a virtual machine of some sort. I'd also need very strict restrictions for the clients so they don't tinker with the database.

Am I on the right track? Is there a solution to this? Thanks in advance!

-ef


r/learnpython • • Aug 23 '26

Python Exercises

21 Upvotes

Hi everyone, I've been learning Python here and there for a month now, and I'd like to know some good sites for Python exercises. What do you recommend?

Also, what IDE do you recommend for Android? I use Acode, but it's a bit inconvenient. I mainly use VS Code on my PC, but when I want to practice on my phone, I'd like to use a mobile IDE.


r/learnpython • • Aug 24 '26

opencv error: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'

3 Upvotes

im working on some image processing thing but as soon as i implementing something that needs to set pixels it started throwing this error, does someone know why? code bellow with comments next to the lines that are the issue along with full error

SOLUTION: change img[x,y]=[0,0,0] to img[x,y] = 0

import cv2

img = cv2.imread('peppers2.png', 0)
x = 0
y = 0
for x in range(0, img.shape[0], 1): 
    if img[x,y] >= 127:
        print("white")
        img[x,y] = [255,255,255] # here is the error
    else:
        print("black")
        img[x,y] = [0,0,0] # here is the error
    print(x)
    x = x + 1

Traceback (most recent call last):
  File "/home/useruserman/Documents/Codium/image shit.py", line 13, in <module>
    img[x,y] = [0,0,0]
    ~~~^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'

r/learnpython • • Aug 23 '26

Is short hand if else important

9 Upvotes

I just learned it but it seem very weird like it feels like i can't write big codes in it cause it will become confusing do you guys use short hand or normal if else


r/learnpython • • Aug 24 '26

I need help pls

0 Upvotes

How can I remove in my python script the Windows bar at the top to drag and close please


r/learnpython • • Aug 24 '26

Ask Anything Monday - Weekly Thread

0 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 • • Aug 24 '26

how to make my code work in minecraft

0 Upvotes

dont question my code too much, i just started python and watched a 1 hour coding with mosh video to understand some of the basics.

all it does is move my mouse around while i hold g. but it doesnt work when i go into minecraft, and i assume, any program that locks my mouse.

what do i do?

import random
import keyboard
import pyautogui
import pyscreeze
from pyautogui import mouseInfo, click
while True:
    if keyboard.is_pressed('g'):
        pyautogui.moveTo(random.randint(0, 2600), random.randint(0, 2600))
    if keyboard.is_pressed('q'):
        break

r/learnpython • • Aug 23 '26

Feedback On Fancy Text Printing

2 Upvotes

I've been learning python for years, but I rarely show my code to anyone. I enjoy showing the results of my code to people, but I don't know too many programmers IRL who can give me feedback. I know I have a habit of not commenting enough, but hopefully this is readable. It's my attempt at making text print like in video games (Earthbound, for example.)

Am I doing anything particularly inefficient? I want to know how I can improve this.

from time import sleep
import sys

#Theoretically there could be other wait times for punctuation
punc_default = {" ": 0, ",": 0.25, ".": 0.4, "!": 0.5, "?": 0.5}

def txt(string,time=0.05,punctimes=punc_default):
    for char in string:
        sys.stdout.write(char)
        sys.stdout.flush()
        if char not in punctimes: sleep(time)
        else: sleep(punctimes[char])

txt("Who lives in a pineapple under the sea? Spongebob Squarepants! qwertyuiop.")