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
I made a Spotify Genre Tracker with the goal of broadening my music taste.

# What My Project Does


Recently I've noticed that I spend way too much time listening to the same playlists/genres over and over again so with the goal of expanding my music knowledge I've decided to make this program that keeps track of the listening time for all the genres in Spotify.

It works by having two threads, one for the cli and user input and another that constantly pings the Spotify API for the currently playing song and keeps track of the listening time in an sqlite database.


# Target Audience

This project is meant for anyone that has a hard time finding new music genres to listen to. It is by no means production ready but if I see people enjoy it I might setup a website for it and make it public.


# Comparison

As far as I'm aware there aren't any projects like this one. The one's available out there keep track of all your stats but none give you a set goal or have the option to track the listening time for a given genre.

Any comments/recommendations are welcome. Hope it helps someone learn more about music!

Here's the repo for anyone that wants to check it

/r/Python
[https://redd.it/1evbgzb
Local to Live Question

I'm considering starting a bigger project than I'm used to. I've flipped through a lot of tutorials but haven't found a solid answer to a question I have.

Most of my projects have just been php and sql based. I just have the files on a webhost and it's live.

Can I do that with Django? It seems like a way different process to go live with Django. I was considering starting with a Django boilerplate.

/r/django
https://redd.it/1evd7gh
Django project links.

I’ve been doing django for couple of weeks. Gained basic knowledge now I want to test it and learn advance concepts by doing and tinkering. Can you guys please provide me some git repo based on django projects?Tnx…

/r/django
https://redd.it/1evp5mh
Monday Daily Thread: Project ideas!

# Weekly Thread: Project Ideas 💡

Welcome to our weekly Project Ideas thread! Whether you're a newbie looking for a first project or an expert seeking a new challenge, this is the place for you.

## How it Works:

1. **Suggest a Project**: Comment your project idea—be it beginner-friendly or advanced.
2. **Build & Share**: If you complete a project, reply to the original comment, share your experience, and attach your source code.
3. **Explore**: Looking for ideas? Check out Al Sweigart's ["The Big Book of Small Python Projects"](https://www.amazon.com/Big-Book-Small-Python-Programming/dp/1718501242) for inspiration.

## Guidelines:

* Clearly state the difficulty level.
* Provide a brief description and, if possible, outline the tech stack.
* Feel free to link to tutorials or resources that might help.

# Example Submissions:

## Project Idea: Chatbot

**Difficulty**: Intermediate

**Tech Stack**: Python, NLP, Flask/FastAPI/Litestar

**Description**: Create a chatbot that can answer FAQs for a website.

**Resources**: [Building a Chatbot with Python](https://www.youtube.com/watch?v=a37BL0stIuM)

# Project Idea: Weather Dashboard

**Difficulty**: Beginner

**Tech Stack**: HTML, CSS, JavaScript, API

**Description**: Build a dashboard that displays real-time weather information using a weather API.

**Resources**: [Weather API Tutorial](https://www.youtube.com/watch?v=9P5MY_2i7K8)

## Project Idea: File Organizer

**Difficulty**: Beginner

**Tech Stack**: Python, File I/O

**Description**: Create a script that organizes files in a directory into sub-folders based on file type.

**Resources**: [Automate the Boring Stuff: Organizing Files](https://automatetheboringstuff.com/2e/chapter9/)

Let's help each other grow. Happy

/r/Python
https://redd.it/1evnvtp
Checks before deploying an app

I know of CSRF for forms and debug set to false and allowed hosts to my domain name. is there anything more? specially security wise.

/r/django
https://redd.it/1ev6xf1
Pro tips for matplotlib figures to really feel right in LaTeX publications

I wrote up some tips that I think will help academics, or anybody else who happens to use matplotlib to make figures that end up in LaTeX documents. A long time ago I was a layout/typography nerd, so I've been trained to be anal, hence the tips below!
https://duetosymmetry.com/code/latex-mpl-fig-tips/

/r/Python
https://redd.it/1evp7ip
I Created the Definitive AUTOMATIC Shiny Hunter for Pokémon BDSP in Python

What My Project Does: Hey everyone! I am Dinones! I coded a Python program using object detection that lets my computer hunt for shiny Pokémon on my physical Nintendo Switch while I sleep. So far, I’ve automatically caught shiny Pokémon like Giratina, Dialga or Azelf, Rotom, Drifloon, all three starters, and more in Pokémon BDSP. Curious to see how it works? Check it out! The program is available for everyone! Obviously, for free; I'm just a student who likes to program this stuff in his free time :)

The games run on a Nintendo Switch (not emulated, a real one). The program gets the output images using a capture card, then, it process them to detect whether the pokemon is shiny or not (OpenCV). Finally, it emulates the joycons using bluetooth (NXBT) and control the Nintendo.

I also want to know what do you think about it: Is it fair to use it in singleplayer? And multiplayer?

Target Audience: All Pokémon BDSP gamers.
Comparison: As far as I know, nobody did this before.

📽️ Youtube: https://www.youtube.com/watch?v=84czUOAvNyk
🤖 Github: https://github.com/Dinones/Nintendo-Switch-Pokemon-Shiny-Hunter

/r/Python
https://redd.it/1evng2g
I built a Python Front End Framework

This is the first real python front end framework you can use in the browser, it is nammed PrunePy :

https://github.com/darikoko/prunepy

# What My Project Does

The goal of this project is to create dynamic UI without learning a new language or tool, with only basic python you will be able to create really well structured UI.

It uses Pyscript and Micropython under the hood, so the size of the final wasm file is bellow 400kos which is really light for webassembly !

PrunePy brings a global store to manage your data in a crentralised way, no more problems to passing data to a child component or stuff like this, everything is accessible from everywhere.

# Target Audience

This project is built for JS devs who want a better language and architecture to build the front, or for Python devs who whant to build a front end in Python.

# Comparison

The benefit from this philosophy is that you can now write your logic in a simple python file, test it, and then write your html to link it to your data.

With React, Solid etc it's very difficult to isolate your logic from your html so it's very complex to test it, plus you are forced to test your

/r/Python
https://redd.it/1evuzem
Making a windows desktop app using pygame: how bad of an idea is it?

I haven't found anyone asking this question, everything seems suitable to make nice desktop apps but I found no mentions of anyone doing it so I'm assuming it's a bad idea but I have no clue why that would be the case

/r/Python
https://redd.it/1evv8no
Why Signals are bad?

I went through some blogs, talking about optimizing performance of Django application and almost every blog mentioned avoid using signals. But none of the authors explained why.

/r/django
https://redd.it/1evvaeu
trying to set up a virtual environment on a linux and windows machine multiple times but failed.

i have a flask project (can't share the github repo because it is private) and I've tried setting it up on my fedora linux machine. the os by default had python 3.12 and I can't remove it because some core packages depend on it. I'm trying to set up a project with pipenv and after I run pipenv install, I get multiple resolution failures and in the error logs, I see that it is picking up some resolverdotpy files from my python3.12 directory.
i have tried specifying the python version as pipenv --python 3.8 install, but no luck. what can I do?

/r/flask
https://redd.it/1evrl3n
Question about transforming code into a web application

Good morning. I had written a large Python code (>500 lines) for a project, and was trying to make a self serve web application for this in Flask. I got the "hello world" and stuff down in flask, but now I am having trouble understanding how to move forward...do I simply copy paste my code into the main() function in app.py? Because I tried a test code like that (Just one input and an output) and the website didn't display anything.

Tl;dr: Trying to make a massive python code into a Flask web app, did the "hello world" code, not sure how to proceed.

/r/flask
https://redd.it/1ew2tkb
If you could go back and give your beginner Django self one piece of advice, what would it be?

For the seasoned Django developers out there - as you look back on your own journey, what's one insight or lesson you wish you had known when you were just starting out?

I'm a junior Flutter developer who is excited to dive into backend development with Django. As someone new to the field, I'm keen to learn from the experienced Django developers in this community.

Looking back, is there anything in particular you would have approached differently in learning and using the Django framework? What's one piece of advice you wish you could give your beginner self?

I'm especially interested in any insights on:

- Key concepts or techniques that were game-changers in your Django journey

- Resources (books, tutorials, projects) you found invaluable as a beginner

- Common beginner pitfalls to avoid or best practices to adopt early on

- Aspects of Django that were challenging to grasp at first but clicked later on

/r/django
https://redd.it/1ew0i59
Has there ever been a proposal for a zero-argument form of `slice()`?

I'm studying Pandas multi-indexing, which uses `slice(None)` [in some spots](https://pandas.pydata.org/docs/user_guide/advanced.html#using-slicers) and it seems ugly so I started wondering the title.

e.g.

dfmi.loc["A1", (slice(None), "foo")]

vs

dfmi.loc["A1", (slice(), "foo")]

Obviously, five extra keystrokes is not a big deal and this is a relatively niche usage, but I don't see any logical reason [`slice`](https://docs.python.org/3/library/functions.html#slice) shouldn't have a zero-argument form. I mean, the syntactic form, `:` doesn't have any value attached to it, so why should the callable form?

As of now, it mostly follows [`range`](https://docs.python.org/3/library/functions.html#func-range)'s signature, requiring either `stop` or `start, stop, step`.

---

**Edit:** NVM, I just realized you can use a convenience object like Pandas [`IndexSlice`](https://pandas.pydata.org/docs/reference/api/pandas.IndexSlice.html), which gives you syntactic sugar for this ***and*** more complicated indexing.

>>> idx = pd.IndexSlice
>>> idx[:]
slice(None, None, None)
>>> idx[:, ...]
(slice(None, None, None), Ellipsis)

Thus:

dfmi.loc["A1", (idx[:], "foo")]
# or
dfmi.loc["A1", idx[:, "foo"]]

All `IndexSlice` does is expose `__getitem__`:

> class _IndexSlice:
> def __getitem__(self, arg):
> return

/r/Python
https://redd.it/1ew3kvm
dont know how to fix it Errno 2

hello guys
im some kind of self-taught-programming-student (or whatever) like probably yall have been and im stucked AGAIN with something i rly dont know how to fix.

this problem ocurred when i was starting to practice django framework, reading the documentation and watching some videos to help me.

but then, this happened

https://preview.redd.it/kp4pv3k76ijd1.png?width=694&format=png&auto=webp&s=b0cc328f00079cbef08d3c3e5f7d6845ca302935

and the reason idk how to fix it is because there actually IS a file named manage in that folder/directory as you guys can see

https://preview.redd.it/acsq6dhe6ijd1.png?width=798&format=png&auto=webp&s=f6f08f7a6e781191ea51c803fb76bb980028d5dc

can someone help a rookie? D:

/r/djangolearning
https://redd.it/1evml07
Do you guys hardcode your backend auth?

So, I'm working on this non-profit project and have just finished the login and registration pages and APIs. I still need to deal with JWT and enhance security. My question is whether you guys hardroll the backend or do u use services like Firebase. However, Firebase is quite expensive, and since it's a non-profit project, I don't have enough funds to support it (I'm using SQLite for the db 💀). I don't anticipate having more than 5,000 users, and I find SQLite easy to use and flexible for starting out. If the user base grows, I can migrate to another database.

/r/flask
https://redd.it/1ew849q
Deployment (venv)

Can I upload my flask app in a virtual environment to the server? I'm only finding tutorials that setup python app in cpanel seperately. If someone knows a tutorial that shows how to upload the venv folder only and get it running (if it's even possible), that would be cool, thanks!

/r/flask
https://redd.it/1ewbbpw
The most upvoted open issue on matplotlib: "plot and scatter should allow marker to be a list"

I always find it kind of amazing where on the surface trivial issues in huge libraries can be open after many years. Today I encountered another one:

* [matplotlib#11155: plot and scatter should allow marker to be a list](https://github.com/matplotlib/matplotlib/issues/11155)

What the user wants is very simple: Just being able to input a list of markers, like you input a list of colors or a list of sizes, to give every point another marker.

Implementation wise, that proved a lot more difficult due to matplotlib's internal handeling of markers, labels and other stuff. Interesting read!

/r/Python
https://redd.it/1ewdf88
Expert Django Dev roadmap!!

I have experience in web development more than 3 years. I have worked on following things
1. DRF, for creating RESTful APIs for web and mobile.
2. Celery for running asynchronous tasks.
3. Celery beat for scheduling cron jobs.
4. Authentication with JWT and session.
5. Deployed app to AWS EC2, using Nginx, Gunicorn..etc.
6. Template rendering, Emails, ..etc.

Can I consider myself as Senior in Django. What should I learn next.?

/r/django
https://redd.it/1ew7gsw
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/1ewh8fl
Troubleshooting Cloudflare Interception and API Request Failures in Python

I've encountered an issue when making POST requests to certain endpoints using Python's requests library. Cloudflare is intercepting these requests, resulting in a 403 Forbidden error. For endpoint A, I've successfully bypassed Cloudflare using the curl_cffi library. However, endpoint B fails even with curl_cffi, resulting in a connection timeout or SSL handshake error instead of the previous 403.



To clarify:

1. This isn't the typical Cloudflare Challenge Page scenario. The error occurs directly upon POST requests to the API endpoint.

2. All required headers and payload are correctly included in the requests.

3. The original request headers don't contain any Cloudflare-specific parameters; these only appear in the response headers.



I'm seeking advice on how to troubleshoot and resolve this issue, particularly for endpoint B. Any insights into potential workarounds or debugging strategies would be appreciated.

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