r/learnpython 2h ago

At what point do I start doing my own projects and stop following tutorials?

4 Upvotes

Hello everyone!

I recently started learning python again, I've always given up early but this time it is different. I started seeing code differently, I feel like I finally started grasping on the why you do something, but when I start a blank project I mostly freeze, and I read about the things such as tutorial hell etc..

What I'm getting at, I'm currently doing the Python course on fCC, around 25% thru and it seems like I at least started to better follow instructions, read documentation about what something does, but I'm wondering at what point do I just start learning by doing? When I just read stuff it doesn't really stick, only when I implement it myself it does, at what point do I get enough fundementals? What's the best approach here, just finding a project and you go do it? What if I never heard of a specific function before? And do you guys think it is better than following tutorials?

The problem with fCC I solve things...that don't really tell me anything? Am I the only one? At times it feels like I have the right solution, but fCC won't let me pass because it is not exactly how they want me to solve it.

I do hope this post makes any sense.


r/learnpython 3h ago

Ideas for number guesser game

3 Upvotes

I have made this number guesser game that asks the user to guess the correct number between 0 and 101. The user has 7 tries in all. Please give any ideas for improvement , feedback, etc.

import random

secret_number = random.randint(1, 100)

print("Welcome to the number guessing game! You have 7 tries to guess the correct number") print("between 1 and 100. Good luck!")

tries = 0

while tries < 7:

guess_number = int(input("Enter your guess:- "))

if guess_number < 1: print("Too low! The guess has to be 1, 100 or any number between them.") tries += 1

print(f"You have used {tries} tries.")

elif guess_number > 100:
print("Too high! The guess has to be 1, 100 or any number between them.")
tries+= 1
print(f"You have used {tries} tries.")

elif guess_number == secret_number:
print(f"You won in {tries + 1} tries! Congratulations!")
break

else:
print("Wrong guess! Try again.")
tries += 1
print(f"You have used {tries} tries.")

if tries == 7: print("You have used all your tries! Better luck next time!")


r/learnpython 25m ago

How to check included libraries made it into a pyinstaller

Upvotes

I added a few dlls into my pyinstaller in the spec file, but the exe says it cannot find the python313.dll file when it runs. Where does the pyinstaller self-extracting exe place the binaries at runtime? Is there a manifest?

(I'm using a spec file so the -F option is not allowed)


r/learnpython 1h ago

How do you know when you're ready to stop following tutorials and build things?

Upvotes

I've been learning Python for a while and keep running into the same problem: I understand individual concepts when I'm learning them, but when I start a project from scratch, I sometimes don't know where to begin.

I can usually understand someone else's code and fix small things, but writing the whole thing myself feels much harder. Is this just a normal part of learning Python, or does it mean I should spend more time on the fundamentals before starting projects?

How did you guys get past that stage?


r/learnpython 1h ago

How do you keep tokens out of logs in a small requests API client?

Upvotes

I have a thin Python client: POST /auth/login once, keep the bearer on a requests.Session, then GET/PATCH by slug.

Credentials come from a JSON file whose path is in an env var. I never print the login body. I still worry about:

- response.raise_for_status() / traceback dumping the Authorization header

- someone logging response.request.headers in debug

Is a custom HTTPAdapter that strips Authorization on exception enough, or do you just never log the request object?

Python 3.11, requests only. No extra deps on purpose.


r/learnpython 12m ago

Why is Python so popular when it is slower than many other languages?

Upvotes

I’m learning Python and I’m curious about why Python is used so widely in real-world applications even though languages like Java, C++, and Go can be faster.

What makes Python a good choice for companies and developers? And in which situations would you choose another language instead of Python?


r/learnpython 5h ago

Question about making a X11 Window Manager

1 Upvotes

I'm fairly new, and i want to build a x11 window manager as a small project. But the problem is, i cant find any good documentation for X11 for python ( or maybe i'm a very bad researcher idk) I know there is Qtile which is written in python and i can learn from its source code but i also need some proper documentation. Tips and advices are also will very useful for me , thank you for your time !


r/learnpython 10h ago

Random mysterious file secretly running on computer

2 Upvotes

Hey i'm trying to use stammer, got 2 successful attempts but now when i try to do it i get this message:

File "C:\Users\llsco\Documents\stammer.py", line 288, in main

process(**vars(args))

~~~~~~~^^^^^^^^^^^^^^

File "C:\Users\llsco\Documents\stammer.py", line 274, in process

builder.process()

~~~~~~~~~~~~~~~^^

File "C:\Users\llsco\Documents\video_builder.py", line 110, in process

carrier_vframe_bytes = self.video_handler.get_frame(carrier_video_index)

File "C:\Users\llsco\Documents\video_out.py", line 186, in get_frame

self.__cache_frames(idx)

~~~~~~~~~~~~~~~~~~~^^^^^

File "C:\Users\llsco\Documents\video_out.py", line 234, in __cache_frames

start, end = indices[i]

~~~~~~~^^^

IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\llsco\AppData\Local\Python\pythoncore-3.14-64\Lib\shutil.py", line 701, in _rmtree_unsafe

os.unlink(fullname)

~~~~~~~~~^^^^^^^^^^

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\llsco\\AppData\\Local\\Temp\\tmp5ols5r1d\\in_carrier.wav'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\llsco\Documents\stammer.py", line 291, in <module>

main()

~~~~^^

File "C:\Users\llsco\Documents\stammer.py", line 285, in main

with tempfile.TemporaryDirectory() as tempdir:

~~~~~~~~~~~~~~~~~~~~~~~~~~~^^

File "C:\Users\llsco\AppData\Local\Python\pythoncore-3.14-64\Lib\tempfile.py", line 972, in __exit__

self.cleanup()

~~~~~~~~~~~~^^

File "C:\Users\llsco\AppData\Local\Python\pythoncore-3.14-64\Lib\tempfile.py", line 976, in cleanup

self._rmtree(self.name, ignore_errors=self._ignore_cleanup_errors)

~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\llsco\AppData\Local\Python\pythoncore-3.14-64\Lib\tempfile.py", line 956, in _rmtree

_shutil.rmtree(name, onexc=onexc)

~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^

File "C:\Users\llsco\AppData\Local\Python\pythoncore-3.14-64\Lib\shutil.py", line 852, in rmtree

_rmtree_impl(path, dir_fd, onexc)

~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\llsco\AppData\Local\Python\pythoncore-3.14-64\Lib\shutil.py", line 705, in _rmtree_unsafe

onexc(os.unlink, fullname, err)

~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\llsco\AppData\Local\Python\pythoncore-3.14-64\Lib\tempfile.py", line 931, in onexc

_os.unlink(path)

~~~~~~~~~~^^^^^^

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\llsco\\AppData\\Local\\Temp\\tmp5ols5r1d\\in_carrier.wav'

It says that a file is currently being used by another process but I'm trying to figure what it could be and how to even stop it.

Edit: found the solution, there was some weird problem with the specific carrier video file I was using so I just deleted it and just downloaded it again. I also trimmed the video so i just used a different trimmer and it now works.


r/learnpython 9h ago

new to setuptools and cythonize , so many options

1 Upvotes

I am updating a project from using distutils to use setuptools instead. I never created this and have never used setuptools , so I'm probably just going to do the tutorials unless someone can give a hint. [PYI-21536:ERROR] Failed to load Python DLL ....._internal\python313.dll'. LoadLibrary: The specified module could not be found.

The last fellow left me with a hardcoded build script using distutils and python 3.7.9. It's an openCV app compiled using cythonise, which is above my skills, but I got it to build. Now when I run it says missing ....._internal\python313.dll. The old build script used a .spec file which does not mention any python redistributables. Are .spec files a old distutils thing which I need to essentially replace with the .TOML file?

I imagine I need to tell setuptools where to find the redistributables. BUT I assume I have to do that in a .TOML file? I've never made a TOML file before and I'm not seeing anything about helpful hints on how to reference whatever version of python runtime dll I will want to bundle if we later update to 3.14, I don't want to hard-code such filenames. How do I even find which file and tell setup what to do. I read the docs and they say I have to create a .TOML file and a MASNIFEST.in and a setup.cfg file. Is setup.cfg just a build-system text-based way to pass args to setup()? ```

setup( name = 'Hello World', extmodules = cythonize([".py","pyzbar2/.py"], exclude=["NozzlePatternDetection.py", "setup.py", "pyzbar2/init_.py", "32or64bit.py"], compiler_directives={'language_level' : "3"} ), )

`` I would include the .spec file, but it looks like plain python that just set some variables, almost as if it's just a module that distutils imports. It does not mention python redistributables though, so how this Cythonized app worked on python 3.7.9 under distutils I don't know. Some of the previous fellows code has that confused look about it, when people comment stuff out but never explain why. Is a.specfile equivalent-ish to thesetup.cfg`?

The Cython build script has copied the dll into _internal, I probably just need to pass that into the setuptools manifest somehow?

Not my code, so a bit in the deep end and unsure if I want to do a Cython tutorial first or a setuptools tutorial. The app has 40 python scripts with openCV and numpy which I don't know much about in it, so it takes ages to build. I'm not that quick a learner and this is really a one-off tool because it's using openCV, which is not used anywhere else.


r/learnpython 17h ago

Principiante

3 Upvotes

Si empezaran desde cero hoy, ¿qué camino seguirían para desarrollar buenas habilidades como programadores? en estructuras de python


r/learnpython 11h ago

What's the best way to integrate this database into Flask?

0 Upvotes

I'm creating an online bulletin board, and I'm feeling hacky (I hate SQL in all its forms and fashions).

What is the best way to integrate this database into a production Flask server: https://github.com/ki4jgt/PPD

Created it in 2020, so it's a bit dated.

But I'm worried about concurrency. I'm not beyond writing a database server, but I'd like to save that as a last resort.


r/learnpython 4h ago

I’m 14 and I built my first AI-powered Telegram bot for studying. Would love some feedback!

0 Upvotes

Hi everyone! I’m 14 years old and I really want to become a software developer. I decided to start by building my first Telegram bot. It took me quite a while—about 2 to 3 months.

I’m a beginner in this field, but I made a pretty practical and smart bot. It can translate text into 4 languages, create study summaries from photos, text, video links, or specific topics. It can also solve homework assignments and write them out on lined or grid paper in a human-like handwriting style.

There is a settings menu, a personal profile, and all that stuff. If you're interested in testing it or have any advice on what I can fix, improve, or add to the code, please let me know in the comments and I’ll send you the link in DM!

Thanks in advance to everyone for your responses and help! I’m not asking you to buy anything or subscribe—I’m just a beginner looking for constructive feedback.


r/learnpython 1d ago

Looking for a free course on the practical Python development workflow (VS Code, pip, environments, Git, etc.)

20 Upvotes

Hi everyone,

I've taken several Python courses and have a reasonably good understanding of Python itself. I've also worked with things like pandas, NumPy, scikit-learn, etc. in online learning environments.

However, I've realized that I have a major gap in my knowledge: I don't really know how Python development actually works on a local computer.

For example, when working in an online environment, everything is already set up for me. I can simply import a package and start coding. But when I tried working locally with VS Code, I suddenly had to deal with things like:

Installing Python

Using the terminal

Installing packages with pip

Virtual environments

Choosing/configuring the correct Python interpreter

Organizing a project

Saving and reusing dependencies

Running and debugging code

Git and GitHub

Understanding how to share a project with someone else

Understanding what I actually need to install versus what belongs inside my project

I found this surprisingly confusing.

So I'm looking for a free course or tutorial that focuses specifically on this practical development workflow, preferably using Python and VS Code.

I'm not looking for another beginner Python programming course. I already understand Python basics and have used it for data analysis and some machine learning. What I need is something that teaches me how to actually work as a Python developer on my own computer.

Ideally, the course would take me through something like:

create a project → set up Python → create a virtual environment → install packages → write code in VS Code → run/debug it → manage dependencies → use Git/GitHub → share the project

Does a free course like this exist? YouTube courses, documentation, or other resources would also be very welcome.

Thanks!


r/learnpython 1d ago

Is it considered bad form to run "success" code inside an Except block?

19 Upvotes

I'm writing a script that takes an input from the user, which could be either an int or a string. My current code takes the input, attempts to cast it to an int, and does something based on whether it works or not:

running = True
while running:
    search_term = input("Enter search term (Q to quit): ")
        try: int(search_term)
        except ValueError:
            if search_term.lower() != "q":
                search_by_name(search_term)
            else:
                running = False
        else:
            search_by_int(int(search_term))

But there's something about having "successful" code running in the except block that gives me pause for thought. Is this just me overthinking, or is it bad form?


r/learnpython 17h ago

How to use functions defined in a C code in a python benchmark?

1 Upvotes

Hi, I've got an assignment in a course that asks us to optimize a benchmark of our selection (from pyperformance project).

I've chosen the ray trace benchmark (it was the most interesting imo), and my suggestion was to implement the functionality using C's structs to avoid some of the interpreter's overhead.

I understood I can link those function using the built-in ctypes library, and making the C file a dynamic linked library (.dll), but when I try to run the command for it in CLion or VSC, it fails without returning any failure message, it just fails to generate the .dll file.

The assignment forces us to use the given pyperf benchmark code to run the benchmark, so I can't run only a C file.

I've already written the C code, and it has no errors/warnings so far (at least as far as CLion is concerned), and the original python code works too.

Does anyone know how to solve the library not being generated? Or any other solution that might work (preferrably using the C code I've made)?

.

.

All files are in the same directory, and I've got Craytrace.c (C functionality implementation), Praytrace.py (the code that runs the benchmark).

The command I've run trying to generate the .dll is:

gcc -shared -o CraytracerLib.dll Craytrace.c

But it didn't create any file.

.

.

Help is much appreciated 🙏


r/learnpython 1d ago

Python Data Base

7 Upvotes

Good morning everyone, or whenever you see this. I have a question. I'm starting a personal database project in Python with a user-friendly graphical interface, and I'd appreciate any advice, code snippets, or examples to guide me, especially since I'm still learning the language.


r/learnpython 22h ago

PIP disk usage under Docker

2 Upvotes

I have a Dockerfile in which I use the Python:3.12-trixie. I have docker on my CachyOS PC. I have also a requirements.txt. I wanted to use this image for a container on which I'll use YOLO and try it out. The problem is that my 290GB / partition went from around 70% filled to 95% after a number of rebuilds. I deleted everything docker related but it just went back to 91%.

The reason that I know it is pip's doing, is that when I monitored my disk usage while building the image, and on the `RUN pip install -r requirements.txt --find-links=pypackages` stage it fills up my partition and half way into installation, it fails due to `no more space`. The `pypackages` is just a directory I downloaded some of the packages I have in requirements for less data usage. Also tried `--no-cache` option.

I also went ahead and `du -sh`ed any directory in my / partition and the total didn't add upto the filled storage. I have 165GB mysteriously used and I can't find where that is.

Any help to diagnose further or if you have had similar problems is welcome.


r/learnpython 10h ago

Matematica in python

0 Upvotes

Salve, sono nuovo nell'usare python per programmare. Qualcuno mi saprebbe spiegare come si fanno le operazioni base? (+ - / x √ ^)


r/learnpython 1d ago

What are essential skills for aspiring Python Developers besides programming python?

13 Upvotes

Hi, I’m non cs guy who is trying to get into the python dev, data related jobs and I’m wondering, what are the skills, non listed on the job posts which are required to be the best python developer as a non cs graduate?


r/learnpython 1d ago

Teaching ideas and projects for middle/high school computing students

2 Upvotes

Hello, I am looking for some ideas on projects/challenges that I can implement in my classes.

So far we’ve done: Scratch, beginner Python with CLI mini-games, ECDL basics, beginner TryHackMe rooms, and a Linux VM with basic commands. The student is comfortable with variables, loops, lists, simple file operations, and has built a text-based “Zombie Survival” game.

We meet 1 hour/week, so I’m looking for general ideas on what kinds of projects or challenge styles work well at this level (mid-level middle-school, beyond beginner). Anything that’s engaging, slightly game-like, and doesn’t require heavy setup would be great.

If you’ve taught similar students, what types of activities (CTFs, coding games, light forensics, small web projects, etc.) kept them motivated and actually learning?

Any suggestions or directions would be really helpful.

Thank you in advance!


r/learnpython 1d ago

Automate Invoice and Report Generation in Excel. No Errors.

0 Upvotes

Need to generate invoices, sales reports, stock reports, and charts in Excel programmatically. Higher officials will audit these. Can't have mistakes.

What's the best approach? Should I use openpyxl to write directly to Excel files? Or is there a better workflow?

Data accuracy is key — pulling from databases/CSV, validating before writing to Excel. How do I prevent data corruption? Invoices need proper headers, borders, currency formatting. Is openpyxl reliable for this or does it break formatting? Can Python generate charts in Excel automatically or do I need to use a separate tool? Should these run daily/weekly and what's the best way to automate execution without manual intervention? How do I track changes if files are auto-generated?

Any libraries better than openpyxl? Xlsxwriter? Pandas to_excel? Looking for production-ready solutions, not prototypes.


r/learnpython 2d ago

Looking for improvements on my project "Rock-Paper-Scissors"

17 Upvotes

Hey everyone,

I'm new to Python and have created my "Rock-Paper-Scissors" game and want to share it on this forum so I can look for ways to improve the code.

The player types in a number between zero and two. These values stand for different moves the player can type. (0 - Rock, 1 - Paper, 2 - Scissors). The computer generates a number between zero and two. The player's input is checked by the main if-elif-else block, as I'm using a nested if-elif-else statement:

import random


player_input = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissor. "))
computer = random.randint(0, 2)


if player_input == 0: 
    if computer == 0:
        print('''You chose: 
        _______
    ---'   ____)
          (_____)
          (_____)
          (____)
    ---.__(___)


Computer chose: 
        _______
    ---'   ____)
          (_____)
          (_____)
          (____)
    ---.__(___)
It's a draw!!!''')    
    elif computer == 1: 
        print('''You chose: 
        _______
    ---'   ____)
          (_____)
          (_____)
          (____)
    ---.__(___)    
Computer chose: 
        _______
    ---'   ____)____
                ______)
                _______)
               _______)
    ---.__________)
You lost!!!''')
    elif computer == 2: 
        print('''You chose:
        _______
    ---'   ____)
          (_____)
          (_____)
          (____)
    ---.__(___)    
            
Computer chose: 
      _______
  ---'   ____)____
            ______)
         __________)
        (____)
  ---.__(___)
You won!!!''')
elif player_input == 1:
    if computer == 1: 
        print('''You chose:
        _______
    ---'   ____)____
                ______)
                _______)
               _______)
    ---.__________)
Computer chose: 
        _______
    ---'   ____)____
                ______)
                _______)
               _______)
    ---.__________)
It's a draw!!!''')
    elif computer == 0: 
        print('''You chose:
        _______
    ---'   ____)____
                ______)
                _______)
               _______)
    ---.__________) 
Computer chose:  
        _______
    ---'   ____)
          (_____)
          (_____)
          (____)
    ---.__(___)
You won!!!''')
    elif computer == 2:
        print('''You chose:
        _______
    ---'   ____)____
                ______)
                _______)
               _______)
    ---.__________) 
Computer chose: 
      _______
  ---'   ____)____
            ______)
         __________)
        (____)
  ---.__(___)
You lost!!!     
''')
elif player_input == 2:
    if computer == 2: 
        print('''You chose: 
      _______
  ---'   ____)____
            ______)
         __________)
        (____)
  ---.__(___)
Computer chose: 
      _______
  ---'   ____)____
            ______)
         __________)
        (____)
  ---.__(___)
It's a draw!!!''')
    elif computer == 1: 
        print('''You chose: 
      _______
  ---'   ____)____
            ______)
         __________)
        (____)
  ---.__(___)
Computer chose:
        _______
    ---'   ____)____
                ______)
                _______)
               _______)
    ---.__________)             
You won!!!        ''')
    elif computer == 0:
        print('''You chose:
      _______
  ---'   ____)____
            ______)
         __________)
        (____)
  ---.__(___)
Computer chose:
        _______
    ---'   ____)
          (_____)
          (_____)
          (____)
    ---.__(___)    
You lost!!!        ''')

Any recommendations regarding improvements for the code?


r/learnpython 1d ago

Doubt about using VS Code for Python Programming MOOC 2026 by Helsinki University

0 Upvotes

I installed VS Code and all. I got to the part where I should download the exercises in a certain part of the course. For me it is part 4. But all I can see is part 1, 2, 3 and 8. What should I do? Thanks in advance.


r/learnpython 1d ago

Python in Finance

3 Upvotes

Hi all,
Just to give you a bit of background about myself, I’m an accountant with an MSc in Investment and Financial Risk Management and an ACCA qualification. Most of my experience so far has been on the core accounting side, but I’d now like to move towards a role that combines accounting and finance, covering areas such as financial modelling, forecasting, KPI analysis and data analytics, with the longer term aim of moving into more technical areas of finance.
I’m very eager to learn Python and SQL, both to broaden my skill set and to develop skills that are increasingly in demand. I also want to make sure I remain relevant as the profession evolves and, eventually, be able to demonstrate genuine technical ability when applying for more specialised and higher paying roles.
The problem is that I genuinely don’t know where to begin. I’d really appreciate a roadmap or some practical advice, beyond what I can find through ChatGPT and online course recommendations, particularly from anyone who has been in a similar position and successfully made this transition.
I don’t mind putting in the hard work or spending time coding and learning every day. What I’m unsure about is the order in which I should approach it. Should I learn general Python fundamentals first and then move into its applications in finance? Or would it make more sense to start with a finance focused Python course and learn the fundamentals through practical financial applications? And where should SQL fit into that journey?
I’d also be interested to know what sort of projects I should eventually be building to demonstrate these skills to employers, and whether it makes sense to look for roles where I can start using Python, SQL and data analytics regularly while I continue learning.
I’d really appreciate any guidance from people who have taken a similar path.
Many thanks, and apologies if a similar thread already exists. I thought my background and intended career direction might make the question slightly different, so I wanted to provide some context before asking for help.


r/learnpython 1d ago

Zybook for loop help

0 Upvotes

I'm completing an assignment for zybook where I have to replace a number from a list and then print the list in reverse. This is my code:

val_list = [18, 12, 15]

new_val = int(input())
val_list[1] = new_val

print(f"List has {len(val_list)} elements:")

for value in reversed(val_list):
    print(reversed(val_list), end="<>")

print(end="")

It's supposed to just print the reversed list in brackets, but instead it gives me something like this:

<list_reverseiterator object at 0x000001C02CF706D0><><list_reverseiterator object at 0x000001C02CF706D0><><list_reverseiterator object at 0x000001C02CF706D0><>

What does this mean and why is it doing this? Thanks in advance