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
What the hell is going on with type hinting these days

When I first learned python back in versions 3.6 and 3.7 I regarded type hinting as a purely styling feature. It was well rooted in my mind that python code with or without type hinting will run the same and it is used only for readability -- basically just us developers being kind to each other.

Nowadays more and more packages are using type hinting for core functions. SQLAlchemy is using it to declare SQL column types (Mapped), FastAPI + Pydantic is using it for HTTP payloads and auto-documentation, and dataclasses uses it to construct (shockingly) data classes.

Don't get me wrong, I'm supportive of type hinting\\annotations. I'm also well aware that all of these packages will execute just fine without it. But maybe it's fair to say that in modern python applications type hinting is a core feature and not just for styling and garnishing.

Edit: I actually find type annotations very useful, I'm not against it. I wanted to discuss whether it's really "optional" due to its widespread integration in libraries. I like u/all4Nature point: I'm thinking on it from a software engineer prespective, data analysts will probably disagree that type hinting is as widespread as I thought.

/r/Python
https://redd.it/1itzac1
My Ever-Expanding Python & Django Notes

Hey everyone! 👋

I wanted to share a project I've been working on: **Code-Memo** – a personal collection of coding notes. This is NOT a structured learning resource or a tutorial site but more of a living reference where I document everything I know (and continue to learn) about Python, Django, Linux, AWS, and more.

Some pages:
📌 **Python Notes**
📌 **Django Notes**

The goal is simple: collect knowledge, organize it, and keep expanding. It will never be "finished" because I’m always adding new things as I go. If you're a Python/Django developer, you might find something useful in there—or even better, you might have suggestions for things to add!

Would love to hear your thoughts.

/r/Python
https://redd.it/1itzsnz
Affordable database options

Coming from the enterprise world, I am used to just spinning up an AWS RDS instance (or similar) for a project to use as a database. The nice thing about that is they have all the backups, metrics and everything nicely done for you. But for a personal project or micro SaaS, paying even $20 per month for a micro instance seem excessive to me.

I heard some people go as simple as using a sqlite in a small project. I was also thinking just a VPC where I have Django and Postgres in docker-compose. Naturally I can make my own backups from the docker instance. But using postgres in docker-compose just feels a bit "flying blind" sort of thing as I do not have metrics.

But in an optimal situation I would have the following:
- cheap
- some way to visualize if database performance is a bottleneck
- possibility to grow the instance to give it better performance if user count grows

Any recommendations?

/r/django
https://redd.it/1iu8eho
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/1iudeoy
In 2025 will there be a viable freelance market for Python developers other than Fiver or UpWork

Posted this question a few weeks ago but I guess it was on the wrong day. Since it free text Friday I will try again.

Are companies looking for freelance Python developers for hourly or statement of work, fixed price scripting work from places other than Upwork or Fiver or similar sites?

/r/Python
https://redd.it/1iudwva
Django for beginners - William Vincent

Everything is good with this book. I am able to understand easily but the only problem i am facing rn is ,at some points , after copying the exact code from the book the code isn't working.
Please help

/r/django
https://redd.it/1iu6yyn
R Detecting LLM Hallucinations using Information Theory

LLM hallucinations are a major challenge, but what if we could predict when they happen? Nature had a great publication on semantic entropy, but I haven't seen many practical guides on detecting LLM hallucinations and production patterns for LLMs.

Sharing a blog about the approach and a mini experiment on detecting LLM hallucinations. BLOG LINK IS HERE

1. Sequence log-probabilities provides a free, effective way to detect unreliable outputs (\~LLM confidence).
2. High-confidence responses were nearly twice as accurate as low-confidence ones (76% vs 45%).
3. Using this approach, we can automatically filter poor responses, introduce human review, or iterative RAG pipelines.

https://preview.redd.it/zu9u6q7n1dke1.png?width=1436&format=png&auto=webp&s=73473fc975f900a27c0d1a64d020efca2f415ba0

Love that information theory finds its way into practical ML yet again!

Bonus: precision recall curve for an LLM.

https://preview.redd.it/rbne2tjj2dke1.png?width=1432&format=png&auto=webp&s=72c5754f932daa7a632d6e0d9c0ed17e54530965

/r/MachineLearning
https://redd.it/1iu9ryi
Appreciation post for PyCharm

I spent the entire day today working on some complex ETL. So many hours spent building, testing, fine-tuning. Once I got it working I was updating the built in sphinx documentation, running the ‘make html’ command several times in the terminal. Turns out I had at one point in this active terminal, done a ‘git reset —hard’ command. While pressing up to cycle through commands, I accidentally ran git reset hard. All my work for the entire day was GONE. I have f’d up at work before, but never this bad. I was mortified.

I had a moment of panic, and then asked chatGPT if there was any way to recover. The git log options it gave did not work. I then asked if PyCharm had any solutions for this. THERE IS A LOCAL HISTORY FEATURE THAT SAVED ME. It saves your changes and I was able to recover it all. Thank you to JetBrains for this amazing product. Four years with this product and I’m still learning about amazing features like this.

/r/Python
https://redd.it/1iume26
Login Functionality not working

I'm making a password manager app for my school project. So i decided to use SQLite since the project is small scale, and I'm hashing my passwords too. When i try to login the browser returns an error, which says :

" user_id = session['user'\]['id'\]

\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^

KeyError: 'id'
"
I've tried using ChatGPT, and other chat bots to see how I can fix the code but I've been stuck on this for three hours now. The function where the error is being returned from is this, and there's the login function too :

Any help would be greatly appreciated.

@app.route('/dashboard')
def dashboard():

    if 'user' not in session:

        print("User not found!!")
        return redirect(urlfor('login'))
   
    print(session)
   
    user
id = session'user''id'

    with sqlite3.connect('database.db') as conn:
        cursor = conn.cursor()


/r/flask
https://redd.it/1iuqtth
Follow the yearly PyCon if you want to get better at using Python

One very under-appreciated advice I'm often giving to people starting with Python (or wanting to dive much deeper) is to follow the annual Python Conference (PyCon) and watch a few talks.

By far not all of them are relevant for most people. Some thing go very deep in how the language works intrinsically, or marginal optimizations for machine-learning stacks, but by and large it's really one of the best ways to keep up with the language and the community.


Just search "PyCon 20xx" (e.g 2024) on Youtube and you'll find most/all of them there.


For example, one talk I absolutely love from the PyCon 2018 (yes, 2018!) is a talk by Hillel Wayne on testing better: https://www.youtube.com/watch?v=MYucYon2-lk

Some things get old, deprecated, some things are just making you a better dev.

/r/Python
https://redd.it/1iurnjd
Is it possible to make vs code like pycharm pro for django development?

I used to use PyCharm, but I'm finding VS Code to be much better for working with AI tools. There are features from PyCharm Pro when working with django. For example, PyCharm provides autocompletion for queryset filtering for all fields (like __gte, __in, etc.), suggests all URL names when using reverse, and has awareness of context variables in templates.

Is there a way to customize VS Code to replicate these PyCharm Pro features?

/r/django
https://redd.it/1iumhwr
🔴 redpoint - Python library for converting climbing grades between different grading systems

GitHub: [https://github.com/ciszko/redpoint](https://github.com/ciszko/redpoint)

**What my project does**

In rock climbing, various climbing styles (sport, boulder, ice) have their own grading systems. What's more, some systems were initially developed in confined geographical areas, climbing areas, countries or continents. `🔴 redpoint` is a Python library that simplifies climbing grade conversions. It supports a wide range of climbing grade systems (sport, bouldering, and other) from [thecrag.com](http://thecrag.com), allowing users to easily convert between systems (e.g., Yosemitee Decimal System to French), compare the difficulty of grades, and even generate ranges of equivalent grades.

The features include:

* Converting the grades between the systems
* Comparing the difficulty of grades (even between the systems)
* Converting a grade into a range of grades from the different system
* Iterating over grades from specific systems
* Finding X harder or lower grade

I've always wanted to combine programming and climbing. I didn't find any Python library that would cover that many grading systems so I decided to give it a go. Besides that, I had the opportunity to upload my library to pypi which was a new experience.

**Target Audience**
(mostly rock climbers)
I find it hard to to compare the grades in my head, especially when I've never been to a specific climbing area that uses

/r/Python
https://redd.it/1iura9d
New to coding. Is it always this difficult?

I’m transitioning from bartending to data analysis at 37yo through an online course called CareerFoundry and I think I’ve made a huge mistake. I do not feel prepared to enter the job market with my new skills. For example It has taken me 6 full hours today just trying to START a project in VSCode and I don’t understand any of the troubleshooting I’m doing. (I don’t remember learning about virtual environments during the course) we did the whole course in Jupyter and now I find out vscode is the standard and it’s an entirely different platform I can’t figure out. I feel like every step forward is 100 steps back.

Could anyone share their “aha!” Moment with coding? I could really use the encouragement. Or have I made a huge mistake and this just isn’t for me? Thanks for reading this far!! Any advice is appreciated.

/r/Python
https://redd.it/1iuyt0y
First Independently Developed Production Level Website

I have an appointment with a state wide organization about creating a website for them that provides both a public facing landing page and a member exclusive portion which will include location to get resources, calendar of events, requests to the administration, polling, and documentation resources for the legal documents of the organization (not sensitive information).

My experience is in making static websites (I have made two for other smaller organization) which were very well received. Modernizing backends for Spring web applications (also 2 times), and creating a series of smaller web application using lightweight frameworks like Flask. I have never independently created a production level website on a modern framework for an organization with more than 100 members.

This website will not be expected to be tremendously high traffic (at highest surge times, a couple times a year, about 2 thousand concurrent users) (I understand that is high traffic however that will not be login members using it, instead it will be checking the current events tabs)

I plan to develop this using a Django framework. My experience with Django is limited reading only the intro material of documentation and creating a few apps with it. That being said it has been

/r/django
https://redd.it/1iuvexl
Why is return not directly inbuilt into redirect() & render()???

I keep forgetting to include the return before I call redirect and render which is annoying. Curious if there are any situations where you would use redirect() or render() but not use return before it for your views?

/r/djangolearning
https://redd.it/1iuaw8q
Saturday Daily Thread: Resource Request and Sharing! Daily Thread

# Weekly Thread: Resource Request and Sharing 📚

Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!

## How it Works:

1. Request: Can't find a resource on a particular topic? Ask here!
2. Share: Found something useful? Share it with the community.
3. Review: Give or get opinions on Python resources you've used.

## Guidelines:

Please include the type of resource (e.g., book, video, article) and the topic.
Always be respectful when reviewing someone else's shared resource.

## Example Shares:

1. Book: "Fluent Python" \- Great for understanding Pythonic idioms.
2. Video: Python Data Structures \- Excellent overview of Python's built-in data structures.
3. Article: Understanding Python Decorators \- A deep dive into decorators.

## Example Requests:

1. Looking for: Video tutorials on web scraping with Python.
2. Need: Book recommendations for Python machine learning.

Share the knowledge, enrich the community. Happy learning! 🌟

/r/Python
https://redd.it/1iv5pd3
I'm unemployed developer

I know web development with mern stack, python django and mobile application development with react native.

Is there any freelance clients or software agencies who can help me?

/r/django
https://redd.it/1iv9c7n
Django/vite/scss

Has anybody had any success with Django-vite and using scss and maybe have a repo I could look at? Currently trying to get this set up and running into a few issue. Not using any FE frameworks. Using a main.js file as the entry point currently this just has main.scss as an import. It works fine in dev but in production on Heroku the browser is trying to read the .scss file and therefore getting a MIME failure and the rest of the js won’t run. CSS file does work though that vite build from the scss.

/r/django
https://redd.it/1iv1a7f
D Dimensionality reduction is bad practice?

I was given a problem statement and data to go along with it. My initial intuition was "what features are most important in this dataset and what initial relationships can i reveal?"

I proposed t-sne, PCA, or UMAP to observe preliminary relationships to explore but was immediately shut down because "reducing dimensions means losing information."

which i know is true but..._____________

can some of you add to the ___________? what would you have said?

/r/MachineLearning
https://redd.it/1iuwgcu
Authentication to the Swagger UI

Hello flask folks,

Creating endpoints in the flask and integrated with the Swagger UI (flasgger).

I wanna add authentication to the Swagger UI?

I newbie to reddit.if any mistakes said by me, feel free to forgive. 😁😁

/r/flask
https://redd.it/1iv9xxl