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
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
Survey Paper over Neuro-Symbolic AI with Knowledge Graphs
https://arxiv.org/pdf/2302.07200

/r/MachineLearning
https://redd.it/1egke1v
PyPy the unknown Hero.

/r/django
https://redd.it/1egfdmf
Error while running the falsk app on development server

When I am adding Csrf to my Flask app and running the app on a development server
I am getting this error: {"error":"Port could not be cast to integer value as '4444,172.233.209.24'"} Can anyone help?

/r/flask
https://redd.it/1egk8x0
Mulitnomial Logistic model but for mixed effects

Hello, I wanted some suggestions on how to implement a mixed effects multinomial logistic regression model for my data.

A little context on my data- I am trying to predict how people categorize an object (4 possible options here - categorical) based on 2 types of inputs (both inputs are categorical variables with 4 different categories each).

Initially, I thought a normal multinomial logit model would work, but it was brought to my attention that I had repeated measures in my data. Which had me looking up mixed effects models.

But, mixed effects multinomial logistic regression for categorical variables sounds....complicated.

Any suggestions on how to implement this (packages/code samples etc) or any better/easier alternatives for this type of data, would be welcome.



/r/pystats
https://redd.it/1egqxsw
Component Library Solution: django-lookbook

Hi, I'd like to share an Django component library solution **django-lookbook** here.

I want something like "StoryBook" to Django but existing solutions of the Django community did not make me satisfied, so I built it myself.

Below are some features you might be interested:

## Pluggable app

It is a classic Django pluggable app which can be integrated with your Django project within minutes.

No matter your Django project use jQuery, Vanilla JS, Alpine.js, HTMX, Stimulus.js or other frontend solution, **it can work with them all**.

## Preview

Let's say you have a custom `Modal` component in your Django project, built with `Alpine.js`, and it supports different modal size `small`, `medium`, `large` based on the `Tailwind CSS`

How to make other team mates quickly understand the usage? Instead of digging the Django templates?

We can create three previews for the Modal and developers can directly check the final result in the component library.


class ModalComponentPreview:

def small_modal():

def medium_modal():

def large_modal():

As you can see, we can create previews and put them in one Python class, and the syntax is very similar with writing unittests

/r/django
https://redd.it/1egi8z3
D Is Unlimited Context Length really possible?: "Unlimiformer" author discusses NeurIPS paper Friday

Is Unlimited Context Length really possible? At what cost?

Amanda Bertsch, author of 2023 NeurIPS paper Unlimiformer, will describe the architecture and take questions at this Friday's Oxen.ai Paper Club.

Greg Schoeninger u/FallMindless3563, Oxen CEO and Master of Plain Speak, will help interp the concept and relate it to other papers we have reviewed.

Call: https://oxen.ai/community

The trick asserted to make Unlimited Context Length possible: Offload the cross attention calc to a K-Nearest Neighbors (K-NN) index.

I tweeted someone's clever animation of K-NN here: https://x.com/mustafarrag/status/1817647917059944474

Paper: https://arxiv.org/abs/2305.01625

Greg, I'll reply with my first 5 questions. I've only read the abstract so far.

/r/MachineLearning
https://redd.it/1egqitt
Help for a Beginner

I am a Django learner made few websites now and i dont know the react or any other i dont understand when can i start for job hunting can anyone recommend what more skills do i need ...

/r/djangolearning
https://redd.it/1egvq2c
Best Resourse to learn Flask api?

i am asking for a tutorial for flask api which is the best way to learn it

/r/flask
https://redd.it/1eed9y8