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
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
🐶 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
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
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
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
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
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
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
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
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
D NeurIPS 2024 Paper Reviews

NeurIPS 2024 paper reviews are supposed to be released today. I thought to create a discussion thread for us to discuss any issue/complain/celebration or anything else.

There is so much noise in the reviews every year. Some good work that the authors are proud of might get a low score because of the noisy system, given that NeurIPS is growing so large these years. We should keep in mind that the work is still valuable no matter what the score is.

/r/MachineLearning
https://redd.it/1efscr2
ArchiveFile: Unified interface for tar, zip, sevenzip, and rar files

PREVIOUS POST

#### What My Project Does
archivefile is a wrapper around `tarfile`, `zipfile`, `py7zr`, and `rarfile`.
The above libraries are excellent when you are dealing with a single archive format but things quickly get annoying when you have a bunch of mixed archives such as .zip, .7z, .cbr, .tar.gz, etc because each library has a slightly different syntax and quirks which you need to deal with.
archivefile wraps the common methods from the above libraries to provide a unified interface that takes care of said differences under the hood. However, it's not as powerful as the libraries it wraps due to lack of support for features that are unique to a specific archive format and library.

#### Target audience
Anyone who's using python to deal with different archive formats

#### Comparison
- ZipFile, TarFile, RarFile, and py7zr - These are libraries that mine wraps since each of them can only deal with a single archive format
- shutil - Shutil can only deal with zipfile and tarfile and only allows full packing or full extraction.
- patool - Excellent library that deals with wider range of formats than mine but in doing so it provides less granular control over each
ArchiveFile falls somewhere between the powerful dedicated library and the

/r/Python
https://redd.it/1eg35qy
Frustrating series of failed deployments — suggestions?

I’m setting up a simple web app that uses Chroma (and thus requires an up to date sqlite3), and has some files that are necessarily over 300mb.

These two factors have caused a lot of trouble in finding a suitable, free deployment website as many of them don’t have the latest sqlite3 version and/or do not support file uploads of >100mb.

What services do you guys suggest?


/r/flask
https://redd.it/1efvjn8
Advice on Usage Limited Subscription Model Using Stripe Payments 🤑

What would be the best way to implement this, I feel that it is a fairly common business model but can't find any resources online. I am using stripe payments.

I believe I would require users to sign up immediately so I can track their usage.
I plan on offering a free trial e.g. 10 uses of my SaaS (each is an openai call).
Then if the user wants to continue using, they have to purchase a subscription.
When subscribed they have a maximum usage e.g. 100 uses per month.

Alternatively, is there a similar business model that I could implement with stripe which I can't be exploited by lots of openai api calls which could get expensive?

My current setup:

Flask backend
OpenAI API for summarization
Simple HTML/CSS/JS frontend
Stripe for payments

Any advice, resources, or code examples would be greatly appreciated. Thanks in advance!

/r/flask
https://redd.it/1eg0w49
Flask for Campus Placements

Hey guys! I am a final-year college student and have worked on multiple Flask applications in the past. My college would have companies visiting the campus for placements in a few days. Based on Flask practice and learning, I feel petrified regarding what to expect from the interviewers and what to focus on. I would be extremely grateful if some suggestions based on / regardless of my projects could be given.

Also, I feel as if I am in a fix as I love Flask and wish to work on new projects, but then considering the time required to map out a project seems too irrational, so should I work on improving pre-existing projects or work on some basic new ones exploring more into the domain? Kindly let me know! Cheers!

GitHub for reference: https://github.com/RampageousRJ

P.S. - Please don't mind my deployed projects, have deployed on render which makes them painfully slow

/r/flask
https://redd.it/1ef5bqi
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/1eg8uu9
D Monthly Who's Hiring and Who wants to be Hired?

For Job Postings please use this template

>Hiring: [Location\], Salary:[\], [Remote | Relocation\], [Full Time | Contract | Part Time\] and [Brief overview, what you're looking for\]

For Those looking for jobs please use this template

>Want to be Hired: [Location\], Salary Expectation:[\], [Remote | Relocation\], [Full Time | Contract | Part Time\] Resume: [Link to resume\] and [Brief overview, what you're looking for\]

​

Please remember that this community is geared towards those with experience.

/r/MachineLearning
https://redd.it/1egc1um
What are some unusual but useful Python libraries you've discovered?

Hey everyone! I'm always on the lookout for new and interesting Python libraries that might not be well-known but are incredibly useful. Recently, I stumbled upon Rich for beautiful console output and Pydantic for data validation, which have been game-changers for my projects. What are some of the lesser-known libraries you've discovered that you think more people should know about? Share your favorites and how you use them!

/r/Python
https://redd.it/1egg99j
Claude playing nicer with django

If you use claude / chatgpt for working on django code, you probably already bumped into the problem that claude will guess the model fields for the models it can't see - producing crappy results.

To get around it, make a management command that describes models accross one or more apps, printing the description to console in a dense format.

Now claude doesn't make mistakes when he is referencing other models. Just ask claude for a list of the models he needs more information about before he starts working, copy the list into the management command and get a console log of the description in an dense format.

I'm interested in any other tricks people have to make claude or chatgpt play better with django.

Instructions and code...

Use it like this:

python manage.py describe_models model1 model2 model3

or

python manage.py describe_models app

or

python manage.py describe_models --all

Here is the management command:

#describemodels.py

from django.core.management.base import BaseCommand
from django.apps import apps
from django.db import models

MAX
CHOICES = 10

class Command(BaseCommand):
    help = 'Print schema of

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