Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.8K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
State in Flask

Hi all, I’m new to Flask and I’m on a small web app project where users are supposed to make repetitive crud operation and some calculation server side, on the same objects. Now I don’t know if it is possible or neither if I’m thinking the right way, but I’d like to cache the state of the objects, to avoid quering each time the db, create the object and (when the user simply reads data) iterate again the list and send it back as a json. Being Flask thread safe, it seems impossible and neither right to work this way. Can anyone give me advice if there is any solution or if I’m taking the problem in the wrong way?

/r/flask
https://redd.it/j0ardw
Hello from .NET!

Just wanted to drop in and say hi! I've been a .NET developer for over 20 years and have been embarking on a journey with AWS for the last several years, but have struggled a bit with the .NET eco system within that context, more specifically, the serverless stuff. I recently discovered Python/boto and must say I am totally in love! Python just seems so much easier and requires way less code to do powerful stuff. I also appreciate the dynamic nature of it. Coming from a statically typed language is a breath of fresh air.

It also seems there is a very robust community around Python, not to mention a TON more jobs than .NET. Looking forward to getting more involved.

/r/Python
https://redd.it/j0b2lq
Why you should try VizTracer to understand your python program

Have you ever thought about "why is my program doing this thing" when you are developing? That happens to me quite a lot when I'm working with Python, and becomes the reason I built [VizTracer](https://github.com/gaogaotiantian/viztracer).

VizTracer is helpful in many aspects, debugging, logging or profiling. The fundamental idea behind VizTracer is to help you understand what your program is doing.

Unlike traditional debuggers, which normally pin you at a specific time and allows you to check on variables, VizTracer focuses on the call stack over time. Basically, VizTracer visualizes how functions calls each other while your program is running.

[Recursive Fibonacci ](https://preview.redd.it/6g55u869pjp51.png?width=2286&format=png&auto=webp&s=bdf8148c457bfc8306333a2db7a3ea808b469b05)

This is a very simple example, the program is doing a recursive fibonacci number calculation:

def fib(n):
if n < 2:
return 1
return fib(n-1) + fib(n-2)

VizTracer can show how the recursive function actually works.

VizTracer is not a toy, it can also deal with very large program.

[Monte Carlo Tree Search](https://preview.redd.it/1jy7ttqxpjp51.png?width=2282&format=png&auto=webp&s=91ae66cc28a050e152d43a783648a0cb1ebdab40)

Above is the result of a MCTS(Monte Carlo Tree Search). You can zoom in to check the details of the program

[Details

/r/Python
https://redd.it/j0dj8q
Sunday megathread: What's everyone working on this week?

Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.

/r/Python
https://redd.it/j0gs61
I Wrote a Script to notify Me of any Instagram Unfollowers

[https://www.youtube.com/watch?v=2R0VogObeT4](https://www.youtube.com/watch?v=2R0VogObeT4)

If you've ever been unfollowed you've probably wondered... "hmm, I wonder who that was"

With this script, now you'll be notified automatically

[https://github.com/yyildiz/instagram-fake-friend-finder](https://github.com/yyildiz/instagram-fake-friend-finder)

/r/Python
https://redd.it/j0cgib
update

noob question. just began getting into ipython. How does one update to a newer version from the terminal? Been looking around but couldn't find anything

/r/IPython
https://redd.it/j0alqq
I'm giving back - here's a free book on Python - keep learning during lockdown!

I started writing "[Slither into Python](https://www.slitherintopython.com/)" a little over a year ago and I have recently completed it. I decided to release it online for free as a thank you to the programming community, in particular the Python community. Since release there has been over 64k readers, and I've received a tonne of really amazing feedback as well as some incredibly important constructive feedback which I have taken and used to improve the content. I know a lot of you out there are learning Python at the moment and I hope this resource can serve you well.

If you have any questions, or feedback for me, then please let me know, my email is on the site!

I know this is a difficult time for many of us but we can use it to our advantage! Many of us have a lot more free time now then we ever had before, so use this time to continue learning and really ramp up your skills!

Check it out here: [www.slitherintopython.com](https://www.slitherintopython.com/)

/r/Python
https://redd.it/j0if10
django is second in most github stars for backendframeworks

/r/django
https://redd.it/j0icp3
How to build a Job board using Django and Vue 3 | Video tutorial

Hi everyone :-)

I just published the first part of my new tutorial series. In this series, I will show you how to build a job board using Django and Vue.

The project will be split into two parts. One part for the employers where they can submit jobs and one part for the job seekers where they can find jobs and apply for them.

I'm also going to make it possible to communicate between them and many other cool things.

Check out the video here and let me know what you think :-)

[https://www.youtube.com/watch?v=JkO-GRErWNY](https://www.youtube.com/watch?v=JkO-GRErWNY)

/r/django
https://redd.it/j0prh7
Best way to implement chat app between users?

So I've been learning django and JS for a while as a side thing, and I want to create a social media app with more reactivity. I'm pretty confident with django (as a beginner) and want to move into learning a JS framework, prob react.

What's the best way to implement a chat app between my users in django? I want to use django as I'm comfortable with it but I'm not sure how I can make something like a chat system. Something like the current Instagram DMs for instance. And for react with django, should I do it both as a stand alone and then use django REST API or implement react in django? Or is there a better alternative?

/r/django
https://redd.it/j0r8t0
Pass Javascript object value to a Flask endpoint

Hi,

How can I pass a Javascript variable (array object) to a Flask endpoint?

/r/flask
https://redd.it/j0s4hl
Setting active/inactive dates for a model

I've got a scenario, where I need to set a user as active or inactive based on dates. i.e. Someone would enter a list of date ranges for when the user was active. I'm already using a custom user model and am familiar with that process.

My question is, what is the best way to model this?

/r/django
https://redd.it/j0tqhc
Flask is the third Backend Framework with the most stars on GitHub
https://expertain.net/7-backend-frameworks-with-the-most-stars-on-github/

/r/flask
https://redd.it/j0wb1a
Django is the second Backend Framework with the most stars on GitHub
https://expertain.net/7-backend-frameworks-with-the-most-stars-on-github/

/r/Python
https://redd.it/j0v9s6
API Mocha

Hi,

I've been using Django for a few years and decided to switch over to Flask for an idea I had to create a free tool for software developers. I started this project exactly one week ago and I'm quite pleased with how simple it has been to use Flask. I've committed about thirty development hours in total, and I plan to continue improving it further.

If you'd like, please go to [https://apimocha.com](https://apimocha.com) and give it a try. Essentially, you create an API endpoint and then send API requests to it, the website will reply with a configurable response. You can define the response data, status code, headers etc. I hope it is useful for prototyping APIs, and testing functionality.

Unfortunately the code itself is closed source, but I'm happy to answer any questions or share. Feedback is really welcome, and I hope you find the website useful!

A few of the capabilities I used:

* Rendering templates (Bulma for CSS)
* Flask-SocketIO (displays API calls in immediately in the browser)
* Flask-RESTful (managing mock responses)
* SQLAlchemy (storing mock rules, and API endpoint names
* Session data (I don't require sign-up, I use sessions to manage access)
* Github for revision

/r/flask
https://redd.it/j1182x
Monday megathread: Project ideas!

Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with how you found it and attach some source code!

/r/Python
https://redd.it/j11ntp
Flask SQLalchemy + Jinja loop

Hello!


I have a database that updates everyday.

I'm using bootstrap as my CSS template, and I want to generate a 'card' for each entry made on the current date

What I want to are the following:

\-Use SQLalchemy to query the database for the current date + all entries on that date

\-Use Jinja2 to generate a card for each option.


My problem is that SQLAlchemy has very light documentation on queries and I still don't understand the syntax for Jinja.


Thanks in advance!

/r/flask
https://redd.it/j12q5a