Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Image processing to extract miles of rail road track

Anyway to estimate number of miles of red line (rail road track) from this image?

https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSFQBtk10HP5jT5JSHjloQ4E5KoNAl32SGo3Q&s

/r/Python
https://redd.it/1mieaaz
Noobie Created my first "app" today!

Recently got into coding (around a month or so ago) and python was something I remembered from a class I took in high school. Through rehashing my memory on YouTube and other forums, today I built my first "app" I guess? Its a checker for minecraft usernames that connects to the mojang api and allows you to see if usernames are available or not. Working on adding a text file import, but for now its manual typing / paste with one username per line.

Pretty proud of my work and how far I've come in a short time. Can't add an image (I'm guessing cuz I just joined the sub) but here's an imgur of how it looks! Basic I know, but functional! I know some of guys are probably pros and slate me for how it looks but I'm so proud of it lol. Here's to going further!

Image of what I made

/r/Python
https://redd.it/1miuohk
Pybotchi: Lightweight Intent-Based Agent Builder

## Core Architecture:

Nested Intent-Based Supervisor Agent Architecture

## What Core Features Are Currently Supported?

### Lifecycle

- Every agent utilizes pre, core, fallback, and post executions.

### Sequential Combination

- Multiple agent executions can be performed in sequence within a single tool call.

### Concurrent Combination

- Multiple agent executions can be performed concurrently in a single tool call, using either threads or tasks.

### Sequential Iteration

- Multiple agent executions can be performed via iteration.

### MCP Integration

- As Server: Existing agents can be mounted to FastAPI to become an MCP endpoint.
- As Client: Agents can connect to an MCP server and integrate its tools.
- Tools can be overridden.

### Combine/Override/Extend/Nest Everything

- Everything is configurable.

## How to Declare an Agent?

### LLM Declaration

from pybotchi import LLM
from langchain_openai import ChatOpenAI

LLM.add(
base = ChatOpenAI(.....)
)


### Imports

from pybotchi import Action, ActionReturn, Context


### Agent Declaration

class Translation(Action):
"""Translate to specified language."""

async def pre(self, context):
message = await context.llm.ainvoke(context.prompts)
await context.add_response(self, message.content)
return ActionReturn.GO


- This can already work as an agent. context.llm will use the base LLM.
- You have complete freedom here: call another agent,

/r/Python
https://redd.it/1miw2jm
Reading older books

I am going through a relatively older book written in 2019. The book is about recommendation engines and that is the topic I really want to learn for a project I am working on but it uses Django as a web framework for demonstration of the overall system as opposed to just the modeling part. I haven't used Django in a while and kind of don't want to get back on that train again. Is it worth it to either fork and update the book repo to newest version of Django (and in the process re-learn the basics of it) or to try porting the website to FastAPI(my current preferred tool for web) or should I just use the older versions of the libraries? I know in the long run it all depends on specifics but what is the consensus on cases like this when you have to read an older book, few other tutorials/docs exist that go into that much detail and you know versioning will be a problem. Let me know if this belongs to learnpython instead but I thought this is more of a discussion than a question.

/r/Python
https://redd.it/1miw1t9
ValueError: compile(): unrecognised flags error no matter what IDE I use.

$ python `manage.py` shell

Python 3.10.0 (default, Jul 20 2022, 12:26:04) [MSC v.1929 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

(InteractiveConsole)

>>> from landingpage.models import Pages

ValueError: compile(): unrecognised flags

>>>

I keep getting this error no matter what IDE i use or what ORM command I use.
It all started when I was going back and forth betwen powershell and bash inside of cursor and vs code. I was doing this because I was learning flutter. Any help fixing this would greatly help. Thanks!

/r/djangolearning
https://redd.it/1mgg14m
Optional chaining operator in Python

I'm trying to implement the optional chaining operator (?.) from JS in Python. The idea of this implementation is to create an Optional class that wraps a type T and allows getting attributes. When getting an attribute from the wrapped object, the type of result should be the type of the attribute or None. For example:

## 1. None
myobj = Optional(None)
result = (
my
obj # OptionalNone
.attr1 # OptionalNone
.attr2 # OptionalNone
.attr3 # OptionalNone
.value # None
) # None

## 2. Nested Objects

@dataclass
class A:
attr3: int

@dataclass
class B:
attr2: A

@dataclass
class C:


/r/Python
https://redd.it/1mid7mt
Django tip Nested Serializers

/r/django
https://redd.it/1mj2age
I finish my first app with Python/Kivy

Hi everyone!
I just finished developing Minimal-Lyst, a lightweight music player built using Python and Kivy.

It supports .mp3, .ogg, and .wav files, has a clean interface, and allows users to customize themes by swapping image assets.

I'd love to hear your thoughts, feedback, or suggestions for improvement!

GitHub repo:
https://github.com/PGFerraz/Minimal-Lyst-Music-PLayer

/r/Python
https://redd.it/1mj5atd
Looking for a reliable way to extract structured data from messy PDFs ?

I’ve seen a lot of folks here looking for a clean way to parse documents (even messy or inconsistent PDFs) and extract structured data that can actually be used in production.

Thought I’d share Retab.com, a developer-first platform built to handle exactly that.

🧾 Input: Any PDF, DOCX, email, scanned file, etc.

📤 Output: Structured JSON, tables, key-value fields,.. based on your own schema

What makes it work :

\- prompt fine-tuning: You can tweak and test your extraction prompt until it’s production-ready

\- evaluation dashboard: Upload test files, iterate on accuracy, and monitor field-by-field performance

\- API-first: Just hit the API with your docs, get clean structured results

Pricing and access :

\- free plan available (no credit card)

\- paid plans start at $0.01 per credit, with a simulator on the site

Use case : invoices, CVs, contracts, RFPs, … especially when document structure is inconsistent.

Just sharing in case it helps someone, happy to answer Qs or show examples if anyone’s working on this.

/r/Python
https://redd.it/1mj459n
Using AI to convert Perl Power Tools to Python

I maintain a project called Perl Power Tools which was originally started in 1999 by Tom Christiansen to provide Windows the tools that Unix people expect. Although it's 26 years later, I'm still maintaining the project mostly because it's not that demanding and it's fun.

Now, Jeffery S. Haemerhas started the Python Power Tools project to automatically port those to Python. I don't have any part of that, but I'm interested in how it will work out and what won't translate well. Some of this is really old 1990s style Perl and is bad style today, especially with decades of Perl slowly improving.

/r/Python
https://redd.it/1mjanx3
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

# Weekly Thread: Professional Use, Jobs, and Education 🏢

Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.

---

## How it Works:

1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.

---

## Guidelines:

- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.

---

## Example Topics:

1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?

---

Let's help each other grow in our careers and education. Happy discussing! 🌟

/r/Python
https://redd.it/1mjkyyw
Best Frontend Framework

what do you suggest is best frotnend framework libraary for DJango flask python based backend framework in web devalopment i am a devaloper but in MERN AND NEXT meaning i have only work in JS framwork for backend so what will you suggest ?

/r/djangolearning
https://redd.it/1mja974
Illnesses or Conditions Among Programmers

Hey coders, I'm conducting research on the most common health issues among programmers—whether physical, psychological, or emotional—such as joint problems, eye strain, anxiety, migraines, sleep disorders, and others.

I believe it's a topic that doesn't get enough attention, and I'd really appreciate your input.

The direct question is:

Have you developed any condition as a result of spending long hours in front of a computer? What are you doing to manage it, and what advice would you give to the next generation of programmers to help them avoid it?

/r/flask
https://redd.it/1mjl3gv
Bytecode for multiple Python versions

Hi all,

I would like to be able to generate the bytecode (pyc) for a given source file containing the source code for a class (let's call it Foo). I then have another source file containing the code for a second class (Foo2) that inherits from the first one (Foo).

By doing so, I can distribute the sources of the second class (Foo2) along with the bytecode of the first class (Foo). In this way the user won't have access to the code in Foo and still have access to some of the methods (overloaded) in the Foo2 class.

I do this for teaching some stuff. The goal would be that I can distribute the class Foo2 containing the prototypes of the methods that I want students to implement. Additionally the can very easily compare their results with those generated with the method of the parent class. The advantages of this is that I can hide some methods that might not be relevant for teaching purposes (reading, writing, plotting, etc) making the code easier to understand for students.

The problem is that I would have to generate the bytecode of Foo for many different python versions, so I was wondering if someone has a

/r/Python
https://redd.it/1mjw1y0
What python based game engine would you recommend?

For some background info, I have been using python for school since 2024 but i'm still kinda grasping some aspects of it. For my school project, I have decided to create a video game. For context, the game is supposed to have a story aspect at first, but then after the story is completed, it is more free play. Like the player gets to walk around and interact with the world. I plan on having these world interactions being either connected to a crafting system or combat system. Currently I'm torn between using either pygame or pyglet.

Any advice on which engine I should use? Or any recommendations on a completely different game engine to use?

Just looking for some opinions!

/r/Python
https://redd.it/1mjw40b
Where do enterprises run analytic python code?

I work at a regional bank. We have zero python infrastructure; as in data scientists and analysts will download and install python on their local machine and run the code there.

There’s no limiting/tooling consistency, no environment expectations or dependency management and it’s all run locally on shitty hardware.

I’m wondering what largeish enterprises tend to do. Perhaps a common server to ssh into? Local analysis but a common toolset? Any anecdotes would be valuable :)

/r/Python
https://redd.it/1mk1vc7
What I believe to be a minor change, caused my flask startup to break...can someone explain why?

The following are 2 rudimentary test pages. One is just a proof of concept button toggle. The second one adds toggleing gpio pins on my pi's button actions.

The first one could be started with flask run --host=0.0.0.0 The second requires: FLASK\_APP=app.routes flask run --host=0.0.0.0

from flask import Flask, render_template
app = Flask(__name__)

led1_state = False
led2_state = False

.route("/")
def index():
return render_template("index.html", led1=led1_state, led2=led2_state)

.route("/toggle/<int:led>")
def toggle(led):
global led1_state, led2_state

if led == 1:
led1_state = not led1_state
elif led == 2:
led2_state = not led2_state

return render_template("index.html", led1=led1_state, led2=led2_state)



/r/flask
https://redd.it/1mkbhyj
Friday Daily Thread: r/Python Meta and Free-Talk Fridays

# Weekly Thread: Meta Discussions and Free Talk Friday 🎙️

Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!

## How it Works:

1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.

## Guidelines:

All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.

## Example Topics:

1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.

Let's keep the conversation going. Happy discussing! 🌟

/r/Python
https://redd.it/1mkg85s