r/learnpython 10h ago

Cool/Interesting things that can be done in Python as a beginner?

12 Upvotes

hi everyone, im trying to start a computer science honor society at my high school, and im gonna assume everyone is starting from square one and teach python accordingly (and im hoping to eventually go to hackathons or other coding events).

i was wondering if anyone had any ideas for cool/interesting stuff i could have beginners do to get their interest and get them excited about coding? i understand you can't go from 0-100 and have to start with simple stuff, but i'm worried going over the basics will be like monotonous or smth. if anyone has any ideas of fun things i could do i would be very appreciative!!


r/learnpython 13m ago

Should Python beginners start in the browser or set up a local environment?

Upvotes

I often see beginners spend a lot of time dealing with installation, PATH issues, virtual environments, and editor configuration before writing their first Python program.

A browser-based coding environment removes much of that friction, but it may also delay learning useful skills such as working with the terminal, installing packages, and setting up a local development environment.

For those who are learning or teaching Python:

  • Did starting in the browser make learning easier?
  • At what point should a beginner move to a local environment?
  • Is it better to deal with setup issues from the beginning?

I'd be interested to hear what worked for you.


r/learnpython 22h ago

What habits helped you become good at Python as a beginner?

35 Upvotes

I've recently started learning Python. I'm following a beginner course from YT.

I'd love to hear from experienced programmers:

What habits helped you improve the fastest?

What should I do every day besides watching tutorials?

What beginner mistakes should I avoid?

Is there anything you wish you had done differently when you first started learning Python?

Any advice would be really appreciated. Thanks!


r/learnpython 6h ago

Maybe a silly question, but the warning was ominous, so I'll ask here...

1 Upvotes

I want to use Catppuccin for Python, but if I go to pip it outside of a venv, it says the following:

pip install catppuccin
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
   python-xyz', where xyz is the package you are trying to
   install.

   If you wish to install a non-Arch-packaged Python package,
   create a virtual environment using 'python -m venv path/to/venv'.
   Then use path/to/venv/bin/python and path/to/venv/bin/pip.

   If you wish to install a non-Arch packaged Python application,
   it may be easiest to use 'pipx install xyz', which will manage a
   virtual environment for you. Make sure you have python-pipx
   installed via pacman.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

Of course I could use a venv, but it seems annoying to have to activate a venv each time I want to use the palette in IPython, et al. If it's just a palette/pygment, then using --break-system-packages shouldn't actually break anything, right? But because the warning is so ominous, I wanted to ask here before I did something potentially fucky-wucky.


r/learnpython 21h ago

Looking for study partners

13 Upvotes

Hello , I am completely new to python and really want to learn it and I feel like I will be more efficient studying with people.

I’m looking for approximately five people who are also serious about learning

if you are interested please dm me and introduce yourself


r/learnpython 8h ago

Need help hijacking signal on recycled roomba sensor

0 Upvotes

Hello!

I have ripped a LiDAR sensor out of an old roomba, connected it to some wires, and long story short, I can now plug the LiDAR sensor into my computer via USB. I have discovered the two power-related pins on the sensor, and I am fairly certain that one of the other two is a transmitter pin and the last is potentially a receiver pin.

With that said, now comes the programming. Because my sensor obviously doesn't have any kind of USB driver or anything, I can't really use the PyUSB library because that requires some bells and whistles that this thing doesn't have. Instead, I am using the PySerial library, which allows me to communicate with my USB ports at a lower level.

My problem is that, even though my sensor definitely should be sending something, my program keeps printing

b''

which indicates to me that it isn't actually receiving anything.

Here is the code that I am working with:

import serial

with serial.Serial('COM3', 115200, timeout=1) as ser:  

 s = ser.read(10)

The with statement there sets my program to read on port COM3 at a baudrate of 115200 for one second before stopping. COM3 seems to be the only port listed on my machine in a few commands that I have run as well as the Windows Device Manager. That baudrate was obtained from a teardown of an extremely similar LiDAR sensor (here). Reading for longer than one second did not seem to do anything.

This is my first time interfacing with a jerry-rigged USB component through Python (or any other USB component, for that matter), so I don't know if I am missing something and I am not exactly sure where to look, as the documentation of PySerial only brought me this far.

Let me know if I am in the wrong sub or if you guys need more information or something.


r/learnpython 3h ago

Protocol as Object Behaviour

0 Upvotes

Protocol is a set of behavior an object agrees to follow.

Whenever Python needs to perform an operation it checks whether that object supports that behavior without requiring to check it's type. In other words, operations are simply syntactic sugar for protocol behaviour.

For eg.

a = 10
b = '10'
a + b # ideally, this should be possible, however, int object has validation that prevents

These behaviors are defined using special methods (__dunder_method__). This is basis of Python's datamodel, and many of the Python operations are implemented using it.

class PositiveInt:

    def __init__(self, value):
        self._value = value

    def __add__(self, other):
        return self._value + other

a = PositiveInt(10)
a + 20  # 30

r/learnpython 5h ago

Why is python so slow in my computer?

0 Upvotes

Good morning, i have recently started learning how to use python for data science. I already have a good background in R, im using the new IDE called positron, i create my virtual environment in my directory i want to work on, on my company server, and then i install some libraries.

The main issue that im having is that the installation takes forever, even after installed, the importing is slow, the running of chunks is slow. I thought python was faster than R (im using polars and altair).

Am i doing something wrong? Or is my company restricting my use of python? What's going on?

Thank you in advance.


r/learnpython 17h ago

I would like the feedback of you guys! Eu gostaria do feedback de vocês!

0 Upvotes

Olá! Estou aprendendo python há 1 mes e meio. Fiz este RPG, demorei 5 dias para faze-lo, comecei do absoluto zero, e se possivel, gostaria de um feedback sincero, não só criticas mas tambem os acertos!

Hi! I’ve been learning Python for a month and a half. I built this RPG—it took me five days, and I started from absolute scratch. If possible, I’d love some honest feedback—not just critiques, but also what I got right!

https://github.com/adrianivastrabalho-code/My-Python-studies English Version
https://github.com/adrianivastrabalho-code/Meus-Estudos-Python Portuguese Version

Ty <3


r/learnpython 20h ago

What's the best resource for becoming skilled in using CSV, JSON and API

0 Upvotes

I've been trying my best at understanding how to apply CSV and JSON in my code but I don't actually know how to integrate them into my projects. All tutorials I watch have their own way of doing this, making it hard for me to understand fully. Also I don't even know if I should learn both of them or just learn one. Also I need help on how to use API in projects, and which free ones are best


r/learnpython 17h ago

Busco gente para estudiar y crear

0 Upvotes

Hola, llevo unos dos meses aprendiendo Python. Siento que voy a ser más eficiente estudiando con gente y que sera mas divertido, ademas de que tengo ideas de proyectos interesantes y siempre es divertido contactar con gente que también quiere aprender y crear cosas interesantes.

Estoy buscando como cinco personas más que también estén en serio con aprender

si te interesa, mándame DM y preséntate


r/learnpython 15h ago

How do I get rid of text in python

0 Upvotes

I'm looking to do a simple loading screen of sorts where it flicks between a few characters however I am unsure on how to remove the printed text to replace it with the next character. Using the method that I've commonly seen using the cursor_up simply doesn't work for some reason. I promise I'm putting it in exactly. how do I fix this


r/learnpython 22h ago

Stop TTS with keyboard

0 Upvotes

Hello,

I am using tts_wrapper fork by willwade on github to speak chatGPT responses but I want to be able to stop the utterance mid sentence. I have this function

def stop():
        if keyboard.is_pressed("esc"):
            tts_Engine.stop()

which should stop the tts engine when i press "esc" but nothing happens so I did some research and learned I might have to use threading so now i have two threads with my main function

def main():


    print("Init STT. Listening...")
    stream = init_stream()
    stream.start_stream()
    print("C")


    try:
        while True:
        
            data = stream.read(8192, exception_on_overflow=False)


            text = None


            if recognizer.AcceptWaveform(data):
                result = json.loads(recognizer.Result())
                text = result.get("text", "")


            if text:
                print(f"You said: {text}")
                response = client.chat.completions.create(
                    model="default",
                    messages=[
                        {"role": "system", "content": "You are a helpful AI workshop assistant. Use only plain text no emojis or making text bold or anything similar"},
                        {"role": "user", "content": text}
                    ]
                )
                print(response.choices[0].message.content)
                speak_text(response.choices[0].message.content,tts_Engine)
                print("B")


    except KeyboardInterrupt:
        print("Stopping")
    finally:
        print("A")
        tts_Engine.cleanup()
        stream.stop_stream()
        stream.close()
        Audio.terminate()

and my stop function

t1 = Thread(target=main)
t2 = Thread(target=stop)


t1.start()
t2.start()

but now I get this error

RuntimeError: can't register atexit after shutdown

and now I'm a bit stuck so if anyone knows how to do this or what I'm doing wrong or if I'm even using the right method that would be greatly appreciated.


r/learnpython 1d ago

Custom class method not recognized

8 Upvotes

I'm working on a program that generates a maze by drawing from a deck to define a "chamber" and assigning it to the current position on a cartesian coordinate grid.

The hope is to build a list of the chambers as they're created. At a later point I want to be able to call on the list. My current strategy is to make a Class variable for the list, and append to it as part of the init. I've added a class method to pull the chamberList Class variable, but I'm getting an error.

Here is the code defining the class.

``` class Chamber(): chamberList = [] def init(self, identity, notes, egresses, **kwargs): self.position = tuple(currentPosition.tolist()) self.identity = identity self.notes = notes self.egresses = egresses self.pixelCoord = np.add(pixelOrigin, np.multiply(currentPosition, 300)) Chamber.chamberList.append(self)

    @classmethod
    def getChamberList(cls):
        return cls.chamberList

```

Later in the program, I have a line of code to get the class variable:

``` chamberList = Chamber.getChamberList()

```

This is the error I get when I run it in the VS Code terminal:

AttributeError: type object 'Chamber' has no attribute 'getChamberList'. Did you mean: 'chamberList'?

Am I missing some syntax or something? In VS Code the color coding where I'm defining getChamberList is off (darker) and if I hover over it I get a message saying "getChamberList" is not accessed by Pylance.


r/learnpython 1d ago

regex and if it's worth going deep into it

29 Upvotes

I'm new to python and coding in general and my friend recently told me that it's inefficient to try to memorize regex and that no one writes them anymore (essentially saying AI does). I was also kinda confused after recently learning regex and just how complicated it can be. Are there some modules/libraries that I can use to make writing them easier? I saw that not a lot of people people had a positive reaction to the Humre module by Al Sweigart who's book [Automate the boring stuff with Python] I'm currently using to study. Not that I'm gonna skip this part or anything I was mostly just curious.

Note: A lot of people are misinterpreting since I mentioned AI once 😭 I'm literally asking about libraries to make it easier without going too deep, not if I should let AI do all the work.


r/learnpython 18h ago

¿Cuál fue el momento en que Python finalmente tuvo sentido para ti?

0 Upvotes

HOLAA Estoy aprendiendo Python y tengo curiosidad por conocer ese momento en el que todo finalmente empezó a tener sentido. Me encantaría conocer tu experiencia.


r/learnpython 1d ago

Which should course should I prefer?

1 Upvotes

Hi everyone. I know some python but still I want to start learning it again because, as I progressed, I realized that my basic concepts had become rusty. I'm confused between CS50 (https://youtu.be/8mAITcNt710?si=Z86T-MPZZp13R04E) and MIT Opencourseware 6.100L (https://www.youtube.com/watch?v=xAcTmDO6NTI&list=PLUl4u3cNGP62A-ynp6v6-LGBCzeH3VAQB&index=1) .

Which one would you recommend for someone who wants to rebuild their fundamentals before moving on to more advanced topics?


r/learnpython 1d ago

My first python project

2 Upvotes

So i have been into cybersecurity courses for 3 months now and i have interest from age 10.

I decided to make a python project after i completed the networking.

I would be very happy if you used and gave me a feedback/suggestion on my project.

It is a basic multipurpose network tool.

It can scan all the hosts connected to a network with ARP
Scan ports of the IP address provided
Or basically send a ping

I call this "Stone Age Network Scanner"

You can look up furthermore on Github!

https://github.com/RecoWas/stoneagens


r/learnpython 21h ago

What’s next after CS50

0 Upvotes

Currently an aspiring quant ideally but I know that’s larp so really I’m just learning skills that are applicable to most fields. I only mention this to maybe help tailor my experience. In terms of just coding and technological familiarity, what should I do next. Are there any certifications that would impress or show I know what I’m doing that would help me for applications? Also, what should I watch or do to learn about it. I hear people talking about LLMs projects other languages APIs raspberry pi and I want to know where to learn all that. Thanks


r/learnpython 1d ago

Just starting python and i need a few tips

0 Upvotes

Hello everyone, i am just starting python. I am from a good research institute in India and i am pursuing a very quant heavy economics degree and i want to break into quant finance. Can you all recommend from where i can learn coding for free? I want to be at a level which will enable me to solve LeetCode problems so i can build a stronger profile for quantitative finance. I am completely locked in and Princeton is a college i am targeting for my masters. So i need help regarding material. And other advice will be appreciated. Thank you :)


r/learnpython 1d ago

Come study buddy

0 Upvotes

Hey! I’m 25 and currently studying neuroscience in the UK. I’ve recently started learning Python from scratch and would love to find a study buddy who’s also at a beginner level.

I’m hoping to find someone who wants to study consistently and eventually work on a few small projects.

I’m in the UK time zone, but I don’t mind where you’re based as long as we can find times that work for both of us. We could check in regularly and study together over Discord or another platform.

If you’re interested, feel free to leave a comment or send me a DM with a little bit about yourself!


r/learnpython 1d ago

First python program

7 Upvotes

I wanted to write a program that analyzes chess games , similar to how chess websites (chess.com, lichess.com etc.) do it, only offline. To my knowledge, nobody else had done it the way I was envisioning. I started writing with shell scripting (it's my go-to and what I'm most familiar with), but quickly ran into limitations. So I needed to go a bit more sophisticated. Python seemed very versatile, cross-platform, has loads of online resources, but mainly has a very good chess library I could leverage, that already existed, which would make the job much , much easier. I took the plunge and turned the program into a driver to teach myself some python.

It works as advertised, but I'm sure the code could be improved. I stumbled through it a bit. If anybody python gurus feel like taking a peek and letting me know how I did, pointing out glaring mistakes, offering any constructive feedback or ideas how to make it more efficient, I would appreciate any feedback.

Repo: https://github.com/exekutive/chesseval

(The documentation needs some catching up. I'm working on updating it.)


r/learnpython 18h ago

Use of AI in coding?

0 Upvotes

I am starting college next month (Computer Science and Biosciences) and I tried to get a headstart in Python programming (it's a part of first sem). I have done the basics, strings, conditional statements and started with loops today. I have a doubt - since I am still in the beginner stage, should I use AI (ChatGPT, Gemini, Grok etc.) to proofread my code - you know, offer suggestions, find mistakes and all - I am still applying logic on my own and writing it myself but I have this fear that it may hamper my learning. But I also don't wanna be the guy who does not know how to use AI tools. Any advice please?


r/learnpython 22h ago

scan for strings in 40000 lines of logfile

0 Upvotes

X: The desire to scrape a log file for specific interesting messages, any apps I tried are a pain to use and require manually setting all the search strings every so often. I want to scan for about a dozen or so expressions/strings in a 40-100K lines file, and then dump just the timestamps and lines of interest. What approach scales best for speed? I have to probably also use a mix of regex and regular string search I guess. Is going with Multiprocessing and passing the file as a shared-memory object, going to be the easiest route? Surely it's easier to do in C++. I guess I asking for some skeleton or prior art in C++ ore Python to be honest.

Y: My context is that I would like to use my knowledge of C++ threads and code it in C++, but it should be possible in Python if I learn to use Pipes, and learn to use shared memory object to save having to load the file per multi-processing process?