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
Guidance on improving the reconstruction results of my VAE Project

Hi all! I was trying to build a VAE with an LSTM to reconstruct particle trajectories by basing off my model on the paper "Modeling Trajectories with Neural Ordinary Differential Equations". However, despite my loss plots showing a downward trend, my predictions are linear.

I have applied KL annealing and learning rate scheduler - and yet, the model doesn't seem to be learning the non-linear dynamics. The input features are x and z positions, velocity, acceleration, and displacement. I used a combination of ELBO and DCT for my reconstruction loss. The results were quite bad with MinMax scaling, so I switched to z-score normalization, which helped improve the scales. I used the Euler method with torchdiffeq.odeint.

Would it be possible for any of you to guide me on what I might be doing wrong? I’m happy to share my implementation if it helps. I appreciate and am grateful for any suggestions (and sorry about missing out on the labeling the axes - they are x and z)

https://preview.redd.it/veskdk7p7nif1.png?width=529&format=png&auto=webp&s=0938c4dd588961f94eba40a0e20d81008bc131f0

https://preview.redd.it/ddubae7p7nif1.png?width=529&format=png&auto=webp&s=15a24e197e6fd331d92175d1327fb2b482aaa2cc

/r/MachineLearning
https://redd.it/1moj422
Weird Flask bug: MySQL time not showing in HTML

Title:
Weird Flask/MySQL bug: start_time won’t show in <input type="time">, but end_time does

Body:
I’m running into a strange issue in my Flask app with MySQL TIME columns.

Table snippet:

mysql> desc tests;
+-------------+-------+
| Field | Type |
+-------------+-------+
| starttime | time |
| end
time | time |
+-------------+-------+


Python code:

if testData:
print("DEBUG-----------------------", test
Data9)
print("DEBUG-----------------------", testData[10])
test
Data = {
'testid': testData0,
'testname': testData3,
'teststarttime': testData[9],
'test
endtime': testData10
}


Debug output:

DEBUG----------------------- 8:30:00
DEBUG----------------------- 12:30:00


/r/flask
https://redd.it/1mobprf
Bug in Python 3.13 wave module? getnchannels() error on cleanup.

Hey everyone,

I ran into a really strange error today while working with the built-in wave module in Python 3.13 and thought I'd share in case anyone else encounters this or has some insight.

I was trying to do something very basic: generate a simple sine wave and save it as a WAV file using the standard library. My code was the textbook example, using wave.open() inside a with statement to handle the file.

The weird part is that my script runs, but then throws this error right at the end, seemingly during the internal cleanup process after the with block closes the file:

wave.Error: # channels not specified

My code to set the channels (wav_file.setnchannels(1)) is definitely there and in the correct order before writing the frames, so it doesn't seem to be a problem with my script's logic. It feels like the library is failing internally when the file object is being destroyed.

Has anyone else seen this with Python 3.13? Is this a known bug in the new version?

Thanks!

/r/Python
https://redd.it/1modnfw
Does creating a new CMS system based on django make sense?

Hi everyone, I have used wordpress for long time in my career, but security point of view always eats my brain. with lot of plugins comes lots of security holes.

Since django being best in industry for security. can make sense to bring it as alternative to wordpress.

Need your perspective.

/r/djangolearning
https://redd.it/1mn2hqt
I created a wrapper for google drive, google calendars, google tasks and gmail

GitHub: https://github.com/dsmolla/google-api-client-wrapper

PyPI: https://pypi.org/project/google-api-client-wrapper/

What my project does:

Hey, I made a simple, and easy to use API wrapper for some of Google's services. I'm working on a project where I need to use google's apis and I ended up building this wrapper around it and wanted to share it here in case anyone is in the same boat and don't want to spend time trying to figure out the official API.

Target Audience

This is for developers who are working on a project that uses Google's APIs and are looking for easy to understand wrappers

Comparison

Data Models like EmailMessage, Event, DriveFolder, Task vs. Raw API responses
Helper Methods
Built-in support for multiple accounts
Query builders vs. Manually writing raw queries
Clear documentation and Easy to navigate
Similar patterns in all services


I will add async support soon especially for batch operations

/r/Python
https://redd.it/1movsu6
I generated a visual diagram for Flask

Hey all I recently created an open-source project which generates accurate diagrams for codebases.
As I have used flask multiple times in my past for simple endpoint projects I generated one for the community here:

https://preview.redd.it/ttm0nghbkoif1.png?width=1292&format=png&auto=webp&s=3527dfa2a6131082ea7fc39fbf2184593655ad33

It is quite interesting to see how it differentiates from other framework as the diagram gives a quick overview of what actually happens under the hood. The diagram is interactive and you can click and explore the components of it and also see the relevant source code files, check the full diagram is here: https://github.com/CodeBoarding/GeneratedOnBoardings/blob/main/flask/on\_boarding.md
And the open-source tool for generation is: https://github.com/CodeBoarding/CodeBoarding

/r/flask
https://redd.it/1mopr9e
I made this “plug and drop” Django library and need some advice

I’m learning Django and Python at work, and to push myself I built a “plug and drop” Django library with several small apps — accounts, profiles, logging, and even 2FA. I’m still struggling with the basics though, and I’d love advice on how to improve my learning process.

The company I work for is *really* small — about 5 people total, including me. We’re only two who code, one who designs the websites (mostly via WordPress), and one who handles SEO and marketing.
Before I joined this team, I hadn’t coded for about 5 years, and back then it was mostly HTML and CSS.

Here’s my issue:
I understand about 75% of the code written by GPT or the other coder in the company, but when it comes to simple things like `for` loops, `if/else` statements, and basic Python/Django syntax, I often can’t remember or figure out how to write them from scratch.

To help myself learn, I came up with the idea of making a small library of apps that could be useful and also serve as a learning project.
It consists of:

* **An account app** – simple login and registration form, built with a custom user model (not

/r/django
https://redd.it/1moxg27
How to properly register a user

Hey, I have an app where users can register either as Sponsors or as Watchers (normal users).
Currently, I have two apps:

Sponsor, with its own [`models.py`](http://models.py) containing specific fields
Watcher, with its own `models.py` containing different fields

Now, I'm wondering:
Should I create a separate app called User or Accounts to handle all user registrations centrally, and then redirect users to the Sponsor or Watcher apps to complete their profile registration?
Or should I have separate "Register as Sponsor" and "Register as Watcher" links that lead directly to the respective Sponsor or Watcher apps, where registration and profile completion are handled independently?

/r/djangolearning
https://redd.it/1mmdsb6
Django tip Serializing Reverse Relationships

/r/django
https://redd.it/1mp30al
FT8Decoder - A Library for the Parsing and Enrichment of FT8 Radio Messages

Hey everyone! I just released my first Python package, [FT8Decoder](https://pypi.org/project/ft8decoder/).

Earlier this summer I got into amateur radio as a hobby and stumbled across [FT8 transmissions](https://www.youtube.com/watch?v=qInOSHfT8jA) while exploring WebSDR. I was intrigued by the spooky alien sounding tones and wanted to know what they meant. I installed WSJT-X, which decodes them in real time, but as a newcomer, “CQ ABDCE FN41” or “KWB8R KCQ4N R-08” didn’t really give me the clarity I was looking for.

So, I went looking for a Python library that could translate these into readable messages in a fun little script. I couldn’t find one, so I decided to build one myself. From there my little library grew into a full FT8 logging and enrichment tool.

**What my Project Does:**

* Parses WSJT-X UDP packets into clean Python objects
* Classifies all FT8 message types (CQ calls, QSOs, signal reports, acknowledgments, etc.)
* Tracks and organizes the state of every FT8 QSO from CQ to 73
* Translates messages such as "KWB8R KCQ4N R-08" into readable text: "KCQ4N says Roger and reports a signal report of -08 to KWB8R."
* Enriches data with frequency offset, MHz conversion, band detection, and more
* Performs Grid square lookups with lat/lon output and interactive map support (Folium)
* Exports

/r/Python
https://redd.it/1mp4w8k
Potty - A CLI tool to download Spotify and youtube music using yt-dlp

Hey everyone!

I just released **Potty**, my new Python-based command-line tool for downloading and managing music from Spotify & YouTube using **yt-dlp**.

This project started because I was frustrated with spotify and I wanted to self-host my own music, and it evolved to wanting to better manage my library, embed metadata, and keep track of what I’d already downloaded.

Some tools worked for YouTube but not Spotify. Others didn’t organize my library or let me clean up broken files or schedule automated downloads. So, I decided to build my own solution, and it grew into something much bigger.

# 🎯 What Potty Does

* **Interactive CLI menus** for downloading, managing, and automating your music library
* **Spotify data integration**: use your exported `YourLibrary.json` to generate tracklists
* **Download by artist & song name** or batch-download entire lists
* **YouTube playlist & link support** with direct audio extraction
* **Metadata embedding** for downloaded tracks (artist, album, artwork, etc.)
* **System resource checks** before starting downloads (CPU, RAM, storage)
* **Retry manager** for failed downloads
* **Duplicate detection & file organization**
* **Export library data** to JSON
* **Clean up** broken or unreadable tracks
* **Audio format & bitrate selection** for quality control

# 👥 Target Audience

Potty is

/r/Python
https://redd.it/1mp7nd1
Astral's first paid offering announced - pyx, a private package registry and pypi frontend

https://astral.sh/pyx

https://x.com/charliermarsh/status/1955695947716985241

Looks like this is how they're going to try to make a profit? Seems pretty not evil, though I haven't had the problems they're solving.

/r/Python
https://redd.it/1mperw4
AskOra - one CLI to talk to OpenAI, Ollama, and more (without losing your mind)

**What My Project Does:**
AskOra is a Python CLI that lets you send prompts to multiple AI providers (OpenAI, Ollama, etc.) using the **same syntax**. It returns structured JSON responses including output, tokens used, and execution time. Works both sync and async.

**Target Audience:**
Developers who want a simple, unified CLI for experimenting with AI models. Good for scripts, testing, or tinkering with AI without installing a dozen different tools.

**Comparison:**
Unlike installing separate CLIs for each AI provider, AskOra lets you use one command for all. It also provides structured outputs and supports async calls, which most other CLIs don’t.

**Quick Example:**

askora --type openai --key YOUR_KEY --model gpt-4o-mini --prompt "Write me a haiku"

For Ollama (local model):

askora --type ollama --base-url http:/localhost:11434 --model codellama --prompt "Are you a good coder"

**Links:**

* GitHub: [https://github.com/jetroni/askora](https://github.com/jetroni/askora)
* PyPI: [https://pypi.org/project/askora](https://pypi.org/project/askora)

Try it out, break it, and give feedback!

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