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 have A question about my code in python

The code should make 100km

then subtract from it 100 meter

then 100cm then

then 100 mm

then Evaluate Exactly the value

THat is The file Which I wrote the correct Code

import Methods as M
def Convert_To_Decimal(Value):
    for i in range(len(Distance_List)-1):
        # Convert To Decimal
        V = Convert_Distance(Distance_List[i], Distance_List[i+1], Value)
       
        if V!=0:
            print(V, Distance_List[i+1], end=" ")  
        V=V-int(V)
    print()
        # Print Number
       
def Convert_Distance(From, To="1km", Value=0):
   
    return round(Value * M.Return_distance(From) / M.Return_distance(To),10)

def Minus():
    B = 100
    for Label in Distance_List[1:]:
        print("Subtracting 100", Label)
   

/r/Python
https://redd.it/1hm3k5p
How to effectively understand the Django repository (or any large codebase)?

The reason I am asking this question stems from my exploration of the Django codebase, which began after I finished studying Django for Beginners 4.2 by Will Vincent. Throughout the book, I often found myself asking questions like, how do CBVs and GCBVs work? Why do they inherit from the View class? Why is .as_view() used with CBVs and GCBVs, but not with FBVs?

These questions stayed in my mind, so I decided to explore the Django repository to understand them better. While most of the code (if not all) went over my head, I believe I now partially "understand" the "why" behind some of these concepts.

From my exploration, I realized that as_view() essentially β€œconverts” CBVs and GCBVs into functions because the foundational way of building Django views are FBVs. CBVs and GCBVs are built on top of FBVs. CBVs aim to achieve better separation of logic by mapping HTTP methods to specific class methods, while GCBVs are built on top of CBVs to simplify common tasks like creating, updating, deleting, querying and displaying data e.c.t.

I am not entirely sure if my understanding is accurate, but this is how I have interpreted it so far.

My question is, How can I understand

/r/django
https://redd.it/1hm4o4f
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

# Weekly Thread: Professional Use, Jobs, and Education 🏒

Welcome to this week's discussion on Python in the professional world! This is your spot to talk about job hunting, career growth, and educational resources in Python. Please note, this thread is not for recruitment.

---

## How it Works:

1. Career Talk: Discuss using Python in your job, or the job market for Python roles.
2. Education Q&A: Ask or answer questions about Python courses, certifications, and educational resources.
3. Workplace Chat: Share your experiences, challenges, or success stories about using Python professionally.

---

## Guidelines:

- This thread is not for recruitment. For job postings, please see r/PythonJobs or the recruitment thread in the sidebar.
- Keep discussions relevant to Python in the professional and educational context.

---

## Example Topics:

1. Career Paths: What kinds of roles are out there for Python developers?
2. Certifications: Are Python certifications worth it?
3. Course Recommendations: Any good advanced Python courses to recommend?
4. Workplace Tools: What Python libraries are indispensable in your professional work?
5. Interview Tips: What types of Python questions are commonly asked in interviews?

---

Let's help each other grow in our careers and education. Happy discussing! 🌟

/r/Python
https://redd.it/1hmc71n
Where to start with headless allauth

Hey everyone!

I've been taking my first steps into front end development, I've chosen sveltekit and am loving it so far. Now for the tricky part, authentication. There is a boilerplate project for allauth in react but I find the documentation to be lacking any guidance on implementation, any pointers?

/r/django
https://redd.it/1hm86tk
🐍 Modern, Minimalistic and Scalable Python FastAPI TemplateπŸš€

Hey! πŸ‘‹ Excited to share my production-ready API template that shows off modern Python practices and tooling! ✨



Key highlights: 🌟

\- ⚑️ Async-first with FastAPI and SQLAlchemy

\- πŸ—οΈ Clean, maintainable architecture (repository pattern)

\- πŸ› οΈ Latest Python tooling (UV package manager)

\- πŸ§ͺ Automated testing and CI pipeline

\- πŸš‚ One-click deployment to Railway



The template implements a fun superhero API to showcase real-world patterns! πŸ¦Έβ€β™‚οΈ



Technical goodies: πŸ”§

\- βœ… Type hints throughout

\- πŸ”„ Pydantic v2 for validation

\- πŸ“– Automatic OpenAPI docs

\- ⚠️ Proper error handling

\- πŸ”„ Async database operations

\- ⚑️ Automated migrations



GitHub: https://github.com/luchog01/minimalistic-fastapi-template 🌟



The logging setup and database migration patterns were super tricky to figure out πŸ˜… Not 100% sure if I handled them in the best way possible! Would really appreciate any feedback from the Python experts here! πŸ™ Always excited to learn from the community!

/r/Python
https://redd.it/1hmbg24
After changing flask port, port 5000 is not working anymore

Hey, I was sending API request to my flask application at 192.168.X.X:5000 from my local network for last few days.
Today I asked my friend to try and send API request , because I was in a hurry, I didn't have time to open new ports and I remembered I had port 25565 already opened so I used that one (so it was pub-ip:25565).

Now that I have time, I opened port 5000 and now the script is not working when I go back to port 5000.
I tried again with 25565 and its working, I tried from port 12345 and its working. Just the 5000 is NOT working.
Any suggestions?

When I start the app:

Serving Flask app 'main'
Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
Running on http://192.168.X.X:5000
Press CTRL+C to quit
Restarting with stat
Debugger is active!
Debugger PIN: 233-951-201

/r/flask
https://redd.it/1hm9j4x
Affordable and Reliable Hosting for Django Project with PostgreSQL, Redis, and AWS S3?

I'm developing a Django project which includes several key modules:

AI Integration: Uses OpenAI to provide crop recommendations and chatbot features.
Weather Module: Incorporates weather data to assist with planning and insights.
Mapping Tools: Utilizes Mapbox for GIS-related functionalities, like visualizing field and crop data.
User Management: Manages user accounts, authentication and auth.

The app requires PostgreSQL for the database, Redis for caching, and AWS S3 for media and static files. I’m looking for a hosting platform that is both affordable and highly reliable for these requirements. Any recommendations?

/r/django
https://redd.it/1hmhox1
Would it be possible to host a django backend on an Android device?

Also, would it be possible for that backend to access sqlite on said Android device?

Thanks.

/r/django
https://redd.it/1hmki0e
D Everyone is so into LLMs but can the transformer architecture be used to improve more β€˜traditional’ fields of machine learning


i’m thinking things like recommendation algorithms, ones that rely on unsupervised learning or many other unsupervised algos

i’ll look more into it but wanted to maybe get some thoughts on it

/r/MachineLearning
https://redd.it/1hmitcz
Authentication state management reactnative django

so i am a nub, and this is my first project i've created login page and signup and used drf to connect, everything works fine and when i create user and login then i've placed welcome,firstname. now i want to make my app acessible after login and i found out i've to learn autentication state but when searching i can't find any docs or proper tutorial related to the stuff. so plz help guys any docs or tutorial.

/r/django
https://redd.it/1hmjyke
A lightweight Python wrapper for the Strava API that makes authentication painless


**What My Project Does**

Light Strava Client is a minimalist Python wrapper around the Strava API that automates the entire OAuth flow and token management. It provides a clean, typed interface for accessing Strava data while handling all the authentication complexity behind the scenes.
Key features:

* Automated OAuth flow (just paste the callback URL and you're done)
* Automatic token refresh handling
* Type-safe responses using Pydantic
* Simple to extend with new endpoints
* No complex dependencies

**Target Audience**

This is primarily designed for developers who want to quickly prototype or build personal projects with Strava data. While it can be used in production, it's intentionally kept minimal to prioritize hackability and ease of understanding over comprehensive feature coverage.

**Comparison**

The main alternative is stravalib, which is a mature and feature-complete library. Light Strava Client takes a different approach by offering a minimal, modern (Pydantic, type hints) codebase that prioritizes quick setup and hackability over comprehensive features.

The code is available here: [https://github.com/GiovanniGiacometti/Light-Strava-Client](https://github.com/GiovanniGiacometti/Light-Strava-Client)

I'd love to hear your thoughts or feature suggestions!

/r/Python
https://redd.it/1hmlsys
A pytest plugin to run async tests 'concurrently'

**What My Project Does**

System/Integration tests sometimes can take really long time, due to spending huge amount of time waiting for external services responding. Pytest-asyncio make async tests testable, but run them sequentially. Pytest-xdist spinup multiple processes, blew up our fragile server during tests collection :(

* This plugin is to solve this by running asynchronous tests in true parallel, enabling faster execution for high I/O or network-bound test suites.
* Also give you high flexibility to specify tests that can run in parallel.
* Compatibility with Pytest-asyncio if you are already deep in rabbit hole.

**Target Audience**

The plugin is mainly targeted system/Integration tests, which is heavily bounded by I/O, network or other external dependency.

This plugin would more or less Break Test Isolation Principle. So make sure your tests is ok to run concurrently before you use this plugin.

**Comparison**

As mentioned above, unlike `pytest-asyncio`, which runs async tests sequentially, `pytest-asyncio-concurrent` takes advantage of Python's asyncio capabilities to execute tests concurrently by specifying async group.

**Try this out!**

Welcome to try this out, and let me know your feedback!

Github link: [https://github.com/czl9707/pytest-asyncio-concurrent](https://github.com/czl9707/pytest-asyncio-concurrent)
PyPI: `pip install pytest-asyncio-concurrent`

/r/Python
https://redd.it/1hmots3
I am using react for front end should I skip going deep about views and templates?

I am learning django, using the docs and django books written by william. My question is should skip learning too deep about templates and such that are used for creating ui and focus on only backend and jump straight to django for apis book?

/r/django
https://redd.it/1hmqlx7
YTMASC, take your YouTube music library to anywhere!

GitHub

I've been developing this tool for quite a while now, but was hesitant to share it because I had many things in mind to implement. However I'd like to share the project as about half of the stuff is in there and functional.

# What My Project Does

YTMASC gets your library by:

Scraping your YouTube library page (yes I know this is a horrible way of doing it but it's the easiest, I've something else in mind don't worry but it'll be the least of my priorities :D)
Imports RiMusic databases (also ViMusic since the fork didn't change the database schema)
A CSV file of your own that has 3 columns (\watch_id, artist, title)

And puts data from these sources into a simple json file. The information here is later used at the tasks you want to run.

Also, there are some tools to help you fix any issues you may run into (YouTube making the video unavailable, migration of old libraries etc.)

It's mainly available as CLI with a config file you can tinker with, I had written a tkinter GUI before but I don't want to maintain it anymore due to it being well, unmaintainable because I didn't think I'd be developing

/r/Python
https://redd.it/1hmnzg9
πŸŒ€ Interstice: The Zero-Player Game Simulator

PyPI | Website | GitHub

Hey r/Python!

I’m excited to introduce Interstice, a zero-player game simulator that explores emergent behavior on a 2D grid. This Python package brings to life complex systems where entities evolve according to simple rules perfect for those curious about simulation, artificial intelligence, and game theory.

# What My Project Does

Interstice is a zero-player game, meaning there’s no user input once the game begins. The simulation evolves autonomously based on pre-defined rules:

Entities: Different "agents" (like Demons and Soldiers) interact on a grid.
Interactions: These agents follow unique behaviors that create emergent patterns.
Visualization: See the grid evolve in real-time through a webpage.

This game lets you experiment with different rules, initial states, and grids to discover the fascinating results of these interactions.

# Target Audience

A fan of games like Conway's Game of Life or Langton's Ant,
Curious about emergent behavior in autonomous systems,
Interested in creating interactive simulations for fun or research

# Comparison

Interactive: Modify rules and observe changes on the fly.
Python-first: Built with Python developers in mind, making it easy to extend.
Creative: Design unique simulations that explore autonomous systems.

# Check it Out

PyPI Package: Install with pip install interstice
Website: [bananajump.com/interstice](https://bananajump.com/interstice)
GitHub Repository: https://github.com/interstice-stack/interstice

# πŸ† Win

/r/Python
https://redd.it/1hmiata
Friday Daily Thread: r/Python Meta and Free-Talk Fridays

# Weekly Thread: Meta Discussions and Free Talk Friday πŸŽ™οΈ

Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!

## How it Works:

1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.

## Guidelines:

All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.

## Example Topics:

1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.

Let's keep the conversation going. Happy discussing! 🌟

/r/Python
https://redd.it/1hn1s3d
Spotify Scheduler - Easily schedule your Spotify playlists to play at a specific time!

What My Project Does
Spotify Scheduler is an app that lets you schedule Spotify playlists to play at specific time (hours, minutes and seconds) (e.g. 8:00-8:15:30). You can use it to automate your listening experience and customize playback times according to your preferences. You can select different playlist for each time slot.

Target Audience
It's ideal for PA systems, school, or just automating music playback at home.

Comparison
I couldn't find any alternatives, so i did this app. The reasonable alternatives are radio automation softwares, but my app is much easier to use.

Github repository: https://github.com/sandrzejewskipl/spotify-scheduler

/r/Python
https://redd.it/1hn0rbo
Please help ASAP ngrok issues

i am having this issue always and now its not even working just showing up this,"Your ngrok-agent version "2.3.41" is too old. The minimum supported agent version for your account is "3.2.0". Please update to a newer version with `ngrok update`, by downloading from https://ngrok.com/download, or by updating your SDK version. Paid accounts are currently excluded from minimum agent version requirements. To begin handling traffic immediately without updating your agent, upgrade to a paid plan: https://dashboard.ngrok.com/billing/subscription."

what should i do i tried with ngrok update but it told me ngrok is running the latest update

please help

/r/djangolearning
https://redd.it/1hn5e8e
Made a self-hosted ebook2audiobook converter, supports voice cloning and 1107+ languages :)

What my project does:

Give it any ebook file and it will convert it into an audiobook, it runs locally for free

Target Audience:

It’s meant to be used as an access ability tool or to help out anyone who likes audiobooks

Comparison:

It’s better than existing alternatives because it runs completely locally and free, needs only 4gb of ram, and supports 1107+ languages. :)

Demos audio files are located in the readme :)
And has a self-contained docker image if you want it like that

GitHub here if you want to check it out :)))

https://github.com/DrewThomasson/
ebook2audiobook


/r/Python
https://redd.it/1hn6pzt
Flask vs fastapi

I am a newbie. I have a little building Web apps in flask but recently came to know about fastapi and how it's more "modern". Now I am confused. I want to start building my career in Web development. Which is better option for me to use? To be more exact, which one is more used in the industry and has a good future? If there isn't much difference then I want to go with whichever is more easier.

P.S: I intend to learn react for front end so even if I

/r/flask
https://redd.it/1hmn0n4
Made a cli tool to setup Django boring stuff

I been working on a lot of Django projects, lately and got tired of doing same old boring, repetitive stuff so i made this cli tool to do all that.

Check it out and lmk how i can make it better:

https://github.com/fulanii/djang\_setup
https://pypi.org/project/djang-setup/

/r/django
https://redd.it/1hnauso