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
Sunday Daily Thread: What's everyone working on this week?

# Weekly Thread: What's Everyone Working On This Week? πŸ› οΈ

Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!

## How it Works:

1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.

## Guidelines:

Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.

## Example Shares:

1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!

Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟

/r/Python
https://redd.it/1hts9ju
What do you name your initial project? I have always thought "main" but I'm thinking as I am learning that may not be correct or the best

Currently have my projects setup as

/Users/<USERNAME>/Developer/Python/django/<PROJECT_NAME>/main/

tree example below

.
β”œβ”€β”€ README.md
β”œβ”€β”€ WIP_README.md
β”œβ”€β”€ main
β”‚   β”œβ”€β”€ accounts
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ __pycache__
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.cpython-312.pyc
β”‚   β”‚   β”œβ”€β”€ admin.py
β”‚   β”‚   β”œβ”€β”€ apps.py
β”‚   β”‚   β”œβ”€β”€ forms.py
β”‚   β”‚   β”œβ”€β”€ migrations
β”‚   β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”‚   └── __pycache__
β”‚   β”‚   β”‚   └── __init__.cpython-312.pyc
β”‚   β”‚   β”œβ”€β”€ models.py
β”‚   β”‚   β”œβ”€β”€ templates
β”‚   β”‚   β”‚   └── accounts
β”‚   β”‚   β”‚   β”œβ”€β”€ login.html
β”‚   β”‚   β”‚   β”œβ”€β”€ signup.html
β”‚   β”‚   β”‚   └── signup_2.html
β”‚   β”‚   β”œβ”€β”€ tests.py
β”‚   β”‚   β”œβ”€β”€ urls.py


/r/djangolearning
https://redd.it/1htj6qq
Sorting Algorithm Visualizations! (with sound) (+ some DSA implementations)

(TLDR, Project here --> https://github.com/pythonioncoder/DSA-Visualizations)

Hey guys!

I just finished a DSA course and decided to implement some of the stuff I learned in a GitHub repo. I also made visualizations for the sorts I learned, so feel free to check it out! It's been a long-time dream of mine to make sorting algorithm visualizations like the famous ones online, but I could never get the hang of it. So, with that in mind, I hope you can appreciate the stuff I've created!


What the project is:

A GitHub repo full of DSA implementations from Linked Lists to BSTs, alongside various sorting algorithms and visualizations implemented in Python using Matplotlib, Numpy, and Pygame.



Target Audience:

Whoever wants to learn more about DSA and Sorting Algos in Python, or just wants to see some cool animations using Matplotlib.


Comparison:

Similar to Timo Bagman's 'Sound of Sorting' project that went viral on youtube a while ago, except on Python.

/r/Python
https://redd.it/1htuwqi
Introcuding kokoro-onnx TTS

Hey everyone!

I recently worked on the kokoro-onnx package, which is a TTS (text-to-speech) system built with onnxruntime, based on the new kokoro model (https://huggingface.co/hexgrad/Kokoro-82M)

The model is really cool and includes multiple voices, including a whispering feature similar to Eleven Labs.

It works faster than real-time on macOS M1. The package supports Linux, Windows, macOS x86-64, and arm64!



You can find the package here:

https://github.com/thewh1teagle/kokoro-onnx


Also, there’s a demo at the bottom.

/r/Python
https://redd.it/1htwitw
Is learning django not good?

I am a student and learning django. I have made 2-3 basics projects using django and django rest framework. But none of my friends or even my seniors are using django. They all are using the javascript frameworks like node.js or next.js. I just wanted to ask is django not used in companies?
Is it not worth it to learn django??

/r/djangolearning
https://redd.it/1hstzgf
I made another project template, but for a python package (python, uv, pytest and more)

Hey everyone,

last time, i shared a template to get started with a generative AI project named "generative-ai-project-template". https://github.com/AmineDjeghri/generative-ai-project-template

Now i created another template for packaging python libraries named "Python-Package-Template. You can check it out https://github.com/AmineDjeghri/python-package-template

πŸ› οΈ Key Features

Engineering tools:

β€’ βœ… Package management: UV

β€’ βœ… Code quality: Pre-commit hooks with Ruff & Detect-secrets

β€’ βœ… Logging: Colorful logs with Loguru

β€’ βœ… Unit tests: Pytest

β€’ βœ… Dockerized: Dockerfile & docker-compose for your evaluation pipeline

β€’ βœ… Make commands: Simplify your workflow (install, run, test)

CI/CD & Maintenance tools:

β€’ βœ… Pipelines: GitHub Actions (.github/workflows) & GitLab CI (.gitlab-ci.yml)

β€’ βœ… Local CI/CD pipelines: Run GitHub Actions with act and GitLab CI with gitlab-ci-local

Documentation tools:

β€’ βœ… Documentation website: MkDocs + mkdocs-material

β€’ βœ… GitHub Pages deployment: Easy deployment with mkdocs gh-deploy

Any feedback, issues, or PRs are welcome!

/r/Python
https://redd.it/1hu0ojq
ShortMoji: Emoji Shortcuts Made Easy for Your Keyboard !

# What My Project Does

ShortMoji is a lightweight, open-source program that lets you insert emojis anywhere using simple, intuitive keyboard shortcuts. Inspired by Discord's emoji system, it supports **126 unique emoji shortcuts** (and counting!) to make your conversations and workflows more expressive.

Simply type a shortcut like `:ne`, and it transforms into πŸ€“ instantly. ShortMoji runs in the background and is designed for speed and ease of use.

**Features include:**

* Fast emoji insertion via shortcuts.
* Low resource consumption.
* Quick program termination by pressing `Esc` twice.
* Free and fully customizable under the GNU license.

# Target Audience

ShortMoji is for anyone who loves emojis and wants a faster way to use them. Whether you're:

* A developer looking for efficiency.
* A casual user who enjoys using emojis.
* A Discord enthusiast already familiar with emoji shortcuts.

# Comparison

While there are other emoji tools available, ShortMoji sets itself apart with:

* **Customizable shortcuts:** Familiar to Discord users and adaptable for others.
* **Open-source freedom:** Unlike proprietary software, you can modify and expand ShortMoji as you like.
* **Minimal resource impact:** A lightweight utility that doesn’t slow down your system.
* **Simple UX:** No need to navigate menus or GUIsβ€”just type and see the magic !

Unlike system-level emoji menus or bloated applications, ShortMoji is a focused solution for quick and easy emoji input.

πŸŽ‰ **Try

/r/Python
https://redd.it/1hu4pgo
Which game library in Python should I choose?

Title. I have tried pygame a little bit already, but I do know that Arcade and other exist too. Should I stick with pygame for its big community or choose Arcade/Pyglet? I do want to try some game jams in the future. Chose this sub cuz I want an unbiased opinion.

/r/Python
https://redd.it/1hu35pl
post response

i need someone's help to handle the response

i only get this response

{
"firstname": "John",
"middle
name": "",
"lastname": "Doe",
"date
ofbirth": "2000-07-14",
"email": "
johndoe@gmail.com"
}


with this serializer

class RegisterUserSerializer(ModelSerializer):
address = AddressSerializer(required=False)
class Meta:
model = CustomUser
fields = ("first
name", "middlename", "lastname", "dateofbirth", "email", "address")

def create(self, validateddata):
address
data = validateddata.pop('address')
user = CustomUser.objects.create(**validated
data)
Address.objects.create(addressdata, user=user)
return user


i want the response something like this

{
"first
name": "John",


/r/django
https://redd.it/1hu84tk
Chainmock - Mocking library for Python and pytest

I recently released v1.0 of a mocking library that I've been developing for a while. I use it in multiple projects myself and thought others might find it useful in their projects.

Github: https://github.com/ollipa/chainmock

Documentation: https://chainmock.readthedocs.io

What the project is:

Chainmock allows mocking, spying, and creating stubs. It's fully typed and works with unittest, doctest and, pytest. The syntax works especially well with pytest fixtures. Under the hood Chainmock uses Python standard library mocks providing an alternative syntax to create mocks and assertions. It also comes with some additional features to make mocking and testing easier.

Example:

mocker(Teapot).mock("brew").return_value("mocked").called_twice()

mocker(Teapot).spy("add_tea").any_call_with("green").call_count_at_most(2)


Target Audience:

Python developers who want a more ergonomic mocking API for their test suites. The syntax works especially well for developers using pytest fixtures.

Comparison:

Similar to pytest-mock library, Chainmock cleans up mocks automatically but provides a more ergonomic API and also evaluates assertions lazily.

Chainmock's API is heavily inspired by flexmock. Compared to flexmock, Chainmock has more familiar API if you have been using standard library unittest and also supports async mocking.



/r/Python
https://redd.it/1hu44o4
Guidance on python backend

Hi

I would appreciate some guidance on initial direction of a project I'm starting.

I am an engineer and have a good background in python for running scripts, calculations, API interactions, etc. I have a collection of engineering tools coded in python that I want to tidy up and build into a web app.

I've gone through a few simple 'hello' world flask tutorials and understand the very basics of flasm, but, I have a feeling like making this entirely in flask might be a bit limited? E.g I want a bit more than what html/CSS can provide. Things like interactive graphs and calculations, displaying greek letters, calculations, printing custom pdfs, drag-and-drop features, etc.

I read online how flask is used everywhere for things like netflix, Pinterest, etc, but presumably there is a flask back end with a front end in something else?

I am quite happy to learn a new programming language but don't want to go down the path of learning one that turns out to be right for me. Is it efficient to build this web app with python and flask running in the background (e.g to run calculations) but have a JS front end, such a vue.js? I would

/r/flask
https://redd.it/1hu6syw
Should PyPI allow 2 projects to have the same name for importing

In the install instructions for the ibis framework we read:

> the ibis-framework package is not the same as the ibis package in PyPI. These two libraries cannot coexist in the same Python environment, as they are both imported with the ibis module name.


1. What do you think of authors who knowingly build their package to "stomp" on a pre-existing namespace?
1. should PyPI allow such name collisions to occur?


/r/Python
https://redd.it/1hu7d17
Webhooks using python and deployment

I have to make an app in Python that exposes a webhook, processes the request, and makes an HTTP request at the end, which is pretty similar to Zapier/make/n8n.

The app is gonna work on a large scale handling around 1k requests every day. I have experience with Flask, but I am not sure if it is the best choice or should I switch to Django or FastAPI or any other stuff you can recommend, I want to make this app as optimized as possible because it has to replace a make.com scenario. Also, is Python the best choice or I should switch to node.js

Last, I wanna know what can be the best and cost effective deployment solution for it, fly.io, cloud services, render etc.

/r/flask
https://redd.it/1hudyve
I've created a tool to make json prettier β•°(Β°β–½Β°)β•―

Hey everyone,

I just added a JSON Beautifier to my website: https://javu.xyz/json\_beautifier

It takes messy JSON and turns it into nicely formatted, readable JSON. Plus, it has a key case conversion feature! You can select camelCase, snake\\\_case , PascalCase, or kebab-case and transform all keys.

I built this with JavaScript mostly and the Ace Editor library (man it's such a great lib). Ace Editor handles basic JSON syntax error highlighting like a boss.

Here's a peek at some key parts of the code cause i know somes are prob curious!! οΌˆοΏ£οΈΆοΏ£οΌ‰β†—γ€€

`beautifyJSON()`: Grabs the JSON, reads your selected case preference and parses the JSON. If it's invalid, it will show an error message ( pop up windows )

`convertKeysToCase(obj, converter)`:This recursively goes through every key in the JSON object and applies the selected case conversion using helper functions: `toCamelCase`, `toSnakeCase`, `toPascalCase`, `toKebabCase`. These functions use simple string manipulation, like this:

```javascript

function toCamelCase(str) {

return str.replace(/[-_\]([a-z\])/g, (g) => g[1\].toUpperCase());

}

```

Nothing really fancy ahah (ο½žοΏ£β–½οΏ£)~

Then, `JSON.stringify` with `null, 4` pretty-prints with a 4-space indent.

Event Listeners: "Copy", "Paste", "Clear", "Example", and "Beautify" buttons do what you'd expect! \\\^o\^/

I also added a "Back Home" button that takes you back to the main page of my site.. LOL cause yeah i forgot that

/r/flask
https://redd.it/1hu4sgk
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/1huld8j
Using Djando in a Full-Stack Application, I want your opinion!

Hello everyone, how are you?

I'm using Django to build a Full-Stack, Frontend and Backend application, using Bootstrap.

The application itself will be two,

1 - School Management System, where there will be everything a management system has.
2 - System for students to see posted classes

Basically, the two complement each other.

In a world where everything is Rest API and Frontend (Vue, React or Angular), building everything Full-Stack has become rarer, at least in my opinion.

Tell me, what are the pros and cons of this? Mainly I would like to hear from those who deal with applications like this on a daily basis and who tend to grow, any tips?

Thanks everyone!

/r/django
https://redd.it/1hup0if
Potato - A Lightweight Tool for Debugging and Testing Python Code

# Potato: A Lightweight Tool for Debugging and Testing Python Code

# What is Potato?

Potato is a Python package designed to halt your code's execution with precision and simplicity. It’s perfect for debugging, testing control flow, or adding a bit of fun to your scripts. The best part? You don’t even have to install it. Python natively supports Potato, thanks to its strict variable naming rules.

Just type potato into your source code and watch the magic happen! Your script will immediately halt with a NameError, leaving your colleagues (or future self) wondering why there's a potato in your code.

# Why Potato?

Zero Dependencies: Potato requires absolutely no installations or updates.
Lightweight: Takes up 0 bytes of storage.
Instant Debugging: Clearly marks the exact point in your code where Potato strikes.
Fun for Everyone: Confuse your friends, co-workers, and even your future self with a well-placed potato!

# Installation

There is no installation. Python comes with Potato pre-installed. Simply open your favorite Python script and start typing potato.

# Usage

# Example 1: Halting a Script

print("Hello, world!")
potato
print("This will never run.")

Output:

Hello, world!
Traceback (most recent call last):


/r/Python
https://redd.it/1huiq1y
Any good resources that I can follow to deploy my application to AWS ECR?

I am using Gitlab CI pipeline. So far I have managed to create the following pipeline.

stages:
  - test
  - build

sast:
  stage: test
include:
  - template: Security/SAST.gitlab-ci.yml
  - template: Security/Secret-Detection.gitlab-ci.yml

variables:
  AWS_REGION: $AWS_ECR_REGION
  AWS_ACCOUNT_ID: $AWS_ACCOUNT_ID
  ECR_REPO_NAME: $ECR_REPO_NAME
  AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
  AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY

staging-build:
  image: docker:24.0.5
  stage: build
  environment:
    name: staging
  services:
    - docker:24.0.5-dind
  rules:
    - if: '$CI_COMMIT_BRANCH == "staging"'
      when: on_success
    - when: never
  before_script:
    - apk add --no-cache python3 py3-pip aws-cli
    -

/r/djangolearning
https://redd.it/1huaovk
Tuitorial - I built a terminal-based tool for code presentations because PowerPoint was too painful


# What My Project Does

[Tuitorial](https://github.com/basnijholt/tuitorial) lets you create interactive code tutorials that run in your terminal. The key insight is that you define your code ONCE, then create multiple views highlighting different parts using pattern matching rules - no more copy-pasting code snippets across slides! Features include:

* Write code once, create multiple highlighted views
* Interactive step-by-step navigation
* Rich syntax highlighting
* Support for Markdown and even images
* Configure via Python or YAML
* Live reload for quick iterations

Here's a quick demo: [https://www.nijho.lt/post/tuitorial/tuitorial-0.4.0.mp4](https://www.nijho.lt/post/tuitorial/tuitorial-0.4.0.mp4) which runs [this YAML format presentation `pipefunc.yaml`](https://github.com/basnijholt/tuitorial/blob/main/examples/pipefunc.yaml)

# Target Audience

This is for the 0.1% of people who:

* Are giving technical presentations or workshops
* Love terminal-based tools
* Are tired of copying the same code into multiple PowerPoint slides
* Want version-controlled, reproducible tutorials

It's particularly useful for teaching scenarios where you want to focus attention on specific parts of code while keeping everything in context.

# Comparison to Existing Alternatives

The problem with traditional tools:

* PowerPoint/Google Slides: Forces you to copy-paste code multiple times just to highlight different parts
* Jupyter notebooks: Great for readers, but during presentations there's too much text for the audience to get distracted by
* Spiel: While also terminal-based, it's more for general presentations without code-specific features
* REPLs: Interactive but lack structured presentation
*

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