Python Daily
2.56K subscribers
1.49K photos
53 videos
2 files
39.1K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
META What happened to r/Python?

I've not been on r/Python in quite a while because life. I visited daily maybe 12-18 months ago and I remember the content here was a lot more discussion about the language itself, with a few pandas and datascience tutorials sprinkled in. Many threads had long discussions that were interresting to read.

Now it seems 90% of posta have less than 3 comments and the posts are mainly beginner showcases (that nobody cares about judging from the amount of comments they get) or some youtube tutorial about machinelearning or building a twitter/discord bot in 4 lines og python.

Is it just me or has this community changed a lot during the pandemic? r/Python used to be the fist thing I checked out on reddit. Not so much anymore unfortunately.

/r/Python
https://redd.it/lk9xbx
Tuesday Daily Thread: Advanced questions

Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.

If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/lkqsu8
Using JWT to authenticate Flask API. I am almost done but having some issues. Can someone please help me?

I am trying to implement JWT authentication for a Flask API. I am using flask_jwt_extended. I am confused about how to persist user sessions. My API has an endpoint for login which issues an access token. I have a different resource that refreshes the token. So, how do I implement the functionality where after the access token is expired, the user is automatically issued a new access token without having to log in.

My current logic ( I believe I am missing something). After a client sends an access token and gets the response that the token is expired, it sends the refresh token to TokenRefresh resource to get a new access token and then resends the same access token. Kinda seems like a bad design. How do you guys suggest I do it?

Resource for Token Refresh

class TokenRefresh(Resource):
@jwtrefreshtokenrequired
def post(self):
current
user = getjwtidentity()
accesstoken = createaccesstoken(identity = currentuser)


/r/flask
https://redd.it/lkpa18
Managing the version of a Flask app

I am looking for some guidance on managing the version number of my flask app. Its currently just a variable that is displayed at the footer area of the app but I want it to be more useful, such as in a way that it can either be auto-incremented through my CI/CD pipeline or perhaps something like a pre-commit hook to remind me to increment it before pushing code up.

/r/flask
https://redd.it/lkrk2v
Twitterbot Python Code

I wrote a twitter bot to get a million followers on Twitter

by following hundreds of thousands of people, awaiting the follow-back, and automating unfollows after a certain time period. Rate limits immediately stumped my ambitious ideas. In hindsight it may have been a bit too ambitious.

Watch how I made it: https:\/\/www.youtube.com\/watch?v=-ZsWwbwhy6g&feature=youtu.be&ab\_channel=DylanSmith

So I remade a reddit-like posting page with a twitter bot by listening to the twitter-post stream and scraping all content in tweets made mentioning "@bestpostbot", "#bestpostbot", or simply "bestpostbot" and posting them on my bots page.

Essentially, anyone can make a post on this page by tweeting their own post and just mentioning the bot. My bot's page (https://twitter.com/bestpostbot) then serves as a space everyone can browse collectively for interesting content. "Upvote" your favorites.

The tweet with the mosts likes and retweets gets pinned and shown off at the top, while all posts on the page compete for this spot. Welcome to bestpostbot. Make a tweet.

View the relatively short code on GitHub: https://github.com/e-Dylan/bestpostbot

/r/Python
https://redd.it/lkmna0
Elyra 2.0 has been released (productivity features for common data science and AI tasks)
https://developer.ibm.com/articles/what-is-new-in-elyra-2-0/

/r/IPython
https://redd.it/lksaa6
Java programmer coming to Python for the first time...

Decided to try and do a thing in Python for the first time in a while.

Wrote a small program to test out a library in Python that I'd originally been using the Java version of.

Keep in mind I'm very, VERY used to Java and to an extent C++.

Take a guess as to what happened.

​

It ran flawlessly with zero errors the first time I ran it.

​

Why the hell don't I use this friggin language more often.

I'm genuinely still astonished, not a single thing I've made in Java has run flawlessly the first time I run it.

So uh, hello Python. Where the hell have you been all this time?

/r/Python
https://redd.it/lkwjuq
I made a Python project that detects if your Reddit account is shadowbanned

In my opinion, shadowbans are the worst things ever. You won't know about it for a long time, and when you will know, you still remain helpless. So I made a simple command line based python app that takes in your Reddit username and checks if the account is shadowbanned. I made this because I have had this shadowban problem in the past and I didn't know how to confirm if I am shadowbanned. I tried out https://nullprogram.com/am-i-shadowbanned/, but as you can see on their page, the service no longer works. You can just download my python file, run it in your terminal, enter your username and wait till the program finds out if you are shadowbanned. It might take a few seconds to over a minute for the program to find out.

Download source code - https://github.com/ProgrammingWithYash/reddit\_shadowban\_detector

If you want a video tutorial on how to make this, comment below.

And sorry if "Intermediate Showcase" is not the right flair for this - the code itself is pretty simple, but I think sending HTTP requests is an intermediate concept ?

/r/Python
https://redd.it/ll4myw
See how my new tool visualizes Python code - and shows bugs in the code base.

/r/IPython
https://redd.it/ll9kwo
What's the simplest way to allow cross-origin requests in Flask using Nix?

I will usually use Flask-Cors but I was wondering if there's a simple way because I am using Nix as a package manager and I don't know how to install it there.

/r/flask
https://redd.it/ll8ik9
Where can I find a project to work on with a group of people?

I want to learn more about Django and working with a team of people seems like a good step for me right now. I've been making a few simple apps, but don't really know what to do next.

/r/django
https://redd.it/ll6rpw
ipywidgets, User Input Choosing What Happens to Data

Hi all,

I'm trying to write a program that scrapes information from a website and then holds it until a user can review the information and choose what gets added to a main dataframe. I got the web scraping part down, but I need to figure out how to get a bit of code that allows me to go through each individual entry collected (and there could be a varying number of them each time) and 'approve' or 'deny' on a subjective basis.

I was figuring the best way to do this would be through ipywidgets, but I couldn't get something together that would allow me to generate a dropdown for each choice and then send a result back (resetting/clearing what needs to be reviewed each time). Would using ipywidgets be the best way to do this? Is there another module I should be looking at to make this work?

Thanks so much in advance for any thoughts or ideas !!

/r/IPython
https://redd.it/llkdei
What size of EC2 instance would you recommend to host a PostgreSQL database for a personal project that will generate around 50k new entries per day?

I'm working on a personal project where I have a DRF API that serves a webapp and I have a background task running every minute that fetches data to an external API (around 50k entries).

The first fetch of the day will create 50k new entries (10 columns each) in my PostgreSQL database, and every fetch after will update those entries with new values. Once the day ends a new set of 50k entries will be generated.

What size of EC2 instance will you recommend to host this database?

I'm trying to go for the smallest instance possible to avoid paying too much for this personal project that most likely will not generate any revenue.

/r/django
https://redd.it/llor5k
Wednesday Daily Thread: Beginner questions

New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/llh6vu
Help Python data analysis short project (paid opportunity)

Hello everyone,

I need someone to help me with a project (paid opportunity)

The idea is to work with different climate variables in a specific location, the project is relatively free, must know how to use/interpret linear regressions, K means, principal components analysis , HCA ...

The project will be done in Python and using pandas library as I have already started with it.

If you're interested please contact me!

/r/pystats
https://redd.it/llrlk9
How to get started with Flask?

Hello, I want to learn and get started with Flask.
But there are not much resources available online related to Flask. I have a good experience of Python .
Can you guys help me how to get started with Flask?

/r/flask
https://redd.it/llryca
Server Initialization UML, please make your critics!

/r/django
https://redd.it/llwmud
Receiving e-mails and storing them in the database.

I know about setting up SMTP to send an e-mail from django, but is there a way to receive e-mail in django?

Edit: Many interesting replies from various people here. I'll expound some more upon the issue, if there's interest.

Basically, this is to be a module for a webshop that has several e-mail addresses. For instance, information, complaints, repairs. I've sketched the general outline in my mind like so:

For sending mail from a different address a django admin action allows to select either: information, complaints, repairs or whatever, then something like this to dynamically select the proper sending address:

from django.core.mail import getconnection, sendmail
from django.core.mail.message import EmailMessage

with getconnection(
host=my
host,
port=myport,
username=my
username,
password=mypassword,
use
tls=myusetls
) as connection:
EmailMessage(subject1, body1, from1, to1,

Ancillary issues that come to mind, the general outline of the models, actually getting the mail. Currently

/r/django
https://redd.it/llrgqt