Daily Python News Question, Tips and Tricks, Best Practices on Python Programming Language Find more reddit channels over at @r_channels
How do you sell your services?
I'm interested in knowing how Django does sell their services. Do you guys normally just talk to people and get clients that way, where you recommended initially by another client that you had, or do you actively advertise yourself on social media or you've been paying Google ads or similar in order to attract customers?
I have these in more questions so feel free to talk about what your approaches or what your experience has been and what you would recommend doing or not doing.
For example if you had a CRM platform with an e-commerce ability to sell products and services. Do you ask people to try your product and then sell it to them or do you have people normally come to you and ask for your services?
Thank you and have a good week
/r/django
https://redd.it/1fpfmhr
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!
# Weekly Thread: Professional Use, Jobs, and Education 🏢
Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.
---
## How it Works:
1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.
---
## Guidelines:
- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.
---
## Example Topics:
1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?
---
Let's help each other grow in our careers and education. Happy discussing! 🌟
/r/Python
https://redd.it/1fpj37t
Reflex v0.6.0 - Frontend. Backend. Pure Python
Hey folks, it's been awhile (v0.4.0) since we (reflex-dev/reflex 19k stars) posted in this community! Just wanted to share some of the exciting new features and improvements we've been working on.
GitHub: https://github.com/reflex-dev/reflex
# What My Project Does
Reflex is the open-source framework empowering Python developers to build web apps faster. Build both your frontend and backend in a single language, Python (pip install reflex), with no JavaScript or web development experience required.
# Target Audience (e.g., Is it meant for production, just a toy project, etc.)
Production-ready--primarily to build internal data, AI, and web apps.
# Comparison (A brief comparison explaining how it differs from existing alternatives.)
Over 60+ components built-in with the flexibility to extend and customize by wrapping your own React components e.g. AG Grid. Strong OOP support, first-class database management (SQLAlchemy), and minimal boilerplate.
# Enhancements and improvements
Optimized Performance: Multiprocess compilation is now available as an opt-in feature, dramatically improving compilation speed for large applications.
We significantly improved our graphing components. Additionally the charts can be made responsive to the window size by setting width to a percentage.
A new `/_health` endpoint has been added for easier monitoring in production environments great for people working with k8s.
The CLI for creating and publishing
/r/Python
https://redd.it/1fpf1lx
Please Help.
https://www.reddit.com/gallery/1fnqqav
/r/djangolearning
https://redd.it/1fnqrkb
The Magic Behind POST Requests in Django REST Framework
antarjaalasanchari/the-magic-behind-post-requests-in-django-rest-framework-caec0d0f1063" rel="nofollow">https://medium.com/@antarjaalasanchari/the-magic-behind-post-requests-in-django-rest-framework-caec0d0f1063
/r/djangolearning
https://redd.it/1fogn8a
ParScrape v0.4.5 Released
# What My project Does:
Scrapes data from sites and uses AI to extract structured data from it.
# Key Features:
Uses Playwright / Selenium to bypass most simple bot checks.
Uses AI to extract data from a page and save it various formats such as CSV, XLSX, JSON, Markdown.
Has rich console output to display data right in your terminal.
# GitHub and PyPI
PAR Scrape is under active development and getting new features all the time.
Check out the project on GitHub or for full documentation, installation instructions, and to contribute: [https://github.com/paulrobello/par\_scrape](https://github.com/paulrobello/par_scrape)
PyPI https://pypi.org/project/par\_scrape/
# Comparison:
I have seem many command line and web applications for scraping but none that are as simple, flexible and fast as ParScrape
# Target Audience
AI enthusiasts and data hungry hobbyist
/r/Python
https://redd.it/1foqa9o
Anyone have any clean logging example code?
I already have django logging fully wired up and functional, and have configured logging across the majority of my views.
The problem I have is that I feel like the log statements clutter my code up a bit. I was thinking of writing a decorator to move the log statements out of the view logic, but then im only able to log relatively generic information.
Anyone have any clean examples or philosophies regarding logging here?
/r/django
https://redd.it/1fowvgf
Asynchronous execution in general
Since this topic comes up here pretty often I was wondering why one would want to do stuff asynchronously and why I seem to be doing it completely differently than the solutions suggested by others here.
1) I have a large table where each cell gets some data from a database query. Since it takes a long time to load the whole page this way I first create the empty table and then have each cell load its data using a separate GET request and have the backend return JSON data way (I think this used to be called AJAX at some time). So it's the browser doing the async stuff, not the backend.
2) I have the app send an email after someone has done some "work" in a session. I spawn a thread which monitors the session (via a timestamp in a database) and when there is no activity for a few minutes, the email gets sent.
So for my use cases the backend does not have to do anything asynchronous at all, or a simple built-in Thread object does the trick.
My take on this is: If you need the app to do something slow while the user is waiting,
/r/flask
https://redd.it/1fojr13
I am in love with Django
Originally I am a data engineer with 4 years of experience. For some side projects I started developing Django around 2 years ago from now. Currently I am developing a yoga education platform for my wife. I feel like I really started to grasp the principles behind the framework. And I realized how all the framework is in harmony with SOLID principles.
I am really enjoying every piece of work I had so far. And I am totally in love with the framework.
/r/django
https://redd.it/1fomc3x
Event Driven Architecture
I'm planning to adopt an event-driven architecture (EDA) for our backend services to improve inter-service communication and system scalability. I'm considering using domain events and a message bus(probably NATS). Does anyone have experience with implementing EDA in Python? Are there any specific libraries or frameworks you'd recommend? Also, what are some common pitfalls to avoid during the transition?"
We have a mix of “microservices” and services that form a distributed system that is dependent on each other.What is lacking is an existing, reliable way for implementing asynchronous inter-service communication by adoption of an EDA . Right now the services talk to each other directly . For a majority of the communication, we’ve utilized REST. The challenge with REST is that it implements a response pattern that tends to couple services together . So I am hoping the domain events should be able to offer a standardized schema for domain events using a schema with each service having the capability to extend as desired. Also a way to view and keep track of events and their associated side effects in the services (An Eventory). For messaging bus should be able to support distributed messaging patterns as well offer high
/r/Python
https://redd.it/1folpvx
Some thoughts on omegaconf and hydra
I recently finished a tutorial on using omegaconf and hydra for ML projects. At the beginning, I thought "okay sure this is nice, a flexible way of specifying config options either in a yaml file or at the command line". By the end, we had developed a complex ML project where we configured different tasks, datasets, training options, optimizers and evaluation settings, all via these nested folders & yaml files, in order to demonstrate hydra's composition, class instantiation, and interpolation abilities. At this point though, all I could think is, "this just feels like learning another programming language" and moreover...why not just do this all in native python to begin with? I was just left feeling rather unclear on what this solves / makes easier?
/r/Python
https://redd.it/1fokrl9
ShareLMAPI: Local Language Model API for Efficient Model Sharing Across Devices and Programs
# What [ShareLMAPI ](https://github.com/starpig1129/ShareLMAPI)Does
ShareLMAPI is a local language model API that allows **sharing model weights across multiple programs on the same device** and supports **cross-device API calls**. Its goal is to reduce resource consumption by avoiding the need to load models multiple times for different processes or devices. Some of its key features include:
* **Local server and client**: The server allows managing model settings, API configurations, and dynamic model loading. The client supports setting various generation parameters when making API calls.
* **Streaming output support**: For real-time tasks, the API can stream responses, improving efficiency for interactive applications.
* **Supports advanced model loading**: It can load models using techniques like BitsAndBytes and PEFT for efficient handling of large language models.
* **API token-based authentication**: Secures both local and cross-device access to the API.
* **Environment setup with Conda and Docker**: Provides an easy way to manage the environment and deploy the API using containerization.
# Target Audience
This project is aimed at developers and AI practitioners who work with large language models and need a solution to **share models efficiently across applications** on the same device or across multiple devices in a local environment. It is designed for **local deployment** and can be used in small-scale
/r/Python
https://redd.it/1foch4h
Does Flask support Asynchronous Programming?
I'm working on a project with flask and thought about adding making the project asynchronous with asyncio because i take the queries from a search engine (like google, duckduckgo,etc). But as far as i've seen this is not possible with flask as of now. (I am using python 3.10) and flask = 3.0.3
/r/flask
https://redd.it/1fnhdx2
Open-sourced FastAPI reference architecture
We just open sourced the reference architecture we use for FastAPI projects here.
Would love to discus different ideas and approaches as this is going to be a living document.
/r/Python
https://redd.it/1fnwxxy
How does Flask actually run in practice? Question about how the code actually executes when deployed.
I'm writing a simple app with Flask that I want to deploy and I'm confused about how this actually runs when it's been deployed. I have a strong feeling this is a case of me not knowing what questions I need to ask/"I don't know what I don't know."
I want to deploy this using Google App Engine because it seems very user-friendly and I'm a noob, and I found an excellent tutorial on how to deploy there and it seems like a perfect fit for my project.
I want the code within the for-loop to be run once per day, not when a user accesses the website - this is the issue that's leading me into confusion.
Here's my code and my questions are at the bottom. Thanks in advance for your help :)
from flask import Flask, rendertemplate
from getshows import getshows
import pandas as pd
from time import sleep
from datetime import datetime
app = Flask(name)
# declare the global variable for storing show info
/r/flask
https://redd.it/1fnpumr
Nanodjango - single file django with working models. Convert to a full project whenever you want.
https://simonwillison.net/2024/Sep/24/nanodjango/
/r/django
https://redd.it/1fp4bgg
changing log levels without deploying / restarting
I've been tinkering with logging in FastAPI and wanted to share something I've been working on. I like logging. I think it's key for debugging and monitoring, but I hate having to deploy / restart to adjust log levels . So, I set out to find a way to change logging levels on the fly.
I wrote a blog post detailing the approach: Dynamic Logging in FastAPI with Python the library is https://github.com/prefab-cloud/prefab-cloud-python
In a nutshell, I used a log filter that's dynamically configurable via Prefab's UI. This setup allows you to change logging levels for both Uvicorn and FastAPI without needing to restart the server. For me, this lets me turning on debug logging for a single user when investigating an issue and generally feel in control of my logging spend.
How are y'all handling logging in their Python applications:
Have you faced challenges / annoyance with adjusting log levels?
Do you just not log because logging is a smell?
What tools or methods have you found effective for managing logs in production?
Do you think this approach addresses a real need, or are there better solutions out there?
I'd love to get your feedback and hear about your experiences. My goal is
/r/Python
https://redd.it/1fpa5m3
A ML-powered scanner to identify the pattern for spam text and malicious sites.
Hello everyone,
I wanna share my machine learning platform that I build with the help of flask and react. The purpose of the platform is to make a prediction on url and text to classify as a malicious/spam or legitimate.
Cons: The model can classify into a unexpected False positive & False negative.
You can try: https://threat-recognator.vercel.app/
Source code: https://github.com/nordszamora/Threat-Recognator.git
I need your feedback & suggestion:)
/r/flask
https://redd.it/1fp3cgy
`streamable`: Stream-like manipulation of iterables
https://github.com/ebonnal/streamable
# What my project does
A `Stream[T]` decorates an `Iterable[T]` with a **fluent interface** enabling the **chaining of lazy operations**:
- **mapping** (concurrently)
- **flattening** (concurrently)
- **grouping** by key, by batch size, by time interval
- **filtering**
- **truncating**
- **catching** exceptions
- **throttling** the rate of iterations
- **observing** the progress of iterations
For more details and examples, check the [Operations section in the README](https://github.com/ebonnal/streamable?tab=readme-ov-file#-operations)
|||
|--|--|
|🔗 *Fluent*|chain methods!|
|🇹 *Typed*|**type-annotated** and [`mypy`](https://github.com/python/mypy)able|
|💤 *Lazy*|operations are **lazily evaluated** at iteration time|
|🔄 *Concurrent*|**thread**-based or `asyncio`-based concurrency|
|🛡️ *Robust*|unit-tested for **Python 3.7 to 3.12** with 100% coverage|
|🪶 *Minimalist*|`pip install streamable` with **no additional dependencies**|
---
# 1. install
```bash
pip install streamable
```
# 2. import
```python
from streamable import Stream
```
# 3. init
Instantiate a `Stream[T]` from an `Iterable[T]`.
```python
integers: Stream[int] = Stream(range(10))
```
# 4. operate
- `Stream`s are ***immutable***: applying an operation returns a new stream.
- Operations are ***lazy***: only evaluated at iteration time. See the [Operations section in the README](https://github.com/ebonnal/streamable?tab=readme-ov-file#-operations).
```python
inverses: Stream[float] = (
integers
.map(lambda n: round(1 / n, 2))
.catch(ZeroDivisionError)
)
```
# 5. iterate
- Iterate over a `Stream[T]` as you would over any other `Iterable[T]`.
- Source elements are ***processed on-the-fly***.
- collect it:
```python
>>> list(inverses)
[1.0, 0.5, 0.33, 0.25, 0.2, 0.17, 0.14, 0.12, 0.11]
>>> set(inverses)
{0.5, 1.0, 0.2, 0.33, 0.25, 0.17, 0.14, 0.12, 0.11}
```
- reduce it:
```python
>>> sum(integers)
2.82
>>> max(inverses)
1.0
>>> from functools import
/r/Python
https://redd.it/1fp38jd
Your Django Stack
Am thinking maybe: Django + HTMX + some css framework?
I need to be able to do some SPA stuff, but also I want the support of a modern CSS framework. I want to move as fast as possible, any suggestions?
/r/django
https://redd.it/1fp0au2
Wednesday Daily Thread: Beginner questions
# Weekly Thread: Beginner Questions 🐍
Welcome to our Beginner Questions thread! Whether you're new to Python or just looking to clarify some basics, this is the thread for you.
## How it Works:
1. Ask Anything: Feel free to ask any Python-related question. There are no bad questions here!
2. Community Support: Get answers and advice from the community.
3. Resource Sharing: Discover tutorials, articles, and beginner-friendly resources.
## Guidelines:
This thread is specifically for beginner questions. For more advanced queries, check out our [Advanced Questions Thread](#advanced-questions-thread-link).
## Recommended Resources:
If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.
## Example Questions:
1. What is the difference between a list and a tuple?
2. How do I read a CSV file in Python?
3. What are Python decorators and how do I use them?
4. How do I install a Python package using pip?
5. What is a virtual environment and why should I use one?
Let's help each other learn Python! 🌟
/r/Python
https://redd.it/1for63c
Converting Jupyter Notebooks to PDF: Exploring Your Options
Converting Jupyter notebooks to PDF can be quite handy, especially when you want to share your analyses with others who may not have Jupyter installed. However, navigating the various options for conversion can be a challenge. I've recently put together a blog post that reviews two popular methods: nbconvert
and Quarto.
In the post, I break down the setup process, features, and limitations of each method to help you decide which one might be the best fit for your needs.
### nbconvertnbconvert
is the official library from the Jupyter team that's designed for this task. It offers versatility by letting you convert notebooks into formats like PDF through two approaches: WebPDF and the traditional PDF via LaTeX.
The WebPDF method is simpler to set up, while the LaTeX route tends to yield higher-quality documents—ideal for complex mathematical content but comes with more installation hurdles.
### Quarto
On the other hand, Quarto provides a comprehensive solution for converting Jupyter notebooks into PDFs, but it does require a bit more effort to get everything working. It’s feature-rich and offers great customization, though the learning curve can be a bit steep.
In my experience, many users start out with nbconvert
using WebPDF for quick needs and then
/r/IPython
https://redd.it/1foi9da
I finally found an environment in which I feel comfortable
I have recently had "technology" crises, feeling useless for not wanting to focus on the JS environment (that is, node, react...) because it is a language that does not make me comfortable due to my programming preferences.
I was looking for alternatives to PHP, which is originally where I worked at a semi-expert level, and until now that I have migrated an app from that side to Flask, I have not felt comfortable and constantly feeling "oh, it makes sense" with each step I take. gave.
I have always loved Python for its guideline of simplicity, indentation (forcing yourself to do this makes changing hands much easier, as does returning to past projects, for readability) and I never knew how to focus my taste for the web with Python. I tried Django, and I will try it again, but it was very strict and it was difficult for me to understand its robustness and ideology, which on the other hand is the most correct but not the most free, since I like to structure myself instead of having it done to me at that level.
Finally I found Flask, I tried it and in a week I migrated my entire website (letterboxd style:
/r/flask
https://redd.it/1foqicx
Best way to approach this?
https://redd.it/1fomwps
@pythondaily
Flask at scale
I'm writing a Flask app in EdTech. We'll run into scaling issues. I was talking with a boutique agency who proclaimed Flask was/is a bad idea. Apparently we need to go MERN. The agency owner told me there are zero Flask webapps at scale in production. This sounded weird/biased... But now wondering if he has a point? I'm doing vanilla Flask with sass, Jinja and JS on the front. I run gunicorn and a postgresql with redis...
/r/flask
https://redd.it/1fon0um
Connor: Fast and fully local NLP file organizer that organizes files based on their textual content
What **Connor** Does
Connor works locally on your computer using a pre-trained NLP model sentence-transformers/paraphrase-MiniLM-L6-v2 to understand the meaning of the data and calculate the cosine similarity between files. The folders are appropriately named using topic modeling through the Latent Dirichlet Allocation (LDA) technique.
Example of before and after running the app within a folder with bunch of files. you can see the tree structure for the same (the screenshot of the tree structure is from the app itself. It gets displayed while using the cli too).
Links: Repo and PyPI
End-user (you) can:
1. Organize files within a selected folder or manually uploaded files (uploading files is only supported for GUI).
2. Organize text-based files (.docx, .txt, .pdf, etc.) using NLP based on their content.
Customization Options:
1. Similarity Threshold: Allows yous to choose a similarity percentage threshold for grouping similar files.
2. Reading Word Limit: You can to set a limit on the number of words read from file content.
3. Folder Name Word Limit: You can specify a maximum number of words allowed in the created folder names.
Target Audience
Anyone who has a bunch of text-based files they need to organize based on content quickly.
Comparison
Most file organizer sort the files based on their extension.
/r/Python
https://redd.it/1fohm7y
Django-Routify v0.2.5 stable release with Poetry support
**Django-Routify** is a package for simple routing Views in the classic Django framework.
Downloads last week on PyPi: 400+
Stars in GitHub: 8
With Django-Routify package you no longer have to manually register your views in urlpatterns
using django.urls.path function.
Django-Routify can help you to easily register your views using Router class and his @Router.route(...)
decorator.
Also you can set auto_trailing_slash to True value when you're initializing your Router and can write your url_path similar to Flask, FastAPI etc.
If auto_trailing_slash
is True
then url_path which will be equal to '/hello-world'
will be translated to classic Django url rule - 'hello-world/'
.
**Detail example**
Registration views with Router
Including router's pathes to urlpatterns
/r/django
https://redd.it/1fodju5
Help with code optimisation for my DigitalOcean droplet
Hello, I am quite new to Flask and all, and currently I made a Flask App that OCR's and Parses some information for me. For OCR I am using easyocr and for parsing I am using openai API, I deployed it by the 1gb RAM, basic droplet plan from DigitalOcean with Nginx and Gunicorn, but even without curl post a single thing it's already on Max Memory and CPU usage.
I'll paste my code down here and any suggestions would be appreciated, if it's better to upgrade my DO plan or if by optimizing the existing code might be enough. Thanks in advance:
# Initialize the Flask app
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = 'uploads'
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB
# Set up rate limiting
limiter = Limiter(
get_remote_address,
app=app,
default_limits=["1000 per day", "100 per hour"]
)
#
/r/flask
https://redd.it/1fnx5eu
I just made my own game!
Rock 🪨 Paper 📄 Scissors ✂️
It’s for a class I’m taking… and I built in a loop where the game will continue until it completes a best of five and then exits automatically!!
I’m so excited. Haha
/r/Python
https://redd.it/1fnzvwg
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/1fnz87u