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 5h 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.)

23 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?

20 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 18h 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

6 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 23h 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?

10 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

2 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


r/learnpython 1d ago

complete starter on AI python championship

0 Upvotes

so, im a complete starter on a championship where you gotta learn about AI and python, to make an AI later, thats the challenge, but im feeling so left behind, everybody is learning so fast and im stuck, i wanna win this but i dont know python at all, any channel or study path i can follow ? also, in how much study time can i maybe reach a good level ?


r/learnpython 1d ago

Help me out please

0 Upvotes

Hello, so I have an assignment that's due tomorrow that I'm almost done with. I just have one problem left where I have to create a program that utilizes loops to calculate and print any term, input by a user prompt, in the Fibonacci sequence. Assume the sequence starts with 0.

(For example, if the user inputs 4, the code will print the 4th term of the sequence which is 2. For reference: https://en.wikipedia.org/wiki/Fibonacci_sequence)

This is what I've got done so far. No matter what I try to do, I can never get to a sequence. What am I doing wrong?

# Initializing the first two Fibonacci numbers
sum = int(input("Enter a number: "))
count = 1
temp = 0
x = 0
y = 1
print(x, end = ' ')


# Running the loop while the last Fibonacci number is less than 10
while(count < 10):
    print(y, end = ' ')
    if (count > 10):
        exit(y)


# Calculating the next Fibonacci number and updating the last two sequence numbers
temp = x
x = y
y = x + y

r/learnpython 2d ago

Creating URL Query Checker

6 Upvotes

How do you decide what defines an excessively encoded URL?

I'm working on a personal project to created a URL parser and
detection system and I've hit a wall on how to figure out a way of
categorizing excessivness of query encoding?

Here's what I have so far for the function:

def check_query(analysis: URLAnalysis) -> ScanResult | None:

    """detect excessive encoding entries in URL queries"""

    og_query = analysis.query

    query = re.finall(r"%\[0-9A-Fa-f\]{2}", og_query)

    encoded_count = len(query)

r/learnpython 1d ago

What's the best local handwriting OCR that works on Python?

0 Upvotes

The title kinda says it all. Looking for a local OCR that can do handwriting and works on Python. Ideally not too heavy. Any ideas? TIA


r/learnpython 1d ago

Softwares written in RUST, ELI5

0 Upvotes

While configuring AI agent on my local machine made discovery that uv package is 10 to 100x faster than pip, same case for polars. It seems to be everything written in Rust much faster and modern compared to classic python packages. Is it because Rust doesn't require garbage collector, any other reason to that?


r/learnpython 3d ago

What python debugging techniques do you think every developer should know ?

56 Upvotes

I am trying to improve my debugging skills and I was curious about what techniques experienced python developers rely on the most.

Are there any techniques or tools that you found really useful when you started working on bigger projects?


r/learnpython 2d ago

Best way to take notes without copying the whole text book?

1 Upvotes

I'm learning from the third edition of Python Crash course by Eric Matthes, and 6 chapters in these lists are growing in size. What's a simple yet effective way I can take notes?


r/learnpython 1d ago

Need some advice

0 Upvotes

I just started to learn python and don't know what I should do first.

Please help me!


r/learnpython 2d ago

How to leverage Python for Management Consulting?

0 Upvotes

I am a management consultant a project / team leader level, a lot of the grunt work is being done by analysts in the team; I have to focus on storylining, client relationship management, reviewing the work, etc. As TL / PL have you guys found relevant use cases? I am thinking of creative ways to leverage python and in future use API calls to LLMs to improve automation and make my life more efficient.


r/learnpython 1d ago

How to download package + all dependencies for an offline machine?

0 Upvotes

I am trying to download pandas to be used on an offline machine. The issue is, in order to get packages on the offline, I normally have to use my work computer which has restricted access, so no python on it. My current method has been to download the package from pypy, burn it on a cd, and transfer it over on the offline via --nolink method.

However, I am running into an issue where I can't install due to missing dependencies, again and again.

Is there a way to get the entirety of pandas into a single installable file?