Python Daily
2.56K subscribers
1.47K photos
53 videos
2 files
38.5K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Best way to get data from server with flask ?

Hi guys I am currently learning web development in that specifically html,css,js,flask and I came across two ways to get the data from the server to my html page one is to send through flask's render template and another is to fetch from js and display it and I am thinking which is the optimal or best way ?

/r/flask
https://redd.it/1omcdbr
I know the basics of Django but I SUCK at design so I give up when I don’t like the design

How do I get over the design troubles? I have a few project ideas for my current job (military, I understand that these projects MAY not go live cause military is picky about stuff like that) but I still would like to see a project through start to finish.

I’ve tried tailwind and daisy, bootstrap (only recently) nothing turns out as I’m hoping. I’ve looked at theme forest for inspiration but those designs are so complex. And right now I don’t want to pay for a theme.

I just want to complete and deploy a project to AWS (wanting to learn AWS along side Django)

/r/djangolearning
https://redd.it/1omx6tr
Having trouble writing to .txt and CSV files while Flask is running.

So I am trying to write simple submission form text from a website to a text file. The form submits fine and I can even print out my data, but it won't write to a text or csv file for some reason. No errors, the file is just empty. I run the same snippit of code in another file that isn't running flask and the code works fine. It writes to the text file. I can even print out the form text and see it in the debug console; but it just won't write to a file. I feel like I'm in the twilight zone.

#this function should work, but it does'nt
def writetotext(data):
with open('DataBase.txt',mode='a') as database:
email=data'email'
subject=data'subject'
message=data'message'
print(f'\n{email},{subject},{message}')
file=database.write(f'\n{email},{subject},{message}')



/r/flask
https://redd.it/1on2o1l
Monday Daily Thread: Project ideas!

# Weekly Thread: Project Ideas 💡

Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.

## How it Works:

1. **Suggest a Project**: Comment your project idea—be it beginner-friendly or advanced.
2. **Build & Share**: If you complete a project, reply to the original comment, share your experience, and attach your source code.
3. **Explore**: Looking for ideas? Check out Al Sweigart's ["The Big Book of Small Python Projects"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) for inspiration.

## Guidelines:

* Clearly state the difficulty level.
* Provide a brief description and, if possible, outline the tech stack.
* Feel free to link to tutorials or resources that might help.

# Example Submissions:

## Project Idea: Chatbot

**Difficulty**: Intermediate

**Tech Stack**: Python, NLP, Flask/FastAPI/Litestar

**Description**: Create a chatbot that can answer FAQs for a website.

**Resources**: [Building a Chatbot with Python](https://www.youtube.com/watch?v=a37BL0stIuM)

# Project Idea: Weather Dashboard

**Difficulty**: Beginner

**Tech Stack**: HTML, CSS, JavaScript, API

**Description**: Build a dashboard that displays real-time weather information using a weather API.

**Resources**: [Weather API Tutorial](https://www.youtube.com/watch?v=9P5MY_2i7K8)

## Project Idea: File Organizer

**Difficulty**: Beginner

**Tech Stack**: Python, File I/O

**Description**: Create a script that organizes files in a directory into sub-folders based on file type.

**Resources**: [Automate the Boring Stuff: Organizing Files](https://automatetheboringstuff.com/2e/chapter9/)

Let's help each other grow. Happy

/r/Python
https://redd.it/1omx03o
R We were wrong about SNNs. The bo.ttleneck isn't binary/sparsity, it's frequency.

TL;DR: The paper reveals that the performance gap between SNNs and ANNs stems not from information loss caused by binary spike activations, but from the intrinsic low-pass filtering of spiking neurons.

Paper: https://arxiv.org/pdf/2505.18608
Repo (please ⭐️ if useful): https://github.com/bic-L/MaxForme

The Main Story:
For years, it's been widely believed that SNNs' performance gap comes from "information loss due to binary/sparse activations." However, recent research has challenged this view. They have found that spiking neurons essentially act as low-pass filters at the network level. This causes high-frequency components to dissipate quickly, reducing the effectiveness of feature representation. Think of SNNs as having "astigmatism" – they see a coarse overall image but cannot clearly discern local details.

Highlighted Results:
1. In a Spiking Transformer on CIFAR-100, simply replacing Avg-Pool (low-pass) with Max-Pool (high-pass) as the token mixer boosted accuracy by +2.39% (79.12% vs 76.73%)
2. Max-Former tried to fix this "astigmatism" through the very light-weight Max-Pool and DWC operation, achieving 82.39% (+7.58%) on ImageNet with 30% less energy.
3. Max-ResNet achieves +2.25% on Cifar10 and +6.65% on Cifar100 by simply adding two Max-Pool operations.

This work provides a new perspective on understanding the performance bottlenecks of SNNs. It suggests that the path to optimizing SNNs may not simply

/r/MachineLearning
https://redd.it/1on7ow7
🆕 ttkbootstrap-icons 3.1 — Stateful Icons at Your Fingertips 🎨💡

Hey everyone — I’m excited to announce v3.1 of ttkbootstrap-icons is bringing major enhancements to its icon system.

## 💫 What’s new

### Stateful icons

You can now map icons to widget states — hover, pressed, selected, disabled — without manually swapping images.

If you just want to map the icon to the themed button states... it's simple

button = ttk.Button(root, text="Home")

# map the icon to the styled button states
BootstrapIcon("house").map(button)


> BTW... this works with vanilla styled Tkinter as well. :-)

If you want to get more fancy...

import ttkbootstrap as ttk

root = ttk.Window("Demo", themename="flatly")

btn = ttk.Button(root, text="Home")
btn.pack(padx=20, pady=20)

icon = BootstrapIcon("house")

# swap icon on hover, and color change on pressed.
icon.map(btn, statespec=[("hover", "#0af"), ("pressed", {"name": "house-fill", "color": "green"})])

root.mainloop()


Icons automatically track your widget’s theme foreground color unless you explicitly override it.
Fully supports all icon sets in `ttkbootstrap-icons`.
Works seamlessly with existing ttkbootstrap themes and styles.

---

## ⚙️ Under the hood

- Introduces StatefulIconMixin, integrated into the base Icon class.
- Uses ttk.Style.map(..., image=...) to apply per-state images dynamically.
- Automatically generates derived child styles like house-house-fill-16.my.TButton if you don’t specify a subclass.
- Falls back to the original untinted icon for unmatched states (the empty-state '' entry).
- Default mode="merge" allows incremental icon-state changes without overwriting existing style maps.

---

## 🧩

/r/Python
https://redd.it/1on22u9
Pyrefly: Type Checking 1.8 Million Lines of Python Per Second

How do you type-check 1.8 million lines of Python per second? Neil Mitchell explains how Pyrefly (a new Python type checker) achieves this level of performance.

Python's optional type system has grown increasingly sophisticated since type annotations were introduced in 2014, now featuring generics, subtyping, flow types, inference, and field refinement. This talk explores how Pyrefly models and validates this complex type system, the architectural choices behind it, and the performance optimizations that make it blazingly fast.

Full talk on Jane Street's youtube channel: https://www.youtube.com/watch?v=Q8YTLHwowcM

Learn more: https://pyrefly.org

/r/Python
https://redd.it/1oncd2l
DP PKBoost v2 is out! An entropy-guided boosting library with a focus on drift adaptation and multiclass/regression support.

Hey everyone in the ML community,

I wanted to start by saying a huge thank you for all the engagement and feedback on PKBoost so far. Your questions, tests, and critiques have been incredibly helpful in shaping this next version. I especially want to thank everyone who took the time to run benchmarks, particularly in challenging drift and imbalance scenarios.

For the Context here are the previous post's

Post 1

Post 2

I'm really excited to announce that PKBoost v2 is now available on GitHub. Here’s a rundown of what's new and improved:

Key New Features

Shannon Entropy Guidance: We've introduced a mutual-information weighted split criterion. This helps the model prioritize features that are truly informative, which has shown to be especially useful in highly imbalanced datasets.
Auto-Tuning: To make things easier, there's now dataset profiling and automatic selection for hyperparameters like learning rate, tree depth, and MI weight.
Expanded Support for Multi-Class and Regression: We've added One-vs-Rest for multiclass boosting and a full range of regression capabilities, including Huber loss for outlier handling.
Hierarchical Adaptive Boosting (HAB): This is a new partition-based ensemble method. It uses k-means clustering to train specialist models on different segments of the data. It also includes drift detection, so only the affected parts of

/r/MachineLearning
https://redd.it/1on8y3y
Tuesday Daily Thread: Advanced questions

# Weekly Wednesday Thread: Advanced Questions 🐍

Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.

## How it Works:

1. **Ask Away**: Post your advanced Python questions here.
2. **Expert Insights**: Get answers from experienced developers.
3. **Resource Pool**: Share or discover tutorials, articles, and tips.

## Guidelines:

* This thread is for **advanced questions only**. Beginner questions are welcome in our [Daily Beginner Thread](#daily-beginner-thread-link) every Thursday.
* Questions that are not advanced may be removed and redirected to the appropriate thread.

## Recommended Resources:

* If you don't receive a response, consider exploring r/LearnPython or join the [Python Discord Server](https://discord.gg/python) for quicker assistance.

## Example Questions:

1. **How can you implement a custom memory allocator in Python?**
2. **What are the best practices for optimizing Cython code for heavy numerical computations?**
3. **How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?**
4. **Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?**
5. **How would you go about implementing a distributed task queue using Celery and RabbitMQ?**
6. **What are some advanced use-cases for Python's decorators?**
7. **How can you achieve real-time data streaming in Python with WebSockets?**
8. **What are the

/r/Python
https://redd.it/1onsfns
Just got $5K AWS credits approved for my startup

Didn’t expect this to still work in 2025, but I just got **$5,000 in AWS credits** approved for my small startup.

We’re not in YC or any accelerator just a verified startup with:

* a **website**
* a **business email**
* and an actual product in progress

It took around 2–3 days to get verified, and the credits were added directly to the AWS account.

So if you’re building something and have your own domain, there’s still a valid path to get AWS credits even if you’re not part of Activate.

If anyone’s curious or wants to check if they’re eligible, DM me I can share the steps.

/r/django
https://redd.it/1onmrq5
Intercom — Open-Source WebRTC Audio & Video Intercom System in Python

Hi Friends,

I just finished an open-source project called Intercom. It turns any computer with a microphone, speakers, and webcam into a remote intercom. You can talk, listen, and watch in real time through your browser using WebRTC.

Repo: https://github.com/zemendaniel/intercom

# What My Project Does

Intercom allows a single user to remotely stream video and audio from a Linux machine to a browser. The user can monitor a space and communicate in real-time with anyone watching. It uses WebRTC for low-latency streaming and Python/Quart as the backend.

# Target Audience

Hobbyists or developers who want a self-hosted intercom system
People looking for a lightweight, Python-based WebRTC solution
Small deployments where 1 user streams and 1 viewer watches

>

# Comparison

Unlike commercial tools like Zoom or Jitsi, Intercom is:

Self-hosted: No third-party servers required for video/audio except for optional TURN relay.
Lightweight & Python-powered: Easy to read, modify, and extend.
Open-source GPLv3 licensed: Guarantees users can use, modify, and redistribute freely.

# Features

🔊 Two-way audio communication
🎥 Live video streaming
🔐 Password-protected single-user login
⚙️ Built with Python, Quart, and aiortc
🧩 Uses Coturn for TURN/STUN relay support
🖥️ Easy deployment on Linux (Ubuntu/Debian)

# Tech Stack

Python 3.11+
Quart (async web framework)
aiortc (WebRTC + media handling)
Hypercorn

/r/Python
https://redd.it/1onnwlx
In which cases you use custom middlewares

I understand what middlewares are and how they work. But in django, they are global in nature. So, in most projects with versatile requirements, especially with roles, why would anyone want to use global middlewares other than for logging.

As a developer, when have you felt the need to use custom global middlewares?

I really want to understand its use cases so I can better prepare this topic.

Thanks a lot.

/r/djangolearning
https://redd.it/1onq17b
What are some of the most interesting Django projects you worked on?

What are some of the most interesting Django projects you worked on? Be they in a professional or personal capacity. Be mindful if using a professional example not to divulge anything considered sensitive.

/r/django
https://redd.it/1onfdra
Showcase trendspyg - Python library for Google Trends data (pytrends
replacement)

What My Project Does



trendspyg retrieves real-time Google Trends data with two approaches:



RSS Feed (0.2s) - Fast trends with news articles, images, and sources

CSV Export (10s) - 480 trends with filtering (time periods, categories,

regions)



pip install trendspyg



from trendspyg import download_google_trends_rss



\# Get trends with news context in <1 second

trends = download_google_trends_rss('US')



print(f"{trends[0\]['trend'\]}: {trends[0\]['news_articles'\][0\]['headline'\]}")

\# Output: "xrp: XRP Price Faces Death Cross Pattern"



Key features:

\- 📰 News articles (3-5 per trend) with sources

\- 📸 Images with attribution

\- 🌍 114 countries + 51 US states

\- 📊 4 output formats (dict, DataFrame, JSON, CSV)

\- 188,000+ configuration options



\---

Target Audience



Production-ready for:



\- Data scientists: Multiple output formats, 24 automated tests, 92% RSS

coverage

\- Journalists: 0.2s response time for breaking news validation with credible

sources

\- SEO/Marketing: Free alternative saving $300-1,500/month vs commercial APIs

\- Researchers: Mixed-methods ready (RSS = qualitative, CSV = quantitative)



Stability: v0.2.0, tested on Python 3.8-3.12, CI/CD pipeline active



\---

Comparison



vs. pytrends (archived April 2025)





/r/Python
https://redd.it/1oo8fka
CoreSpecViewer: An open-source hyperspectral core scanning platform

# [](https://www.reddit.com/r/Python/?f=flair_name%3A%22Showcase%22)[CoreSpecViewer](https://github.com/Russjas/CoreSpecViewer/tree/main)

This is my first serious python repo, where I have actually built something rather than just "learn to code" projects.

It is pretty niche, a gui for hyperspectral core scanning workflows, but I am pretty pleased with it.

I hope that I have set it up in such a way that I can add pages with extra functionality, additional instrument manufacturers.

If anyone is nerdy enough to want to play with it free data can be downloaded from:

Happy to recieve all comments and criticisms, particularly if anyone does try it on data and breaks it!

**What my project does:**

This is a platform for opening raw hyperspectral core scanning data, processing and performing necessary corrections and processing for interpretation. It also handles all loading and saving of data, including products

**Target Audience**

Principally geologist working with drill core, this data is becoming more and more available, but there is limited choice in commercial applications and most open-souce solution require command line or scripting

**Comparison**
This is similar to many open-source python libraries, and uses them extensively, but is the only desktop based GUI platform

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