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
Friday Daily Thread: r/Python Meta and Free-Talk Fridays

# Weekly Thread: Meta Discussions and Free Talk Friday πŸŽ™οΈ

Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!

## How it Works:

1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.

## Guidelines:

All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.

## Example Topics:

1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.

Let's keep the conversation going. Happy discussing! 🌟

/r/Python
https://redd.it/1gbh5k3
How do Session IDs work?

New to Flask. What I know is there are 2 ways to implement sessions: client-side and server-side. The former uses the default flask session (from flask import session) while the later uses a library called Flask-Session (need to add from flask_session import Session) .

I read both flask and Flask-Session docs, I still can't wrap my head around how sessions really work. The default session will turn your session data dict into cookie, then salt it, add signature, encode in base64. The Flask-Session's session still uses cookie, but it only contains the session identifier.

Session identifier is for identifying users, duh. But I have some questions:

1. Since Flask-Session is just extension of the deault session, do both of them implement the same approach to assigning session ID?
2. Where can I find the session IDs of the users?
3. Is it going to reset after closing the tab? browser?
4. When I do session.clear(), is everything cleared, including the session ID?

Again, sorry for asking these dumb questions. Any help would be appreciated. Thanks!

/r/flask
https://redd.it/1gb6kzq
Ethics concerns and Google D

Apologies if this isn't the right place for this facet of ML, but it didn't seem against the rules.

I recently participated in an Alphabet human data research study used to evaluate AI agents and models.

Without going further into the details, the structure of the study felt very ethically questionable. The agreement said if there were any concerns, to contact HuBREC, human behavioural research ethics committee.

However, their email provided in the agreement hubrec@google.com does not exist and I have no point of contact at all short of looking up past academic talks and cold emailing people.

I am having a lot of difficulty searching for next steps as there is no other contact information I can use except for that email. I do know that Google has fired AI ethics researchers in recent memory, and that this topic never seems to be taken seriously. It seems like a bad look for an on-going study to point you to a committee that doesn't seem to exist.

/r/MachineLearning
https://redd.it/1gbblsc
need help for django with aws s3 bucket

i have a website with backend django (digital ocean ) (dockerize the app )hosted in the backend and vite react project in s3 bucket i keep getting this error , I'm sure settings,py file is correct, i tried all of

CORSALLOWEDORIGINS =
    'http://myappsfrontends.s3-website-us-east-1.amazonaws.com',

ALLOWEDHOSTS = ['*']


CORS
ORIGINALLOWALL = True

and setup the cors middleware in the right order

i spent week searching all of stackoverflow and reddit for solutions and nothing works, so this is the last solution

(i'm using aws just to learn some cloud to increase my skills )

cors policy in aws

[

{

"AllowedHeaders": [

"*"

\],

"AllowedMethods": [

"GET",

"PUT",

"POST",

"DELETE"

\],

"AllowedOrigins": [

"http://myappsfrontends.s3-website-us-east-1.amazonaws.com"

\],

"ExposeHeaders": [

"Content-Range",

"Content-Length",

"ETag"

\],

"MaxAgeSeconds": 3000

}

\]

https://preview.redd.it/hfa5s7c3mrwd1.png?width=1887&format=png&auto=webp&s=739741d0e97e6c6ed2123e09e04616f5d5c1d517



/r/djangolearning
https://redd.it/1gbcw7e
Manim : package for maths animation

I recently explored Manim, an open-sourced python package for generating animated videos for explaining maths. It includes animations for shapes, equations, codes, graphs, etc. The repo is trending on GitHub as well. The demo also looks very impressive. Check it out here : https://youtu.be/QciJxVjF4M4?si=Bk_gU4Tj5f6gPpiq

/r/Python
https://redd.it/1gbldgk
PyGenTree: A Simple Yet Powerful Python Package for Generating ASCII Directory Trees

# What My Project Does

PyGenTree is a Python package that generates ASCII tree representations of directory structures. It's a simple command-line tool that allows you to visualize the structure of your project or any directory on your system. With PyGenTree, you can easily document your project's structure, quickly understand unfamiliar codebases, or generate directory trees for README files.

# Target Audience

PyGenTree is designed for developers, programmers, and anyone who works with directory structures on a regular basis. It's a useful tool for:

* Developers who want to document their project's structure
* Programmers who need to quickly understand unfamiliar codebases
* DevOps teams who want to visualize directory structures for deployment or debugging purposes
* Anyone who wants to generate directory trees for README files or documentation purposes

# Comparison

There are existing tools that generate directory trees, such as `tree` on Linux and `dir` on Windows. There are online ASCII Tree Generators where you have to manually add files and directories. There are some python packages similar to this, but I tried to combine all the useful features from these alternatives and create this one. PyGenTree differs from these alternatives in several ways:

* **Cross-platform compatibility**: PyGenTree works on Windows, macOS, and Linux, making it a great

/r/Python
https://redd.it/1gbnnbu
Help Needed: Scaling My RAG-Based LLM Browser Extension

Hi everyone,

I've developed a browser extension using a Retrieval-Augmented Generation (RAG) model that works great with PDF files stored locally on my machine, with server running on flask. Now, I’m looking to scale this solution for broader use and could really use some advice from experts here as I’m new to deployment.

Here are my key questions:

1. Secured Authorization System: What’s the best approach to create a secure authorization system that adheres to modern security standards?
2. Secure Data Storage: I plan to let users upload their data (primarily PDFs for now). This data needs to be encrypted and protected against security threats. What’s the recommended way to store this data securely while keeping these threats in mind?
3. Affordable LLM Service: (Not a priority but still relevant) Right now, I’m using the gemini-1.5-flash API with my own key. I’m looking for suggestions on any free or low-cost LLM services I can use at scale.

Any insights, advice, or pointers would be greatly appreciated! Thanks in advance!

/r/flask
https://redd.it/1gav6h7
This is now valid syntax in Python 3.13!

There are a [few changes that didn't get much attention](https://www.bitecode.dev/p/python-313-what-didnt-make-the-headlines) in the last releases, and one of them is that comprehensions and lambdas can now be used in annotations (the place where you put type hints).

As the article mentions, this came from a bug tickets that requested this to work:

class name_2[*name_5, name_3: int]:
(name_3 := name_4)

class name_4[name_5: name_5]((name_4 for name_5 in name_0 if name_3), name_2 if name_3 else name_0):
pass


Here we have a walrus, unpacking, type vars and a comprehension all in one. I tried it in 3.13 (you gotta create a few variables), and yes, it is now valid syntax.

I don't think I have any use for it (except the typevar, it's pretty sweet), but I pity the person that will have to read that one day in a real code base :)






/r/Python
https://redd.it/1gbu1g0
Single line turns the dataclass into a GUI/TUI & CLI application

I've been annoyed for years of the overhead you get when building a user interface. It's easy to write a useful script but to put there CLI flags or a GUI window adds too much code. I've been crawling many times to find a library that handles this without burying me under tons of tutorials.

Last six months I spent doing research and developing a project that requires low to none skills to produce a full app out of nowhere. Unlike alternatives, mininterface requires almost nothing, no code modification at all, no learning. Just use a standard dataclass (or a pydantic model, attrs) to store the configuration and you get (1) CLI / config file parsing and (2) useful dialogs to be used in your app.

I've used this already for several projects in my company and I promise I won't release a new Python project without this ever again. I published it only last month and have presented it on two conferences so far – it's still new. If you are a developer, you are the target audience. What do you think, is the interface intuitive enough? Should I rename a method or something now while the project is still a

/r/Python
https://redd.it/1gbprvv
Posting 2 - the HTTP client TUI, now supports Python scripting, custom keymaps, and more!

Hello r/Python

I'm excited to share Posting 2 with you all!

# What My Project Does

Posting is a terminal based app for interacting with HTTP APIs. It's a bit like Postman, Insomnia, Bruno, etc.

Posting is a snappy and keyboard-centric UI, built for power users but still approachable for those who aren't familiar with terminal apps.

You can build up requests using the UI, send them and interact with the response, and save the requests to disk as simple YAML files for easy sharing, version control, and re-use.

Posting offers efficient "jump mode" navigation which allows you to jump across the UI quickly with the keyboard, extensive autocompletion, themes, integration with other tools (e.g. quickly swap into Vim to edit a request body and swap back), and a bunch more quality-of-life features to let you move fast.

It's written entirely in Python using the Textual framework, and also uses great Python tools like httpx and Pydantic.

With the new release of version 2, you can now run Python code before and after requests! This lets you perform setup and teardown (e.g. logging, setting variables, tokens, etc.).

This version also introduces the (frequently requested) ability to change your keymap for a variety of actions. This will hopefully prevent keybind

/r/Python
https://redd.it/1gc0tiu
Webapp hosting resources

I going develop a webapp in django that can to post image and text. Get registion form data from user. Now don't know how much Hosting resource like cpu, ram, bandwidth for 100 to 500 user . Also tell some free and paid webapp Hosting service in low cost for startup

/r/djangolearning
https://redd.it/1gc1xh0
Pixel-map: A Python CLI tool for plotting geo files in the terminal

# What My Project Does

[**Pixel-map**](https://github.com/RaczeQ/pixel-map) displays geo data in the terminal. It can be used to quickly look into the geospatial data without opening generating HTML maps or using tools like [kepler.gl](https://kepler.gl/).

GitHub: [https://github.com/RaczeQ/pixel-map](https://github.com/RaczeQ/pixel-map)

PyPI: [https://pypi.org/project/pixel-map/](https://pypi.org/project/pixel-map/)

Since I can't embed images in this post, I can only show you the Black and White modes of the library.

ASCII renderer `ascii-bw`:

$ pixel-map arc-de-triomphe.parquet -r ascii-bw --width 82 --height 43 --no-bg
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━ arc-de-triomphe.parquet ━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                               ┃
┃                                                                               ┃
┃                                                @@L_  jr                

/r/Python
https://redd.it/1gc3a1k
Anyone working on or with a great but little-known test framework?

If you're developing or enjoying a less popular testing framework with Python, I'd love to hear about it!

I don't love pytest, some of its complexities, tall decorator stacks, and function naming conventions.

I do love ward, with its unusual non-function-naming test names, and unusual defining-functions-in-loops for parameterization. Unfortunately it's now archived, as the developer is busy at Textualize.

Maintaining it myself is probably beyond my abilities and bandwidth, so I plan to migrate some projects to pytest soon, but wanted to check if anyone can show off some fun alternative with something special to offer.

Thanks for any contribution!

/r/Python
https://redd.it/1gbxrho
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/1gc8ekm
one year of peer review D

My manuscript has been in peer review for 10 and half months to ieee. The last time I contacted the journal to ask about the situation, they told me that they were looking for reviewers. It's been two months since the last email. I have no response from the journal. The manuscript is still in peer review. My question is, is it normal for it to take so long? Is this a good sign that my paper will be accepted? If it were the opposite, would they not hesitate to reject it directly or is it normal for it to take so long and then reject it in the end? The paper is about natural language peocessing

/r/MachineLearning
https://redd.it/1gbzxbf
How do I solve this circular import error between two models ?

Here's a simplified to the maximum version of my code:

from app2.models import Model2

class Model1(models.Model):
model2 = models.OneToOneField(Model2, ondelete=models.CASCADE, null=True)


# In another app
from app1.models import Model1

class Model2(models.Model):
field1 = models.CharField(max
length=90)

def save(self):
super().save()
objectmodel1 = Model1.objects.filter()
# Process on object
model1


In there, there are two models. One in each of two apps. Model1 needs to import Model2 to define a One To One relationship and Model2 needs to import Model1 because it needs to use it in its save method hence the circular import error I get. I could import Model1 in the save method of Model2 directly but I've read it is not recommended for multiple understandable reasons.

I also heard I could put the name of the model "Model2" in

/r/djangolearning
https://redd.it/1gcbct4
Build a 'Chat with Wikipedia' App Using Flask and Gemini API (Demo + Code)

Hey Community,

I’m excited to share how quick and easy it is to bring your apps and ideas to life using Flaskβ€”the learning curve is really user-friendly! I recently built a "Chat with Wikipedia" app using Flask, powered by the Gemini API.

You can check out a demo on my YouTube channel (link provided in the video description), where you’ll also find the code.

Here’s a quick overview: this app lets you enter a Wikipedia page title and chat with the page to ask questions about it.

Next on my list is to develop a Chrome extension to extend this concept, making it possible to chat with any website directly.

Let me know what you think!

https://www.youtube.com/watch?v=1mxTvmpDV-I

/r/flask
https://redd.it/1gbrfs2
Project Open source video indexing/labelling/tag generation tool.

Guys, I'm looking for an open source tool or any repo that can help me generate tags for video to categorize multiple videos and do further analysis.

An equivalent of what I want is Azure AI clvideo inxer, but If there was such a open source tool, it will solve the problem.

/r/MachineLearning
https://redd.it/1gccyhp