1102
Daily Python News Question, Tips and Tricks, Best Practices on Python Programming Language Find more reddit channels over at @r_channels
Whatever happened to "explicit is better than implicit"?
I'm making an app with FastAPI and PyTest, and it seems like everything relies on implicit magic to get things done.
With PyTest, it magically rewrites the bytecode so that you can use the built in assert statement instead of custom methods. This is all fine until you try and use a helper method that contains asserts and now it gets the line numbers wrong, or you want to make a module of shared testing methods which won't get their bytecode rewritten unless you remember to ask pytest to specifically rewrite that module as well.
Another thing with PyTest is that it creates test classes implicitly, and calls test methods implicitly, so the only way you can inject dependencies like mock databases and the like is through fixtures. Fixtures are resolved implicitly by looking for something in the scope with a matching name. So you need to find somewhere at global scope where you need to stick your test-only dependencies and somehow switch off the production-only dependencies.
FastAPI is similar. It has 'magic' dependencies which it will try and resolve based on the identifier name when the path function is called, meaning that if those dependencies should be configurable, then you need to
/r/Python
https://redd.it/1efrusl
Discussion Non compute hungry research publications that you really liked in the recent years?
There are several pieces of fantastic works happening all across the industry and academia. But greater the hype around a work more resource/compute heavy it generally is.
What about some works done in academia/industry/independently by a small group (or single author) that is really fundamental or impactful, yet required very little compute (a single or double GPU or sometimes even CPU)?
Which works do you have in mind and why do you think they stand out?
/r/MachineLearning
https://redd.it/1efmmnn
Is my portfolio good enough to get an entry-level position?
Is my portfolio good enough to get an entry-level position? I've been trying to get an entry-level position for about 4 to 5 months, but with no luck. If you guys have some time, can you guys check out my portfolio site and give me some feedback, please? Here is the portfolio site at Pythonanywhere, and here is my resume on Google Drive. Any feedback will be greatly appreciated. Thank you.
/r/djangolearning
https://redd.it/1efo7ol
How to Edit DOCX Documents on the Fly Using Flask?
Hi everyone,
I'm currently working on a Flask application and need to edit DOCX format documents on the fly. Has anyone done this before? If so, could you point me to any source code or libraries that can help with this?
Thanks in advance! ☺️
/r/flask
https://redd.it/1efhsde
🐶 immunipy: Find vulnerable dependencies in your Python projects
# What My Project Does
I've created immunipy a Python SCA tool that acts as a watchdog, keeping an eye out for security vulnerabilities and reporting them promptly, written in Rust. immunipy will scan your requirements.txt or poetry.lock files and search for existing vulnerabilities in your dependencies, if any of your dependencies is reported as vulnerable then you will get the information, such as: package, version, fixed version (if exists), vuln id, aliases and the location.
It's easy to use and is really fast, all the vulnerabilities are reported in real time.
# Target Audience
I think that immunipy is useful for every project, specially the production ready ones, due that every time that you run it you will get an instant scan of your dependencies.
# Comparison
It's easy to use, just pip install immunipy and you can run it! Also, you can add it in your CI/CD pipeline and run it regularly, this is useful if you want to keep your projects free of vulnerable dependencies.
/r/Python
https://redd.it/1ef02hg
Do you feel like Python's type hinting got "stable"?
Basically the title.
I was reading through [https://docs.python.org/3.13/library/typing.html](https://docs.python.org/3.13/library/typing.html) and noticed that quite a lot happened over the last few years. Doing a text search for `deprecated since version x` with `x` being one of `3.9` to `3.13` I found these according numbers of occurrences:
* `3.9` -> 37
* `3.10` -> 0
* `3.11` -> 1
* `3.12` -> 3
* `3.13` -> 5
Which makes me question how "stable" Python type hinting has become these days. Do you think that there are still rough edges that need major overhauls or is Python 3.13 actually mostly where we need it to be in order to productively use static typing?
/r/Python
https://redd.it/1ef1ym0
Django boilerplate
http://www.djangoship.com
/r/djangolearning
https://redd.it/1edpjxn
I created a command line tool using Python and Ollama to automatically create PRs on GitHub
Hey everybody!
# What My Project Does
I created this command line tool called jit that analyses your diffs and commit messages to generate a pull request description (based on your project's PR template if it has one) and then creates a pull request on GitHub (draft by default) using GitHub CLI.
# Target Audience
This tool is meant for developers that use GitHub. Mostly meant for hobby projects, but if you want you can use it on a production project (for work/clients) because:
* it utilizes a local LLM (no sharing your code to 3rd party APIs)
* The pull requests follow the template specified in your repository
* The pull request is marked as draft by default
# Comparison
I have not found any cli tools that do this in this manner. But I think GitHub's Copilot for Pull Requests will certainly generate better descriptions: [https://githubnext.com/projects/copilot-for-pull-requests/](https://githubnext.com/projects/copilot-for-pull-requests/)
# More about me and jit
I am predominantly a full-stack web developer (React, NestJS) for my job, but I love playing around with Python and other things. I have developed this using Python and Ollama with llama3.
I have been using jit almost every day, for about a month now, and it has made such a big difference in my day-to-day as a
/r/Python
https://redd.it/1eehm1a
What package do you use for DRF authentication?
title
/r/django
https://redd.it/1eevy1v
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/1eellgu
My first flask app, got popular on Instagram (2m views, 50k+ users) what do you all think?
https://redd.it/1eelt6t
@pythondaily
Giving the option to the user of allowing concurrent login
Hi there,
i am new to django. I implemented the disabling of concurrent login on the same account using different devices by the use of sessions.
So i thought of why not letting the user itself decide if he wants to allow concurrent login or not.
I tried searching for solutions to this but my search was fruitless.
Any help is appreciated !
/r/djangolearning
https://redd.it/1edpig2
Cool services you've made with FastAPI
Hey Everyone, I was just wondering what kind of cool projects people have made using FastAPI? What did you like about the framework and what did you dislike? Is FastAPI used a lot with ML models or computer vision services. Would love to hear your experiences and projects!
/r/Python
https://redd.it/1eeeoti
Cli scraper Dedicated to Alibaba v0.2.0
I have already showcased this package project. I just want to inform you all about my package evolution.
What My Project Does ?
Gathering data from Alibaba based on keywords provided by users and save them in database MySQL/sqlite
Targeted Audience
Thoses who want to build an ALIBABA datasets for analysis.
Comparisons
Asynchronous request to handle many page results.
New features:
Set your bright data api key to use async mode.
Export your scraped data to csv file (you must to have an updated sqlite file which will be converted to csv).
Future enhancements:
Add a rag to chat with your database and let him do your SQL query for you .
This will probably the least feature that in planning to add to this project.
Maybe I will make it croos plateform. Cause now it's only works on windows.
Still looking for testers an reviews and suggestions to improve.
Do you think this package have a potential to grow ? Is it useful ? If not how to make more interesting ?
Here is the repo : https://github.com/poneoneo/Alibaba-CLI-Scrapper
Also excuse me for orthography errors on 'scraper'
I'm find a way to rename my package but its seems to be hard and risky and I dont want to
/r/Python
https://redd.it/1ee79hd
system design mock interviews
Where should i take mock interviews on system design so i can learn more and improve myself
/r/flask
https://redd.it/1ee551q
Django and Vue/Vite
hey yall!
So I'm trying to figure out how to structure a new django/vue project, i want the vue project to live inside the django project. i want to have my root django url point to the vue build files, i also want to be able to use the vite dev server as normal. From what i can tell, this means I need to get vite to proxy to django (not even sure that's supposed to mean).
im a little lost and i cannot find any good docs/resources on this topic, if anyone has any experience with this type of setup - pls help me out. if you have any good resources please send them my way
thanks
/r/django
https://redd.it/1efqj3z
UXsim 1.4.0 released, with a ~20x speedup over 1.3.0 for large scale traffic scenarios
Version 1.4.0 of UXsim is released, which optimized two shortest path search functions by using better suited data formats (matrices where possible) and vectorization, for a \~20x speedup over 1.3.0. See:
[https://github.com/toruseo/UXsim/issues/53](https://github.com/toruseo/UXsim/issues/53)
https://github.com/toruseo/UXsim/issues/84
UXsim 1.4.0 highlights
Significant speed up for large-scale scenario
In combination with the previous v1.3.1 update, we have optimized the shortest path search and related functions. As a result, the calculation speed for large scenarios (e.g., those with 1000+ links) has increased by 10 to 100 times.
Implement new scenario writing/reading functions `W.save_scenario` and `W.load_scenario`.
As a demonstration of these updates, we have added demo in Chicago-Sketch dataset with 1 million vehicles.
UXsim
UXsim is a free, open-source macroscopic and mesoscopic network traffic flow simulator written in Python. It simulates the movements of car travelers and traffic congestion in road networks. It is suitable for simulating large-scale (e.g., city-scale) traffic phenomena. UXsim is especially useful for scientific and educational purposes because of its simple, lightweight, and customizable features, but users are free to use UXsim for any purpose.
/r/Python
https://redd.it/1efnuau
Spotify Route isnt working
I have been working on my Spotify Player Project with React and Flask when all of a sudden my route for playlist retrieval stops working and all of my other routes remain fine. I didn't touch it or anything it just broke all of a sudden if anyone could offer any help it would be much appreciated. https://github.com/00fff/SoundLink
/r/flask
https://redd.it/1efcecy
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/1eff15m
Is django (+ htmx) the right thing for me?
Hi everybody!
I'm coming from the data science python path. Long time ago I learned html and css - builded some static websites while studying but never got really into it - a little bit of bootstrap, jquery or wordpress on top was all I needed.
Now I want to build a website where different users can access different dashboards. After processing the data from different sources, it will be stored in a postgres database from where I want to access the data with django and build some dashboards for different use cases and users.
Furthermore I want to create some questionnaires where users have to log in and answer in predefined intervalls and store these values in my database too.
Most of my visualizations I do with matplotlib, seaborn and vega-altair in streamlit apps for now, but I don't like being limited by streamlit anymore. And my projects are getting bigger.
So I am searching a framework to learn which meets my needs.
Can you recommend django + htmx to me in good conscience?
Should I take the effort and learn a javascript framework?
Thank you for your thoughts!
/r/django
https://redd.it/1ef5zyw
How long would it take to switch from SQLite to SQL?
Going from non prod to prod soon.
Also, anyone know how long it takes to implement google login? So users can click sign in with google etc
Thanks!!
(I am on azure)
/r/django
https://redd.it/1eexzx3
D Simple Questions Thread
Please post your questions here instead of creating a new thread. Encourage others who create new posts for questions to post here instead!
Thread will stay alive until next one so keep posting after the date in the title.
Thanks to everyone for answering questions in the previous thread!
/r/MachineLearning
https://redd.it/1ee9dra
Thoughts on using Figma/Webflow with FastAPI
I dislike working on the front-end. I plan to use Figma exports or Webflow for the front end of my project. Is it sufficient to use FastAPI with Jinja templates for optimal performance?
/r/Python
https://redd.it/1eeqqtq
What benefit do PostgreSQL connection pools offer over CONNMAXAGE ?
Django 5.1 has psycopg connection pool support: https://docs.djangoproject.com/en/5.1/releases/5.1/#postgresql-connection-pools
How exactly is this different from the existing CONNMAXAGE setting which I assumed was using persistent connection pools already.
/r/django
https://redd.it/1eet0bl
Starting a new django job tomorrow
what should I know? what its a must to study?
context: I have only basic notions of this framework, like already build a simple CRUD and thats all. even tho the company selected me because because, I dont really know why but they liked me, but its the only tech of the company Im not very familiar. Im very nervous
/r/django
https://redd.it/1eepb7o
Running Background Tasks in Production (Azure Web App)
have a Django backend project in which i use django-background-tasks to send scheduled emails in the background , in development environment i need a second terminal running the command : python manage.py process_tasks
now for the production environment i hosted the backend on azure web app and tried the approach of
supervisor (http://supervisord.org/configuration.html) creating a conf file that gets executed on the server but for now i have to manually connect to the server via ssh and run this file the whole point of using the module is to automate this part yet it doesn't seem to work
https://preview.redd.it/sb0urf0232fd1.png?width=833&format=png&auto=webp&s=076055d0f2ad8ea6f9786604aa31d031ef2f7528
also tried to add to the deployment workflow this part :
- name: Set up Supervisor
run: |
# Install Supervisor
pip install supervisor
# Create logs directory if it doesn't exist
mkdir -p logs
chmod 666 logs
# Start Supervisor
/r/djangolearning
https://redd.it/1edfdu1
I built an e-commerce site
I built an e-commerce site. If you guys have some spare time, can you guys test out my site and give me some feedback, please? Any feedback will be greatly appreciated. Thank you very much. Here is the site at Pythonanywhere Here is the username and password: new_user1, testuser123
/r/djangolearning
https://redd.it/1ee9cwd
Django seems like a full-stack framework as opposed to a back-end framework, Is it right for me if I'm looking for a back-end framework?
Title basically sums it up. I wanna get into Django but the tutorials I've seen so far make it seem like it's more of a full-stack framework, and this is making it really difficult for me to know what I'm learning?
I plan on using it with frameworks like React, HTML, CSS, Next.js and more.
This might be a dumb question but I really need to know. Thanks!
/r/django
https://redd.it/1eeai8t
How to pass context to render_template?
Hi,
I use Flask with htmx. In case its a normal request, I call `render_template` as usual. But in case the request is coming from htmx, I want to return only a part of the template.
I've created two templates each time I need to return either or.
```jinja2
# login.html
{% extends "base.html" %}
{% block main %}
{% include "login_form.html" %}
{% endblock main %}
```
```jinja2
# login_form.html
<form>
...
</form>
```
In my route I can easily do:
```python
from flask import render_template
if htmx: template = "login_form.html"
else: template = "login.html"
return render_template(template, ...)
```
Now I came across [Jinja2-Fragments](https://github.com/sponsfreixes/jinja2-fragments) which allows to render only individual blocks of a template. That means I wouldn't have to create the wrapper templates, which would be desirable.
Problem is, I now end up with something like:
```python
from flask import render_template
from jinja2_fragments.flask import render_block
if htmx: return render_block("login.html", "main", ...)
else: return render_template("login.html", ...)
```
Okay, cool. But if I pass n variables as context to the template, I have to repeat those in both function calls. Not exactly DRY.
I could create a dict like `vars = {"var1": var1, "var2": var2, ...}` and pass that to both function calls, but then in the template I need to prefix all variables with `vars.var1` which is not so pretty either.
Is
/r/flask
https://redd.it/1eebend
developing a project management interactive dashboard
Greetings,
I'm considering to develop an interactive dashboard that allows the below features
- allows orchestrating tasks between different teams, along with the ability to track the progress
- generate automated reports based on a predefined template
- has an interactive dashboard so I can see the number of tasks per X time and their status
- can be connected to Excel sheet as an input source
would you please advice on what libraries should I use and whether this work is a daunting task and I should go for a vendor-tool? I know the answer would depend on the details of my context, however I'd like to have a general estimation
thanks in advance
/r/Python
https://redd.it/1ee51yz