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
Generating Docx file



Hello everyone,

I have a problem. I need to generate a DOCX file that includes some data plots and a table. I have tried all the available solutions I found online, but none of them have worked. Can you enlighten me with some ideas or suggest a new library?

Thank you.

/r/Python
https://redd.it/1ejzy2l
Scheduled task

I’ve got some basic flask apps under my belt. But nothing too advanced. I know my projects aren’t set up properly, since it’s based on the basic flask intro tutorial.

I’m planning on building a flask project for one of my clubs to run a giveaway next July. I’d like do pull names / contact info from an API, and every 30 minutes on the day of the giveaway select and text winners from entries submitted since the prior winner selection. I’ve never done anything with scheduled or background tasks.

/r/flask
https://redd.it/1ek6xnj
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/1ek9spq
Limitations of subprocess?

Are there any limitations as to what `subprocess` can't do or tools that are known to be incompatible with subprocesses?

I am looking to build an IDE that uses subprocesses to launch code in different environments.

For example, I know it is possible for a subprocess to spawn subprocesses.

However, I don't want to get 100 hours into development only to realize something hypothetical like "oh sqlite connections don't support suprocesses" or "you can't spawn [multithreading/multiprocessing\] from subprocess"

/r/Python
https://redd.it/1ek3vxc
Thoughts on Django Microservices Architecture

I have recently started building Django Projects which I need to connect to each other with a microservices like approach. I was wondering if there are any good references that I can take to model my projects.
Also since its microservices and will have multiple pods for a service, I would also like to understand how we handle the ratelimiting across multiple pods of a service - I am using django_ratelimit as of now

/r/django
https://redd.it/1ek1cis
What Python skills are in demand?

Hello Everyone! As technology keeps evolving, so does the need for certain programming skills. If you're already working with Python or thinking about starting, what do you think are the most valuable Python skills in today's job market? Are there any specific libraries, frameworks, or areas where Python is becoming a must-know? Please let me know what's trending and crucial for Python developers to learn and master!

/r/Python
https://redd.it/1ekhfp4
Saleor vs Oscar Ecommerce

Hi,

I am currently assessing refactoring a custom lightweight marketplace app built with Nuxt to a proper backend (read Django) to address some of the core pain points usually faced with JS applications (incompatibility between packages, lack of included "batteries", time intensive development etc.)
Saleor and Oscar are the most popular options in the Django ecosystem and I was wondering if people had any experience using one or the other? And what was the overall guideline regarding their usage?
Cheers

/r/django
https://redd.it/1ekklgc
AI research in medicine R

I'm interested in AI in medicine and want to dive deeper into AI research in this field. Are there any platforms, researchers, or YouTubers you'd recommend who explore this topic in depth, especially those who discuss and analyze research papers?

/r/MachineLearning
https://redd.it/1ekjkw1
PyAwaitable: An ideal way to define asynchronous logic in C extensions

I've put this idea through a number of discussions (namely, this one and this one) about adding capability to the C API directly to call asynchronous Python code, and I'm officially releasing my reference implementation as a library, per request from the core devs!

## What My Project Does

Put simply, PyAwaitable lets you write and run asynchronous Python functions, from pure C code!

## Target Audience

This project is intended towards those who care a lot about Python performance, or develop C extensions.

## Comparison

As of writing, there are no other libraries that do this. The answer for asynchronous C code has always been: you can't (without a lot of effort, at least -- too much effort for it to be effective).

Most people will defer async logic to a non-async function (think loop.run_until_complete, and friends), and then call that from C.

## Installation

I've developed a stable version, which you can either install off PyPI, or vendor into your project off the releases page: https://github.com/ZeroIntensity/pyawaitable

Feedback, positive or negative, would be appreciated!



/r/Python
https://redd.it/1ekpk4c
Node Demonstrator - tool to create graphs and show standard algorithms

What my project does

I've been working on a module (largely for myself to use in school) to demonstrate to students, and then for themselves to be able to explore, how graph algorithms work step by step.

It's got to a point where I'm happy enough to share with people, is anyone's interested... I've published it on PyPI here (and it's on GitHub, naturally) so feel free to check it out.

Target Audience

Honestly, this is just a toy project aimed at educational use by A-level teachers (UK), and students

Comparison

It was as much about me building the project and proving that I could use Tkinter (well, ultimately CustomTkinter) and particularly the Canvas to create a drag/drop area for the graph. Haven't really looked at alternatives.

/r/Python
https://redd.it/1ekyqvz
I made a quick-start template for Flask apps called Create Flask App

Hey everyone!

I made this project called Create Flask App to help you quickly set up and scale your Flask applications. It comes with user authentication (register, login, logout), profile management, and a basic admin page, all styled with Bootstrap 5.3.3. By default, it uses SQLite3, but you can easily configure it to use your preferred database.

Check it out, give it a star if you like it, and let me know what features you'd love to see next and/or feel free to contribute. Your feedback and suggestions would be awesome!

I will keep working on it, adding new features and improvements.



👉 Create Flask App on GitHub

Thanks for checking it out!

/r/flask
https://redd.it/1ekjvap
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/1el3al8
Tool: quickly find the strptime/strftime format code for your date

I appreciate the various strftime cheat sheets floating around online but I've been wanting a tool that'll do the datetime format string construction automatically for a given date/datetime.

So I made a tool to do this: https://pym.dev/strptime

It has a few not-so-obvious features as well. More details in this post, if you're curious.

/r/Python
https://redd.it/1ekv35s
I am getting an error in forms.py specifically the function in functions.py. Put simply the login function form query for the username and email both return None. How do I fix the code?

I am getting an error that no matter how hard I try I can’t solve it. I have located what is causing the error. It is caused by the code in forms.py specifically the function in functions.py. For some reason the query’s are returning None even though in the /register route I added the username and email and password to the db. I am using the same email for the username form and email form before adding them to the db but I don’t think that should make a difference. How do I fix the code?





I think it was working before. Also I plan to pytest the code where the username form and email form are equal then adding them to the db but I decided to post this in case that doesn’t make a difference.

Also I was looking in dbeaver, a database manager, and the columns username and email exists. So I am very confused. I didn’t include all the function but like stated I included the function that is causing the error. Also in the /register route just assume for simplicity I redirected to the /login route instead of where I redirect.





auth/models.py

https://pastebin.com/K5nE4yVr



auth/routes.py

https://pastebin.com/j0fEg9Hy





auth/functions.py

https://pastebin.com/CnCkkLGT



auth/forms.py

https://pastebin.com/DLBr86uN



Here is the output.

https://imgur.com/a/Pdg7gEk

/r/flask
https://redd.it/1el5vba
Are there patterns for receiveing emails within app?

I have no intention of sending emails on my own, I use SES for that, but sometimes it would be convenient if my app could receive emails, e.g. users could reply to messages by replying to email instead of going to app to write message, etc.

So, are there any ways to implement receiving emails using pure python in my flask app? Maybe some type of webhook solution?

I don't want to deal with Postfix or the likes, nor do i want to integrate with an external email provider, so with these reqiurements maybe the answer is no, not possible.

/r/flask
https://redd.it/1eknuqj
Inventory Management for an Antiques Company with Django and Shopify Integration

Hey everyone!

I'm thrilled to share my experience with my 5th Django project for a real client. This time, I worked with an antiques company to build a robust inventory management system integrated with Shopify.

The project revolved around using webhooks from Shopify to keep the inventory up-to-date and QR codes for quick verification of product locations in the warehouse. One of the key challenges was managing products without bin locations. Initially, products without a specified bin location caused inventory discrepancies. To address this, I adjusted the data queries to handle blank spaces and cleaned the data when importing from CSVs to ensure accurate registration of all products.

Another challenge was seamlessly integrating with Shopify's API and implementing QR code functionality. Shopify's API was quite flexible, which made the integration smoother. I used a Python library to generate and read QR codes, allowing for fast and accurate product verification. This significantly reduced human errors and saved a lot of time.

The app's interface was optimized for use on tablets, enabling employees to move freely around the warehouse while checking inventory. This mobility greatly enhanced the efficiency and accuracy of inventory management.

Working on this real project for a real client was incredibly rewarding. Each project

/r/django
https://redd.it/1ekxpcl
I wrote this simple script to analyze python files.

### What my project does

It's a simple utility script which allows you to analyze your python file. It provides simple detailed insights into the structure and composition of Python code, including information about functions, classes, imports, variables, and function calls.

### Target Audience

Honestly, this is just a fun project

### Comparison

N/A


#### Link to the project

/r/Python
https://redd.it/1el7xyf
How would you implement a "10% off for first-time customers" coupon?

I need to create a coupon that shouldn't be able to be reused.

I've thought of cookies, IP, emails/authentication, fingerprinting, etc., but nothing is really bulletproof.

How would you approach this?

Edit: This is for an ecommerce platform, so assume no user database since guest checkouts are a must.

/r/django
https://redd.it/1ekxcom