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
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
I built my own PyTorch from scratch over the last 5 months in C and modern Python.

What My Project Does

Magnetron is a machine learning framework I built from scratch over the past 5 months in C and modern Python. It’s inspired by frameworks like PyTorch but designed for deeper understanding and experimentation. It supports core ML features like automatic differentiation, tensor operations, and computation graph building while being lightweight and modular (under 5k LOC).



Target Audience

Magnetron is intended for developers and researchers who want a transparent, low-level alternative to existing ML frameworks. It’s great for learning how ML frameworks work internally, experimenting with novel algorithms, or building custom features (feel free to hack).

Comparison

Magnetron differs from PyTorch and TensorFlow in several ways:

• It’s entirely designed and implemented by me, with minimal external dependencies.

• It offers a more modular and compact API tailored for both ease of use and low-level access.

• The focus is on understanding and innovation rather than polished production features.

Magnetron already supports CPU computation, automatic differentiation, and custom memory allocators. I’m currently implementing the CUDA backend, with plans to make it pip-installable soon.



Check it out here: GitHub Repo, X Post

Closing Note

Inspired by Feynman’s philosophy, “What I cannot create, I do not understand,” Magnetron is my way of understanding machine learning frameworks deeply. Feedback is greatly appreciated

/r/Python
https://redd.it/1hv14tt
Python running on Wasm / NEAR under 1MB Challenge

I have tried RustPython and MicroPython and so far. The best result I got with RustPython was 4.3MB and MicroPython got much further (230kb), but there are still some use of unsupported Wasm features or not provided host functions that must be avoided, so here we are with this challenge and a sizeable price for it.

$300k in grants

More details can be found on the GitHub Discussion boards of:

* RustPython: https://github.com/RustPython/RustPython/discussions/5467

* MicroPython: https://github.com/orgs/micropython/discussions/16427

/r/Python
https://redd.it/1huxrs6
How to proxy to a flask/gunicorn app at a non-root location?

I have a flask app served by gunicorn that I want to proxy to through Apache (all on the same machine). I need the app to be accessible through `/wsgi` on the server.

So I'm trying this in the Apache config:

ProxyPass "/wsgi" "unix:/var/run/gunicorn/wsgi.sock|http://%{HTTP_HOST}"

This works but the problem is that `flask.url_for()` produces invalid urls because it doesn't know that it lives under `/wsgi`: It starts all generated URLs at `/` instead of `/wsgi`. It seems that I can make flask recognize this by setting the `SCRIPT_NAME` header like so:

<Location "/wsgi">
ProxyPass "unix:/var/run/gunicorn/wsgi.sock|http://%{HTTP_HOST}"
RequestHeader set SCRIPT_NAME /wsgi
</Location>

...but that doesn't work. `SCRIPT_NAME` remains set to the empty string in `flask.request.environ`.

How can this be done correctly? I don't want to do any hackery on the flask side of things (like hard-coding its "subdirectory" into the application).

Also I noticed that the `%{HTTP_HOST}` bit isn't expanded but gets passed as `%{http_host}` (lowercase) into `flask.request.environ`. Is this the intended behavior? I've got to admit that all my attempts so far have been more or less blindly copy-and-pasted from various web searches

/r/flask
https://redd.it/1hv161d
First personal project


Hey guys, I made my first project in django and react. It's a website that scraps IT job offers from all most popular websites in Poland. I want to look for junior role soon and created it to help me with that.

It's easy to have all job offers in one place, you can save job and track your recrutation process, add notes.
I also summarize description to display only essential info, mainly what company needs.

It's supposed to also help me track what skills are in demand currently.
It took longer than I expected, but want to finally be done with it. I would appreciate some suggestions, feedback 😀

https://devradar.work/

/r/django
https://redd.it/1huyeej
File explorer issue

Hi, im just starting to learn django. the situation is this:

im creating a web and i need to make a button to open the file explorer, but when im trying to test the function the page just broke and never open file explorer, just still loading, any idea what could be and how to resolve? (i dont have the button rn, and i have no idea how to put this func in a button, im so new on web programming). Thank's!

/r/djangolearning
https://redd.it/1hsmqti
Is my way of validating deletion forms inherently bad?

In a lot of places in the website I'm making, I need to make a button that sends the primary key of an object displayed in a list on the page to the server for it to do an action on the object like deleting it or incrementing the value of one of its fields. In those cases, I make a django form with a "type" and "object\_pk" hidden field.

In my view, I then loop on the queryset of every object I want to display in the list and append a dictionnary containing the object itself and its associated form to a list before passing it to the template as context. In this kind of situation, I can't just pass the form itself as context because its "object\_pk" field needs to have a different value for each object. I then display the submit button of each form to the user.

If the user comes to click on the button (let's say it's a delete button) the pk of the object is then sent to the same view which would resemble something like this:

def my_view(request):
if request.method == "POST" and request.POST["type"]

/r/djangolearning
https://redd.it/1hvf3bv