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
[Project] LLM based Python docs that never touches your original code

Documentation is tedious and time-consuming. I thought LLMs might be the answer, but they tend to hallucinate, inventing functions or misinterpret code. Not ideal when you're trying to document real, working code

So I built lmdocs. It can:

* Reference documentation from imported libraries 
* Guarantees that your original code is unchanged
* Work with OpenAI and lo¯cal LLMs

I'd love to get some feedback from other devs. If you're interested, you can check it out here: [https://github.com/MananSoni42/lmdocs](https://github.com/MananSoni42/lmdocs)

It's open source, so feel free to contribute or just let me know what you think. 

/r/MachineLearning
https://redd.it/1dkxld2
What would you improve about Django framework?

If you were part of the Django committee, and you were in charge or deciding where would Django head for its version 6 and in the following years, what would you suggest to the rest of them? What do you think Django is lacking and where it can be improved? If you think the framework is already perfect please also say it in the comments.

/r/django
https://redd.it/1dlj5n6
Saturday Daily Thread: Resource Request and Sharing! Daily Thread

# Weekly Thread: Resource Request and Sharing 📚

Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!

## How it Works:

1. Request: Can't find a resource on a particular topic? Ask here!
2. Share: Found something useful? Share it with the community.
3. Review: Give or get opinions on Python resources you've used.

## Guidelines:

Please include the type of resource (e.g., book, video, article) and the topic.
Always be respectful when reviewing someone else's shared resource.

## Example Shares:

1. Book: "Fluent Python" \- Great for understanding Pythonic idioms.
2. Video: Python Data Structures \- Excellent overview of Python's built-in data structures.
3. Article: Understanding Python Decorators \- A deep dive into decorators.

## Example Requests:

1. Looking for: Video tutorials on web scraping with Python.
2. Need: Book recommendations for Python machine learning.

Share the knowledge, enrich the community. Happy learning! 🌟

/r/Python
https://redd.it/1dlig0j
I made a little Python quiz for interns and new Python developers at my company

I put this quiz together to help create conversation for interns and new python developers at my company. Its based on the content from one of my favourite books (Fluent Python). I hope you enjoy it!

Quiz

/r/Python
https://redd.it/1dkz4gv
Running Python in Web Browsers

Python is one of the world's most popular programming languages and the web is the most ubiquitous application platform. There are several projects which aim to enable Python to run in web browsers.

* [Brython](https://www.brython.info/) is an implementation of Python 3 written in JavaScript.
* [Skulpt](https://skulpt.org/) is an implementation of Python 2/3 written in JavaScript.
* [PyScript](https://pyscript.net/) is an implementation of Python 3 written in WebAssembly.
* [Transcrypt](https://www.reddit.com/r/VistaPython/) is a Python to JavaScript compiler - unfortunately, the project seems to have been abandoned.
* [Batavia](https://github.com/beeware/batavia) is a Python virtual machine written in JavaScript - unfortunately, the project seems to have been abandoned.

Finally, I have created [VistaPython](https://www.reddit.com/r/VistaPython/) which is also intended to run Python 3 in web browsers but by using a bytecode interpreter written in JavaScript.

Each design has strengths and weaknesses:

Both Brython and Skulpt use hand-written Python parsers which are difficult to maintain. VistaPython uses a parser generator, [Antlr](https://www.antlr.org/), to automatically generate the JavaScript code for the parser. The parser can be updated to match the latest Python version by simply running a script.

Also, both Brython and Skulpt generate JavaScript code which is then evaluated. In VistaPython, the compiler produces a "code object" which is then executed using the bytecode interpreter. The first approach will

/r/Python
https://redd.it/1dl8stp
Thread : Recommend the best book/blog/tutorial articles you have gone-though in Django

Let me Start :

# 1 . Theory + Small Projects for Beginners

https://preview.redd.it/92u8c0s3z38d1.jpg?width=2550&format=pjpg&auto=webp&s=10802ee65af298c82b4e89499e8af050614af8ee

These books are very beginner friendly, if you know a bit of django I will suggest go for the PROFESSIONAL and API books.You will buid some simle app , even deploy to heroku or Python anywhere.

# 2. Cookboook for Beginner

https://preview.redd.it/o3limovmz38d1.png?width=1166&format=png&auto=webp&s=bf0692bfe41f1f6529d6ca3ebd560a2081751d92

This one contain 5-6 interesting projects with level of low to high.
It covers -

1. Blog App
2. Social Media Site
3. Ecom Site
4. CMS - by building a e-learning system

Github Link : https://github.com/PacktPublishing/Django-4-by-example

# Suggest more books ? Also Lemme know if you know good blogs/articles/personal blogs where people explains theory as well go though projects hands-on.

Currently i am exploring coding for entrepreneurs (https://www.codingforentrepreneurs.com/search/?query=Django)

/r/django
https://redd.it/1dltqf0
A simple website scraper script

# Web Scraper Script

## What My Project Does

This project scrapes websites to extract and display titles and links of articles. It processes multiple websites in parallel, fetching and parsing content to provide a consolidated list of articles with their full URLs.

## Target Audience

Home users, researchers, and web enthusiasts who need to gather information from multiple websites quickly and efficiently.

## Features

- Parallel Processing: Uses ThreadPoolExecutor to fetch multiple websites concurrently, speeding up the scraping process.
- Error Handling and Logging: Provides detailed logging for debugging and retry mechanisms for robustness.
- Full URL Extraction: Ensures that all extracted links are complete URLs, enhancing usability.
- Customizable Headers: Allows customization of HTTP headers to mimic different browsers.

## Script Overview

The script consists of several key components:

### Fetching URLs

The script fetches content from the given URLs using the requests library. It includes retry logic with exponential backoff to handle transient errors.

### Parsing Content

The script uses BeautifulSoup to parse the fetched HTML content and extract article titles and links. It ensures that the links are converted to full URLs using urljoin.

### Concurrent Execution

The script employs ThreadPoolExecutor to fetch and parse content from multiple websites in parallel, improving efficiency.

## Access the Script

You can access the script on GitHub here:

/r/Python
https://redd.it/1dlfge9
Trouble getting registration form to submit with first_name and email

I have a template from creative-tim. I am trying to get my registration form to work so it will input first\_name and email. Everything else is submitting perfect fine.

templates/registration/signup.html snippet

<form method="POST" action="{% url 'signup' %}">
{% csrf_token %}
<div class="mb-3">
<label for="id_first_name" class="form-label">First Name</label>
{{ form.first_name.errors }}
<input type="text" name="first_name" id="id_first_name" class="form-control bg-gradient-dark border-dark text-white" placeholder="First Name" aria-label="First Name">
</div>


/r/djangolearning
https://redd.it/1dm1als
discover-plugins - track which plugins are installed into your python environment

# What my project does

discover-plugins is a simple CLI tool that lets you list and filter ~~plugins~~ entrypoints installed into a python environment.

I recently had to track down a bug that I ultimately resulted from a plugin I had installed into my environment. To my surprise, there was no easy way to list which kind of plugins were installed, so I decided to build my own tool.

# Target Audience

discover-plugins is intended as a debugging tool for those times when you are not quite sure which plugins are currently part of your python environment.

# Installation

pipx install discover-plugins

# Usage

Find all installed plugins related to pytest (the relevant group name is pytest11):

discover-plugins --group pytest11

The tool defaults to use the first python interpreter on your path, you can optionally specify which interpreter to use with the --interpreter flag.

The output will list all entrypoints belonging to the pytest11 group. For example, if you had installed a single pytest plugin (pytest-aws-apigateway) the output would look like this:

{
"pytest11":
{
"name": "pytest_httpx",


/r/Python
[https://redd.it/1dm01o1
How to Quantitatively Measure the Accuracy of RAG Model-Generated Answers Compared to Expert Respons

Hi everyone,

I’m working on a project that involves generating answers to a set of frequently asked questions (FAQs) related to dental sciences using a Retrieval-Augmented Generation (RAG) model. To evaluate the performance of the RAG model, I want to quantitatively measure the accuracy of its answers compared to standard answers provided by dental professionals and doctors.

I have both sets of answers (expert and RAG-generated) for the same questions, and I’m looking for effective methods or metrics to compare them

/r/Python
https://redd.it/1dm5r6y
Is anyone here looking for a developer to contribute to your personal projects?

I guess the title explains it all, I'm looking for some personal projects to work or contribute on and would be really helpful if anyone is looking for a dev. I did look upon some open-source projects but they were too advanced and out of scope for me so I just wanna start small and learn.

/r/Python
https://redd.it/1dm4h72
Pulling Current List From Database in Flask-Admin Form

`Hello guys,`

1) I have a database named Account and I want to list the Account records of the current user in a select list in this database. But this list must be up to date and list all Accounts currently available. But the code I wrote does not work that way. For example, I add an Account, but I have to close and reopen the script for it to appear up to date. if I don't do this the accounts are never listed. How can I solve this problem?

2) I want to show error/warning or success message on the form depending on the situation. What code can I do this with? I tried form.errors\['general'\] but I was not successful.



I would be very glad if you could help me, thank you.

Screenshot of code : https://imgur.com/carbon-5PSK9Kz


`class JobView(MyModelView):`

`column_list = ('id', 'user_id','account_name', 'api_key', 'keyword_list', 'instructions', 'language', 'product', 'search_tweet_limit', 'num_tweets', 'sleep_time')`

`form_columns = ['account_name', 'api_key', 'keyword_list', 'instructions', 'language', 'product', 'search_tweet_limit', 'num_tweets', 'sleep_time']`



`form_choices = {`

`'account_name': [], # Boş bırakıyoruz, dinamik olarak dolduracağız`

`'language': [], # Boş bırakıyoruz, dinamik olarak dolduracağız`

`'product': [('Latest', 'Latest'), ('Top', 'Top')]`

`}`



`def on_model_change(self, form, model, is_created):`

`if is_created:`

`model.user_id = current_user.id`

`super(JobView, self).on_model_change(form, model, is_created)`



`def is_accessible(self):`

`return current_user.is_authenticated`



`with app.app_context():`

`accounts = Account.query.all()`

`for account in accounts:`

`form_choices['account_name'].append((account.auth_info_1, account.auth_info_1))`



`languages =

/r/flask
https://redd.it/1dm4513
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/1dm9767
My library VidGear v0.3.3 - brings libcamera API Support to python.

Hello Python developers!

I'm excited to announce the release of VidGear v0.3.3, which brings official support for the libcamera backend in its PiGear API! This update enhances the capabilities of Raspberry Pi Camera Modules and provides limited USB camera support.

#### More about PiGear:

PiGear is a specialized API optimized for Raspberry Pi 🍇 Boards, offering comprehensive support for camera modules (e.g., OmniVision OV5647 Camera Module, Sony IMX219 Camera Module) and limited compatibility for USB cameras.

PiGear implements a seamless and robust wrapper around the Picamera2 Python library, simplifying integration with minimal code changes and ensuring a smooth transition for developers already familiar with the Picamera2 API. PiGear leverages the libcamera API under the hood with multi-threading, providing high-performance 🔥, enhanced control, and functionality for Raspberry Pi camera modules.

PiGear handles common configuration parameters and non-standard settings for various camera types, simplifying the integration process. PiGear currently supports PiCamera2 API parameters such as sensor, controls, transform, and format, with internal type and sanity checks for robust performance.

While primarily focused on Raspberry Pi camera modules, PiGear also provides basic functionality for USB webcams (only with Picamera2 API), along with the ability to accurately differentiate between USB and Raspberry Pi cameras using metadata.

PiGear seamlessly switches to

/r/Python
https://redd.it/1dmfnzv
Does anyone follow the Fat Model, Skinny View design pattern in real-world projects?

We're currently dealing with some very thick views at work (think legacy startup code, lol), and I'd like to establish a convention to avoid this in the future. I've found a few resources that recommend encapsulating business logic in your models.

While I'm considering the 'Fat models, skinny views' approach, I'm also curious about any potential pitfalls or challenges that might come with it.

Could you share any insights or experiences in this regard?

Thanks in advance!

References:
- Official docs: https://docs.djangoproject.com/en/5.0/misc/design-philosophies/#include-all-relevant-domain-logic
- Best practices site I found: https://django-best-practices.readthedocs.io/en/latest/applications.html#make-em-fat

/r/django
https://redd.it/1dlxhg3
I've created artikle (https://artikle.live/), an app that classifies LinkedIn posts based on various topics—I've currently set it up for tracking store openings. It's fully built with Flask and Dash. All done in a couple of days. Flask is a really powerful and simple framework.




/r/flask
https://redd.it/1dm2q4s
How can I integrate a existing django project into a django ui kit?

Hey guys....i have joined a startup..and they have 2 things
1. A django project with some models and html templates where i can input data ...
2. A django ui kit...
Now they want me to integrate the main project into the ui kit...
How can i do this?
Is there any way to do this via API?
If so, then how to do this?

/r/djangolearning
https://redd.it/1dmhdrs
Understanding someone else's code

I'm interning right now and have been handed over an unfinished django project by the company. how do i begin to try understanding it ? is there a method that experienced devs use ? the proj does have a postman collection but no other documentation as such. My question might be a little ignorant but i just need to be pointed in the right direction.

(the project isn't live right now, they've just given me push access on github)

/r/django
https://redd.it/1dmhoqh
Python(Django) vs JS(MERN) vs Java

I'm currently a 2nd-year college student with a 2-month vacation right now. I'm planning to dive into web development during this break and throughout my 2nd year. I’d appreciate some advice on my roadmap and whether it’s optimized for my goals.



Here's my current plan:



**2nd Year:**

- **Summer (2 Months)**:

- **Backend**: Learn Django (I already know Python).

- **Frontend**: Learn React.

- **Academic Year**:

- Continue with Django and React.

- Learn FastAPI for building high-performance APIs.

- Focus on Java for DSA (since my college curriculum includes Java).



**3rd Year:**

- **College Curriculum**: Focus on Python for AI/ML projects with Django(heard django is good for this)

- **Self-study**: Switch to the MERN stack (MongoDB, Express.js, React, Node.js) ( Bcoz it is more performant)



**4th Year:**

- **Web Development**: Gain proficiency in both Python (Django, FastAPI) and the MERN stack.

(MAYBE TRY) - **App Development**: Learn React Native or Flutter.



My questions are:

1. Is this roadmap feasible and efficient for becoming proficient in development?

2. Should I prioritize Django and FastAPI over the MERN stack, or vice versa?

3. Given that big companies often use Java and startups lean towards the MERN stack, how should I balance my learning focus?

4. Any other tips or suggestions to

/r/django
https://redd.it/1dmogee
I want to build my first SaaS.

Hey all!
So, I've been a django developer for about 2 years and now I want to build my first SaaS, any advice on how to get started? I don't have any experience on how to put a website to production and I think that's something I'll need to learn along the way.
Stuff like load balancing also scare me cause I'm a self-taught programmer and I'm always afraid of forgetting something or writing shitty code. Besides, I don't have any front-end development knowledge so I think I'm gonna be using django's templates to build the front-end. Is this a stupid idea?
Any help is extremely appreciated :D

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