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
Which Docker tutorial to use?

I've been trying to deploy my Django app for a while, and because I don't have any experience with docker and trying to deploy ASAP, I tried to follow tutorials and here's what I found:

reddit post \- This reddit post linked an article, which isn't that old, plus is using exactly what I need: Django (DRF in my case), Redis, Celery and Postgres. But it's saying that

>server and worker share the same Dockerfile

So that means that I'm hosting both Celery and Django on the same server. It's not a big problem, but I've already hosted celery on Railway and Django on Render, they work fine, the problem is that the article is not showing the deployment process and is using NGINX. Do I deploy the same way I do usually on Render or do I have to follow the article and eventually encounter problems with deployment?

youtube video \- Many people say good stuff about this one, but I think it's outdated. It was released in 2020 (correct me if I'm wrong).

and this youtube video \- He's also explaining the same things simply, but I'd say the same thing about it. Outdated???

/r/django
https://redd.it/13hb9i4
Guide for a complete beginner - Tips, tricks and tutorials

Hi everyone, I’m fresh out of CS50 and looking to expand in BE and DevOps. Is there any good course or tutorial that can help me to build from ground up, already know some Python, C and JS.

Would love the help!

/r/django
https://redd.it/13hi1rc
Trouble Deploying Django to Railway.app

I am trying to get Railway to work as I like their features. I had the Railway account for a few days before I realized that I could get to learn it way quicker if I upgraded my account to the Developer one. My intention is to deploy the Django project's development environment (app plus database) onto Railway. My Django project is API only and I need the frontend dev environment (which I will host in a separate environment on Railway) to have access to the backend's API endpoints online.

When I deploy the development environment now, after referencing https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Deployment#getting\_your\_website\_ready\_to\_publish, I get the following deploy log "Watching for file changes with StatReloader

"Performing system checks... System check identified no issues (0 silenced). May 14, 2023 - 16:19:46 Django version 4.2.1, using settings 'project.settings.local' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C."

However, I get "Application failed to respond" when I try to access the project using the generated domain.

Here are the rest of my configurations and logs: build log: https://pastebin.com/pKw65eGe (I hid some data by replacing it with "xxx") base.py (base settings) https://pastebin.com/5fTkXTGB local.py (dev environment) https://pastebin.com/cfLPiDzm requirements.txt https://pastebin.com/T35yEriz (I'll clean it up once I figure out which libraries I do

/r/django
https://redd.it/13hj7bl
Monday Daily Thread: 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! If you're looking for project ideas, you might be interested in checking out Al Sweigart's, "The Big Book of Small Python Projects" which provides a list of projects and the code to make them work.

/r/Python
https://redd.it/13hrkfo
Using NextJS for templates a sensible choice?

Hey! I have a personal project I’ve been working on for over a year as a solo dev. I am experienced with Python, and have been using Django for my project. It has an API for mobile, and I am building a dashboard.

I gave templates/htmx/alpine a try, and found limitations pretty fast. These could be due to my inexperience with these, but I find making reusable components (how one would in say, react) to be difficult. And trying to have an edit form modal that shows a toast afterwards seemed like it was a lot to figure out with htmx/alpine (I was able to get them individually, but not both in order).

I work professionally with Vue, but all the component libraries for React seem great and make developing beautiful UIs and reusable components quite easy. I could be wrong, but I think doing a UI with something like Mantine could be a similar amount of work as Django templates - but far more flexible and easy to get nice results.

The benefits that NextJS provides seem really interesting, but the one thing I wonder about is if it is a bad approach to have Django being a service that next

/r/django
https://redd.it/13hu98j
Any must-have extensions for working with Python in VSCode/VSCodium?

Suggestions for extensions that help in general and not just with Python, are also welcome.

/r/Python
https://redd.it/13h2xuc
Multiparadigmatic Web Scraping Tool!

Hello! Hope you're all doing fine! I recently developed a multiparadigmatic web scraping tool with web crawling included as you can define the max hops it takes inside every link it finds inside a webpage!

It uses Async/IO to give maximum performance! Wanted to use multithreading to boost the HTML Parsing part since it's more of a CPU Bound part, but I benchmarked using multiprocessing and the overhead of creating multiple processes just for parsing wasn't worth it, since I'm quite experienced with C I might create a simple wrapper around this tool.

It's great to embed in a Browser Extension or just for any general purpose data mining on the web you might need. Instead of writing purpose specific scrapers for that particular web page you can just use this library.

Give me your sincere opinion since it is my first time publishing and authoring a python library, and it's my first OSS getting actually 16 stars. With this post I hope to get good insight and to learn and improve my python knowledge! My first programming language was C!
I know I got to automate the publishing process with GitHub Actions, the same way I have it for

/r/Python
https://redd.it/13hkrgc
Release 0.6.0 of FastKafka adds Redditors' requested features

FastKafka is a powerful and easy-to-use Python library for building asynchronous web services that interact with Kafka topics. Built on top of Pydantic, AIOKafka and AsyncAPI, FastKafka simplifies the process of writing producers and consumers for Kafka topics and automatically generates documentation for such microservices.


This release contains s number of feature requests from Redditors. Please take a look and let us know how we can make it better for you and your use cases.

https://github.com/airtai/fastkafka

/r/Python
https://redd.it/13i0eaz
A short bugfix story about UnicodeDecodeError: 'utf-8' codec can't decode byte

Hi everyone. Hope you are doing well.

I just wanted to share a short story with you about my yesterday's journey of bug fixing.

I am not a professional programmer but I have a working live webservice made on flask.

It appears, that when return render_template("about.html") happens, inside Flask there is some check happens whether passed html code has utf-8 symbols or not.

Error was: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position ... which was hard to debug because track trace was pointing out to my return render_template code and that was it. Position error was pointing to something inside a Flask files, not in my html. Other errors inside track trace were happening also inside Flask files.

What I normally do, when I update my code locally in PyCharm, I push it to private github and then just copy a text version of a file (code) to my production server via WinSCP, just via editing same file on server. I don't do a lot of changes so it is just easier for me, I guess.

So when I did slight change to my about.html on my local machine when everything worked fine, I copied code, opened remote SSH connection via WinSCP to

/r/flask
https://redd.it/13fe6rt
How do you maintain a development environment as well as a production version of your Django projects?

New to Web Dev and Django. I have created my first Django project and have deployed it to a website that I own. I am struggling to make a nice workflow to allow me to both develop and test my app, as well as deploy it when I am happy.

My current workflow is to write new code in the production version of my app which is currently deployed to my website. I write the code locally on VS Code, push to Gitlab, jump onto my server, and pull the latest code. This takes a while and isn't a nice way to develop and test quickly.

I can't seem to find any guidance online about managing and developing a running website. Does anyone have any suggestions on improving my workflow, and maintaining a separate space for development?

/r/django
https://redd.it/13i9h19
A Python package to retrieve data from Steam

Hi guys, I recently just build this lightweight package called steamcrawl after seeing that people are having trouble accessing/querying certain information on Steam. It simply makes a query to Steam, sorts the important information from the messy JSON then returns a pandas DataFrame. Here are some features that my package has been able to do so far:

\- Get your listing/buying/selling/cancelling on the community market.
\- Get all app id
\- Get the price history of an item.
\- Get the item id of an item.
\- Get buy/sell orders of an item.
...and more.

If you are interested, please give it a visit at: https://github.com/Hungreeee/steamcrawl
Note: the code is completely open, you can freely look into it or take it for personal use, I really don't mind that. I think it can be useful for educational purposes, especially for anyone who is trying to crawl Steam data but just doesn't know where to start.

/r/Python
https://redd.it/13i7oyy
I interviewed Joris Schellekens, author of the Borb PDF library, about his progress on building a business around an open source library. “If you want a library that is regularly updated by a team of developers, someone needs to pay those developers.”
https://codecodeship.com/blog/2023-05-15-joris-schellekens?utm_source=reddit

/r/Python
https://redd.it/13i6wo4
Scaling Django Applications: Best Practices and Strategies

Hey everyone! 😊

I'm excited to share my latest blog post with you all - "Scaling Django Applications: Best Practices and Strategies". I've attempted to be as precise as possible, and not too verbose. However, if you're interested in diving deeper into any specific topic, let me know and I'll consider writing another article with more detail.

In this comprehensive guide, I delve into the world of scaling Django applications, covering everything from understanding scalability, identifying bottlenecks, database strategies, caching, to best practices. It's a lot, but remember - every big journey begins with a single step.

So, whether you're a seasoned Django developer or just starting out, I hope you'll find some value in it. And remember, the path to success is always under construction. So, let's keep learning and growing together!

You can read the full article here: https://danielbuilescu.com/blogs/learn-python/scaling-django-applications-best-practices-and-strategies

/r/django
https://redd.it/13iaqzg
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/13ip05k
Introducing seaborn-polars, a package allowing to use Polars DataFrames and LazyFrames with Seaborn

In the last few months I've been using Polars more and more with only major inconvenience being that when doing exploratory data analysis, Polars dataframes are not supported by any of the common plotting packages. So it was either switching to Pandas or having a whole lot of boilerplate. For example, creating a scatterplot using pandas df is simply:

import seaborn as sns
sns.scatterplot(df, x='rating', y='votes', hue='genre')


But with Polars you'd have to do:

x = df.select(pl.col('rating')).to_numpy().ravel()
y = df.select(pl.col('votes')).to_numpy().ravel()
hue = df.select(pl.col('genre')).to_numpy().ravel()
sns.scatterplot(x=x, y=y, hue=hue)


That's quite a lot of boilerplate so I wrote this small package that is a wrapper around seaborn plotting functions and allows for them to be used with Polars DataFrames and LazyFrames using the same syntax as with Pandas dfs:

import polars as pl
import seaborn_polars as snl

df = pl.scan_csv('data.txt')
snl.scatterplot(df, x='rating', y='votes', hue='genre')


The code creates a deepcopy of the original dataframe so your source LazyFrames will remain lazy after plotting.

The package is available on PyPI: https://pypi.org/project/seaborn-polars/

If you want to contribute or interested in source code, the repository is here: https://github.com/pavelcherepan/seaborn\_polars

/r/Python
https://redd.it/13ittrl