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
D Simple Questions Thread

Please post your questions here instead of creating a new thread. Encourage others who create new posts for questions to post here instead!

Thread will stay alive until next one so keep posting after the date in the title.

Thanks to everyone for answering questions in the previous thread!

/r/MachineLearning
https://redd.it/1c9jy4b
My falsk app works fine when running using launch.sh file locally but when i route the traffic via proxy ( nginx ), i get 504 Gateway Time-out.

My falsk app works fine when running using launch.sh file locally but when i route the traffic via proxy ( nginx ), i get 504 Gateway Time-out.

Here is my current nginx config

server {
listen 80;
listen :::80;

servername ;

location / {
return 301 https://$host$requesturi;
}
}

server {
listen 443 ssl;

ssl
protocols TLSv1 TLSv1.1 TLSv1.2;
sslciphers HIGH:!aNULL:!MD5;

ssl
certificate /etc/ssl/certs/example.com.pem;


/r/flask
https://redd.it/1cafuij
D Llama-3 may have just killed proprietary AI models

Full Blog Post

Meta released Llama-3 only three days ago, and it already feels like the inflection point when open source models finally closed the gap with proprietary models. The initial benchmarks show that Llama-3 70B comes pretty close to GPT-4 in many tasks:

The [official Meta page](https://llama.meta.com/llama3/) only shows that Llama-3 outperforms Gemini 1.5 and Claude Sonnet.
Artificial Analysis shows that Llama-3 is in-between Gemini-1.5 and Opus/GPT-4 for quality.
On [LMSYS Chatbot Arena Leaderboard](https://arena.lmsys.org/), Llama-3 is ranked #5 while current GPT-4 models and Claude Opus are still tied at #1.

The even more powerful Llama-3 400B+ model is still in training and is likely to surpass GPT-4 and Opus once released.

## Meta vs OpenAI

Some speculate that Meta's goal from the start was to target OpenAI with a ["scorched earth"](
https://en.wikipedia.org/wiki/Scorched_earth) approach by releasing powerful open models to disrupt the competitive landscape and avoid being left behind in the AI race.

Meta can likely outspend OpenAI on compute and talent:

OpenAI makes an estimated revenue of $2B and is likely unprofitable. Meta generated a revenue of $134B and profits of $39B in 2023.
Meta's compute resources likely outrank OpenAI by now.
Open source likely attracts better talent and researchers.

One possible outcome could

/r/MachineLearning
https://redd.it/1cad7kk
Tuesday Daily Thread: Advanced questions

# Weekly Wednesday Thread: Advanced Questions 🐍

Dive deep into Python with our Advanced Questions thread! This space is reserved for questions about more advanced Python topics, frameworks, and best practices.

## How it Works:

1. **Ask Away**: Post your advanced Python questions here.
2. **Expert Insights**: Get answers from experienced developers.
3. **Resource Pool**: Share or discover tutorials, articles, and tips.

## Guidelines:

* This thread is for **advanced questions only**. Beginner questions are welcome in our [Daily Beginner Thread](#daily-beginner-thread-link) every Thursday.
* Questions that are not advanced may be removed and redirected to the appropriate thread.

## Recommended Resources:

* If you don't receive a response, consider exploring r/LearnPython or join the [Python Discord Server](https://discord.gg/python) for quicker assistance.

## Example Questions:

1. **How can you implement a custom memory allocator in Python?**
2. **What are the best practices for optimizing Cython code for heavy numerical computations?**
3. **How do you set up a multi-threaded architecture using Python's Global Interpreter Lock (GIL)?**
4. **Can you explain the intricacies of metaclasses and how they influence object-oriented design in Python?**
5. **How would you go about implementing a distributed task queue using Celery and RabbitMQ?**
6. **What are some advanced use-cases for Python's decorators?**
7. **How can you achieve real-time data streaming in Python with WebSockets?**
8. **What are the

/r/Python
https://redd.it/1caq9bh
What is the best service/platform to help monetize my APIs & cut development time?

I've developed several APIs with Python’s FastAPI and deployed them on Google App Engine. I aim to monetize these through a website that allows user registration, subscription to paid plans, and API usage. I need functionalities like user accounts, admin dashboard, subscription management, and an API gateway with features like key generation and rate limiting. What tools are available to minimize coding for these standard components?

/r/flask
https://redd.it/1caru2m
I now know again why I stopped using mamba / conda for setting up virtual environments

I have started at a new job and had the idea that it would probably be clever to set up my developing environment in exactly the same way as my predecessor did. Because:

1. This should help resolving errors quicker in the transition period
2. His code was good and clean and it appears that he knows what he is doing
3. we were using mostly the same tools (VScode etc.) anyways.

He set up his virtual environments (VE)s with conda/mamba. I vaguely remembered that I also used to do that but then stopped for some reason and switched to the virtualenv package. But I did not remember why anymore. So I just set up my VEs in the same way, it should not really make any difference anyways (so I thought). Well, fast forward about two weeks and now I have VEs that occasionally (but not always) exist twice in the same folders under the same name (according to mamba info --envs) and that are at the same time completely empty (according to mamba list) and contain all packages I have installed anywhere, ever (according to pip list). I usually install packages via pip and I assume this may have fucked things up

/r/Python
https://redd.it/1caflkr
[D] Phi-3 to be released soon

Heard from two independent sources at MSFT (one close to Sebastien Bubeck) about the upcoming Phi-3 models:

* Three different sized models (up to 14B)
* Again, mostly synthetic and LLM-augmented training data
* Apparently some upscaling techniques on the training side
* No more Apache 2 but more restrictive license (similar to llama3)
* Mixtral level performance with much fewer parameters

I wanted to see if anyone has more insider information about the models.

/r/MachineLearning
https://redd.it/1cartvg
Free platforms to deploy my flask+react app?

I built a data analytics web app using flask BE, react FE, and postgresql database to store all the data that users will analyze. I want to get out an MVP for as little cost as possible (I don't have much disposable funds right now) and was wondering if y'all had recommendations for free (or lowest cost) platforms to use? Heroku seems to have discontinued their free tier :( I was also checking out Cyclic but their docs seem to say they only support a single db table which would not serve my app's needs. I'm not too concerned about scalability right now since I just want to get out an MVP to start pitching investors and raising funds. Once those funds are (hopefully) raised, then I'll have more resources to pay for a more scalable platform. Right now I just need a platform that supports flask + react stack, auth, and at least 10-20 db tables in postgresql. Any recs would be greatly appreciated! Thanks!

/r/flask
https://redd.it/1caniyx
Using SSE vs Web-sockets

Hello all,

I'm creating an app where I'll be sharing data from the server, there will not many client requests for data, what I'm thinking to use is SSE, because there's no need client operation required or payload required, only thing is I have to identify which user sending the request(if you have suggestions for identifying users over SSE, please share).

Using SSE or Web sockets, I'm confused because I've never tested any of one in production neither used much, also there will be about 83-147 MB data will be sent from the server to client every 2 to 3 hour average, and simultaneously almost 500 users will be connected to the server.

The confusion is which will be more memory efficient, which will have less CPU load and if there are any other solution which can handle more than 500 simultaneous connections which requires not that much memory, and not much CPU load, I'm not looking for a cheap product or like that but the thing is Performance and speed with low memory consumption and low CPU usage is

/r/flask
https://redd.it/1cayel1
GoDaddy/Outlook contact us form

Hello, I recently signed up for GoDaddy and Microsoft 365 Email Essentials. I'm trying to make a contact us form. I have turned on SMTP and made setup MFA so I can make a app password. It worked when I was using gmail's SMTP. I can also send a email out to a user, but when I make it so that a user tries to send a email to me via the contact form I get:

(554, b'5.2.252 SendAsDenied; [myemail@email.com](mailto:myemail@email.com) not allowed to send [client@mail.com](mailto:client@mail.com); STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message \[BeginDiagnosticData\]Cannot submit message.

My code is:

@app.route('/submit_contact_form', methods=['POST'])
def submit_contact_form():
    name = request.form['name']
    email = request.form['email']
    subject = request.form['subject']
    message = request.form['message']
    msg = Message(subject=subject, sender=email, recipients=['myemail@email.com'])
    msg.body = f"Name: {name}\nEmail: {email}\nMessage: {message}"
   
    try:
        mail.send(msg)
        message_sent = True
   

/r/flask
https://redd.it/1cb1hcy
Async on OpenAI response

Hey guys. I have a function and a route that gets some response from openai and posts it to the website. It takes alot of time. How can I implement async processing on it to take multiple tasks at once and be faster. I've researched on this but it is quite confusing. Whats the difference b/w AsyncIO and Redis RQ / Celery. Any good resource would help.

/r/flask
https://redd.it/1cb38k8
Seeking Feedback on My First Django Web App. What are the next steps?

Hello everyone,

I’m excited to share my first web app, StreetTreasure, which I’ve developed as part of a class project. I had some experience in Python, so I chose Django for this project. It’s been a week since I started, and I’ve managed to implement the basic functionalities.

The inspiration for StreetTreasure came from observing the waste of perfectly good items, like furniture and electronics, that people often leave on the street before city garbage collections. With some interviews, we learned that selling these items on platforms like FB Marketplace or Craigslist, or even donating them, can be time-consuming. So, I created StreetTreasure to help people easily find usable items in their neighborhoods.

Here’s how it works: Registered users can anonymously post a picture of the item they’re discarding. Our app then maps the picture based on the EXIF info with a timestamp. So far, I’ve implemented:

1. User registration and authentication
2. Post information management using an SQL database
3. Conversion of GPS data to geo-coordinates from EXIF

The prototype is currently deployed on a free PythonAnywhere account. If you’re interested in trying it out, you can access it here.
https://crystalflare335.pythonanywhere.com/

Looking ahead, if the app gains traction, we’re considering implementing the following features:

1. Improved

/r/djangolearning
https://redd.it/1caw5et
Having trouble getting flask to run.

Hi

I'm having trouble getting Flask to work. Here's some background and where the problem is:

\- I'm new to python but I've programmed in other langagues.

\- I'm on a Windows 10 Pro laptop.

\-- I'm following this youtube tutorial: "Python for Web Development – Crash Course [API, SQL Databases, Virtual Environment, Flask, Django\]"

Everything has been going fine and I was excited to get into the web app section. At the 52 minute mark, he starts the section labeled "Flask Setup". Here's what I did:

\- Following his instructions, I installed Flask using:

pip install flask

\- It installed without errors.

\- Next he says to create a virtual enviornment for a new project. So I did the following:

python -m venv webBookmarks

("webBookmarks" is the name of hte project I want to work on.)

\- I actived it using:

webBookmarks\\scripts\\activate

\- I'm now in the 'webBookmarks' VM as shown in the format of the command prompt:

(webBookmarks) c:\\Clem\\python\\Virtual environments\\webBookmarks>

\- Next, he says to use this command:

(webBookmarks) c:\\Clem\\python\\Virtual environments\\webBookmarks>FLASK_APP=app.py

\- When I issue that command, I get the following error:

* 'FLASK_APP' is not recognized as an internal or external command, operable program or

/r/flask
https://redd.it/1cb5daf
Creating a site like Alltrails.com in Django (Django beginner question)

I want to create something similar to Alltrails.com like this page https://www.alltrails.com/en-gb/explore/england/staffordshire/newcastle-under-lyme?b\_tl\_lat=55.78716611610855&b\_tl\_lng=-9.493297338892177&b\_br\_lat=49.881806552115165&b\_br\_lng=4.888657338893637&mobileMap=true

Something where users around the world can add routes on a world map with photos and a description, which others users can search, view and add comments on.

I was just curious if it's possible in Django. Can I use Django + Tailwinds + HMTX + Openstreetmaps (+leafletjs) to achieve something similar?

Are there any specific tutorials or resources that might help? (i've learnt the basic beginner Django basics)

/r/django
https://redd.it/1cb7qzw
8 minutes to build a Connect4 game with HTMX and Django 🟡🔴

Hi fellow Django-nauts 🚀

I wrote a short post showing how to build a simple Connect4 game with HTMX and Django in 8 minutes. I've kept everything as simple as possible.

Here's the guide to build the game: Build a Connect4 game with HTMX and Django in 8 minutes 🟡

Build a Connect4 game with HTMX and Django in 8 minutes 🟡🔴

/r/django
https://redd.it/1cb4ssy
Feedback on Django Preview Copy

I've been seeking honest feedback on the preview copy of "Django 5 by Example" from fellow developers who enjoy reading tech books. If you're curious about the projects included, you can check them out here, you can let me know: https://forms.gle/uFUrBBsCvJa6gHYZA

/r/djangolearning
https://redd.it/1ca9ioh
Wednesday Daily Thread: Beginner questions

# Weekly Thread: Beginner Questions 🐍

Welcome to our Beginner Questions thread! Whether you're new to Python or just looking to clarify some basics, this is the thread for you.

## How it Works:

1. Ask Anything: Feel free to ask any Python-related question. There are no bad questions here!
2. Community Support: Get answers and advice from the community.
3. Resource Sharing: Discover tutorials, articles, and beginner-friendly resources.

## Guidelines:

This thread is specifically for beginner questions. For more advanced queries, check out our [Advanced Questions Thread](#advanced-questions-thread-link).

## Recommended Resources:

If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.

## Example Questions:

1. What is the difference between a list and a tuple?
2. How do I read a CSV file in Python?
3. What are Python decorators and how do I use them?
4. How do I install a Python package using pip?
5. What is a virtual environment and why should I use one?

Let's help each other learn Python! 🌟

/r/Python
https://redd.it/1cbk37r
Zillow scraper made pure in Python

Hello everyone., on today new scraper I created the python version for the zillow scraper.

https://github.com/johnbalvin/pyzill

What My Project Does

The library will get zillow listings and details.
I didn't created a defined structured like on the Go version just because it's not as easy to maintain this kind of projects on python like on Go.
It is made on pure python with HTTP requests, so no selenium, puppeteer, playwright etc. or none of those automation libraries that I hate.


Target Audience

This project target could be real state agents probably, so lets say you want to track the real price history of properties around an area, you can use it track it


Comparison 

There are libraries similar outhere but they look outdated, most of the time, scraping projects need to ne on constant maintance due to changed on the page or api



pip install pyzill

Let me know what ou think, thanks

about me:
I'm full stack developer specialized on web scraping and backend, with 6-7 years of experience

/r/Python
https://redd.it/1cblimn