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/1coby3c
Is there any way to get ssl certificate without using nginx?

So I'm trying to get an ssl certificate for my domain using https://letsencrypt.org/ on my linux machine. However, out of all the tutorials I have tried, not a single command relating to nginx or snapd has worked.


So I am wondering, is there any way to just tell certbot to generate a certificate for my flask server and thats it without having to boot up 20 thousand different things and 200 config files? Any help is appreciated, thanks.


I'm using flask as my server and ngrok to serve it.

/r/flask
https://redd.it/1cog8ix
Deploy Django website on my own PC

Hi to all. I have a Django project and I want to deploy it on my PC (Linux installed) so that anyone can connect to my website by IP address (this will be enough). What I should do?I will be very grateful if you share the tutorial link with my case

/r/django
https://redd.it/1cohzz9
Is there a fully gdb python debugger?

For fully compatible I mean:

1. Same API (e.g. I can use commands line info breakpoints, display myvar, etc from CLI)
2. Has MI interface

Thanks!

/r/Python
https://redd.it/1cojizh
Is there a discord or place to ask for help?

Do I just ask for help here? Pretty new to flask and trying to get a simple website for my assignment to just display the weather after grabbing it from weathermap org.

/r/flask
https://redd.it/1comqp0
Brackets not reading x in loop

My goal is to generate a signature line with the persons name that’s generated in a dps.input. It ask them how many members they have -> creates inputs based on how many members - > then makes signature lines, but after I create the input fields I can’t find a way to get the information from the input field. I thought I’d be able to re-loop x to get the names {{ dps.data.x|string }} but that doesn’t work and using 0-4 isn’t either.

{{ dps.input("numberOfMembers", "Number of Members", required=True) }}

{% set memberNumber = [\] %}

{% if dps.data.numberOfMembers %}

{% for x in range(dps.data.numberOfMembers|int) %}

{{ memberNumber.append(x|string) }}

{{ dps.input(memberNumber[loop.index0\], "Member", required=True) }}

{% endfor %}

{% endif %}


{% if dps.data.numberOfMembers %}

{% for x in range(dps.data.numberOfMembers|int) %}

<table style="width: 100%; table-layout: fixed; ">

<tr>

<th colspan="1" style="padding-bottom: 1em; ">

</th>

<th colspan="1" style="padding-bottom: 1em; ">

</th>

<th colspan="1" style="padding-bottom: 1em; ">

</th>

</tr>

<tr>

<td style="width:33%; ">

<span class="check_fillin" style="font-style:8.5pt; width:100%; line-height:6pt"></span>

</td>

<td style="width:33%; font-weight: bold; text-align: left; ">

</td>

<td style="width:33%; ">

Dated:<span class="check_fillin" style="font-style:8.5pt; width:80%; line-height:6pt"></span>

</td>

</tr>

<tr style="vertical-align: top;">

<td style="width:25%; font-weight: bold; vertical-align: top; text-align: left;">

{{ dps.data.x|string }}Member

</td>

<td style="width:25%; font-weight: bold; vertical-align: top; text-align: left;">

</td>

<td style="width:40%; vertical-align: top; text-align: left;">

</td>

</tr>

</table>

{% endfor %}

{% endif %}

/r/flask
https://redd.it/1cosuh4
PSA: Don't forget to set up all available firewalls!

The past few days I've been under attack from bots. Nothing spectacular - just trying SQL injections and other broad surface exploits. I was able to catch them due to some bugs in my forms and got alerts from Sentry as a result.

I'm using Cloudflare and was surprised that the attacks weren't mitigated. I then realized that I've done something really stupid - I'd simply forgotten to set up my server firewall to only allow traffic from Cloudflare's IPs. This means that all the bots were probing my server directly, circumventing Cloudflare.

Once I remedied that, traffic and server load dropped dramatically.

As an extra layer of security, I also wrote a small middleware which blocks the IP once they've accrued a certain amount of 400 status responses in a specific timeframe.






/r/django
https://redd.it/1coq05c
Introducing Flask Boilerplate Generator

Are you tired of spending valuable time setting up the same boilerplate code every time you start a new Flask project? Say hello to Flask Boilerplate Generator - your ultimate time-saving tool for Flask development!

Flask Boilerplate Generator streamlines the development process by automating the setup of a Flask project with just a few simple commands. Whether you're a seasoned Flask developer or just starting out, this tool will help you get your project up and running in no time.

== Key Features ==

Effortless Setup: Simply install the package from Github and use the command-line interface to create a new Flask project with a predefined folder structure and blueprint setup.

Virtual Environment Management: Automatically sets up a virtual environment for your project, ensuring clean and isolated dependencies.

Blueprint Configuration: Quickly scaffold your project with pre-configured blueprints for common application components like authentication, administration, error handling, search, account settings, views, database(model) and more.

Security Enhancements: Includes built-in security measures such as CSRF protection, HTTP headers middleware, and secure session management to help keep your application safe from common vulnerabilities.


======== User Commands: To Get Started Quickly =======
Flask Boilerplate Generator provides convenient commands to streamline your project setup:

=======Create Project Folder:=======

Bash or Terminal

flask-manage create-app mydemoapp

(This command creates a new directory for your Flask

/r/flask
https://redd.it/1cos334
Interactive plots in the terminal

I made a library to create interactive plots in the terminal ([pip install itrm](https://pypi.org/project/itrm/)). It uses braille characters (by default) to display the data with sub-character resolution. There are several keybindings for moving a vertical cursor left and right, for zooming in or out on data, and for changing which curve to focus on. There are occasions (such as when working with a server) where MatPlotLib is not an option and the terminal is the only available tool. But, in my opinion, it is actually faster to use this tool (itrm) to zoom in on interesting parts of data and analyze patterns than using other tools like MatPlotLib. In fact, with large data sets (\~1 million points), this tool actually renders faster than MatPlotLib. Please check it out and let know what you think.
![](https://gitlab.com/davidwoodburn/itrm/-/raw/main/figures/fig_iplot.png)

/r/Python
https://redd.it/1cor562
Django + React Shopping Cart

For Django Developers, mastering full-stack web app development with Django and a frontend framework sets you apart in the job market. I recently began a beginner series on creating web apps with Django and React. If this aligns with your interests, I'm confident this series will be extremely beneficial for you.

Episode 1 starts here 👇.
https://youtu.be/SD2l2-_y2sw?si=QEWI6I78exr7o45A

/r/djangolearning
https://redd.it/1cofsla
How to do unit and integration testing?

I created this project for a college project, but I have doubts about how I should do the unit and integration tests. I created some tests, but my colleague said they were e2e tests, which does not fit the job requirements. So if anyone can explain how I should do these tests and how far my tests are from the objective of the work.

https://github.com/GabrieldbSouza/Personal-Finance-Management/tree/main/server%2Ftests

/r/flask
https://redd.it/1cozm7e
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/1cp43wy
Need some advice for Auth with Django Rest Framework APIs

Here is some context

App will be used by people that hold sensitive information
App will be accessed via web (Nextjs) and mobile (React Native)
I need organization support
I want to use HTTP-only cookies for web and token based auth for mobile

App structure

I will add organization and add an admin for it
Organization admin can then make other admins and organization users

I have looked at Auth0, Clerk, and Supertokens. I don't mind paying for auth but these platforms seem to only provide token based authorization that resides in Authorization header of request. Or maybe I have missed something in their documentation.

Secondly, I want to build a single auth API that can be consumed on both web and mobile.

I have also looked at django-allauth and django-organizations to see if I can self-do authentication but I am not sure if it is worth the risk to do it myself considering security implications. Also, I havent found anything that is exactly what I need.

Let me know what you guys think. Also does anyone have a demo or open source project that does similar to what I am trying to do? I would love to look at it.

/r/django
https://redd.it/1cp2ozf
I have learned django from cs50w course. what I should do next?

I have learned basic django from cs50w course, but I want to built good websites, what are thr things should I learn next and from where (if u can tell me)? Please!

(I know basic Javascript)

/r/django
https://redd.it/1cp61n6
IP subnet or IP calculator tool need feedback

Hey folks,

I've been dabbling with a Python project recently that's all about making life easier for us I.T. people. It's a nifty little tool that calculates IP subnets and does IP calculations from the command or CLI.

Here's the GitHub link and the code:

https://github.com/nicanorflavier/ipnet

I’m pretty stoked about it, but I know there’s always room for improvement. So, I thought, better to turn to than the wise minds of this python community?

I’m all ears for any feedback, tips, tricks, or advice you guys might have. Thanks a ton in advance!

/r/Python
https://redd.it/1comgeg
Help with Django-star-ratings and django-comments-xtd

I think I have really confused myself. I wanted to make the star rating part of the comment form but I’m not sure how to do it.

Has anyone had any experience with this?

I’m not sure how to add a field to the comment model for it to be then used in the form and render like it’s meant to in the Django-star-ratings library.

It seems that in the documentation for Django-star-ratings they just have template tags but not sure how I should make this work with the rest of the comment code.

/r/djangolearning
https://redd.it/1co1v0e
Dictionary is not getting populated with the a list of users

I have code query below. Anniversary stores the number of years after burial date. If anniversary is less than or equal to zero, then the deceased person is not yet buried, therefore, users are allowed to send condolence messages, otherwise the tab changes to anniversary messages. A user is only allowed to send one condolence or anniversary message, otherwise the button to edit his/her condolence/anniversary message appears. But unfortunately the author_dict is not getting populated for the code to check whether a user has already posted or not. Help me understand and correct my code why the authors_dict is not getting populated. The database has data. I am using flask, sqlachemy and sqlite database:

# Initialize the variable
authors_dict = {}

/r/flask
https://redd.it/1cp9n58
R Marcus Hutter's work on Universal Artificial Intelligence

Marcus Hutter, a senior researcher at Google DeepMind, has written two books on Universal Artificial Intelligence (UAI), one in 2005 and one hot off the press in 2024. The main goal of UAI is to develop a mathematical theory for combining sequential prediction (which seeks to predict the distribution of the next observation) together with action (which seeks to maximize expected reward), since these are among the problems that intelligent agents face when interacting in an unknown environment. Solomonoff induction provides a universal approach to sequence prediction in that it constructs an optimal prior (in a certain sense) over the space of all computable distributions of sequences, thus enabling Bayesian updating to enable convergence to the true predictive distribution (assuming the latter is computable). Combining Solomonoff induction with optimal action leads us to an agent known as AIXI, which in this theoretical setting, can be argued to be a mathematical incarnation of artificial general intelligence (AGI): it is an agent which acts optimally in general, unknown environments. More generally, Shane Legg and Marcus Hutter have proposed a definition of "universal intelligence" in their paper https://arxiv.org/abs/0712.3329

In my technical whiteboard conversation with Hutter, we cover aspects of Universal AI in detail:

https://preview.redd.it/o6700v1udrzc1.png?width=3329&format=png&auto=webp&s=c00b825dbd4d7c266ffec5a31d994661348bff49

Youtube: https://www.youtube.com/watch?v=7TgOwMW\_rnk&list=PL0uWtVBhzF5AzYKq5rI7gom5WU1iwPIZO



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