pythondaily | Образование

Telegram-канал pythondaily - Python Daily

1102

Daily Python News Question, Tips and Tricks, Best Practices on Python Programming Language Find more reddit channels over at @r_channels

Подписаться на канал

Python Daily

D Monthly Who's Hiring and Who wants to be Hired?

For Job Postings please use this template

>Hiring: [Location\], Salary:[\], [Remote | Relocation\], [Full Time | Contract | Part Time\] and [Brief overview, what you're looking for\]

For Those looking for jobs please use this template

>Want to be Hired: [Location\], Salary Expectation:[\], [Remote | Relocation\], [Full Time | Contract | Part Time\] Resume: [Link to resume\] and [Brief overview, what you're looking for\]

​

Please remember that this community is geared towards those with experience.

/r/MachineLearning
https://redd.it/1ftdkmb

Читать полностью…

Python Daily

I created a simple note taking application in Flask

Hey r/flask!

Been studying flask for a couple weeks and I wanna share with you a project I deployed on PythonAnywhere - check it out!

https://flasknotes.pythonanywhere.com/

You can build your own as well, I've provided a comprehensive README on GitHub.

https://github.com/ghandylan/flask-notes

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

Читать полностью…

Python Daily

I made some Python applications that may be useful for those interested in the self hosted world

There is a variety of apps that can be used via a docker container or by running standalone.

For details, see: https://github.com/TheWicklowWolf

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

Читать полностью…

Python Daily

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/1ftak55

Читать полностью…

Python Daily

Built a 360 Geo Guesser Game with Django

https://i.redd.it/kb5lw2nmuyrd1.gif


Recently built a Geo Guesser Game over the weekend, curious to see what feedback I could get on this project. I made a blog post in partnership with this project that can be found:
https://geomapindex.com/blog/Building%20a%20New%20Geo%20Guesser%20Game/

Play the game here:
https://dash.geomapindex.com/geo\_game\_select

Built in Django / Dash, custom components and UI just an initial release.

Specific input I'm looking for:

What do you like / don't like about the UI?

What location should I make the next game for?

What features would you like to see added?

etcetera..

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

Читать полностью…

Python Daily

Introducing ZipNN: A Python Library for lossless Compressing tailored for AI Models

**What My Project Does:**

ZipNN is an open-source Python library that enables lossless compression of AI models, **reducing their size by 33% with BF16 format (yes, also Llama3.2)**. Effectively cutting down download times and easing the load on servers. The library integrates smoothly with Hugging Face, with just adding a single line of code. The decompression is fast and there are already compressed Models on Hugging Face that you can try right away and save time.

**Target Audience:**

ZipNN is developed for **AI researchers, data scientists, and software developers** who manage large neural network models. It is particularly useful for those seeking efficient ways to handle model size constraints in both academic and production environments. The library aims to facilitate better resource management without sacrificing the accuracy of AI models.

**Comparison with Existing Alternatives:**

**ZipNN is tailored for AI models (the NN stands for neural network)** and gives both a better compression ratio and speed.
For example, with BF16, ZSTD (the current state-of-the-art) saves 21%, while ZipNN saves 33%, and compression and decompression are x1.5 faster.


**Additional Resources and Examples:**

* **GitHub Repository:** [Visit the ZipNN GitHub Repository](https://github.com/zipnn/zipnn)
* **Kaggle Notebook – Practical Example:** [Using ZipNN with Llama-3.2 on Kaggle](https://www.kaggle.com/code/royleibovitz/huggingface-llama-3-2-example)
* **Example Directory:** For more

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

Читать полностью…

Python Daily

deltabase: manage delta tables in both local and cloud environments with ease

What My Project Does: 

DeltaBase is a lightweight, comprehensive solution for managing Delta Tables in both local and cloud environments. Built on the high-performance frameworks **polars** and **deltalake**, DeltaBase streamlines data operations with features like upsert, delete, commit, and version control. Designed for data engineers, analysts, and developers, it ensures data consistency, efficient versioning, and seamless integration into your workflows.

Here is an Example Notebook using DeltaBase to explore some Magic The Gathering data.

Target Audience: data engineers, analysts, and developers

Comparison: fits somewhere inbetween using polars and deltalake directly and databricks

https://github.com/uname-n/deltabase

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

Читать полностью…

Python Daily

Software Engineer Jobs database 9/25: Weekly posts of recently posted software engineer roles

Hey friends, every week I search the internet for software engineer jobs that have been recently posted on a company's career page. I collect the jobs, put them in a spreadsheet, and share them with anyone whose looking for their next role. All for free.

This week is the biggest job list I’ve curated to date. Over 150 roles from Software Engineering to Infrastructure Engineering, and includes opportunities across the globe. Due to popular demand, we’ve expanded beyond the USA to feature roles in Europe, South America, and Asia.

I hand pick the ones I know are good roles, with market salaries, and no glaring flags (ex: I generally only put roles with posted salary bands). Though its not easy to tell if the roles require leetcode or not.

The data is sourced by my own web scraping bots, paid sources, free sources, VC sites, and the typical job board sites. I spend an ungodly amount on the web so you don't have too!

About me, I am a senior software engineer with a decade of work history, and ample job searching experience to know that its a long game and its a numbers game.

If there are other roles you'd like to see,

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

Читать полностью…

Python Daily

Major Update: Simplify HTTP Security Headers in Django with secure.py

Hi Django developers,

A major update to secure.py has been released—a Python library that simplifies managing HTTP security headers in your Django applications. This release is a complete rewrite, leveraging modern Python 3.10+ features for better performance and usability.

Why Use secure.py with Django?

- Quick Setup: Apply BASIC or STRICT security headers with just one line.
- Full Customization: Control headers like Content-Security-Policy (CSP), HSTS, X-Frame-Options, Referrer-Policy, and more.
- Seamless Integration: Works smoothly with Django's middleware and view functions.

How to Integrate secure.py in Your Django Project

Middleware Example:

from django.http import HttpResponse
from secure import Secure

secure_headers = Secure.with_default_headers()

def set_secure_headers(get_response):
def middleware(request):
response = get_response(request)
secure_headers.set_headers(response)
return response
return middleware


Add set_secure_headers to your MIDDLEWARE list in settings.py.

Single View Example:

from django.http import HttpResponse
from secure import Secure

secure_headers = Secure.with_default_headers()

def home(request):
response = HttpResponse("Hello, world")
secure_headers.set_headers(response)
return response


This update makes it easier to enhance your Django app's security, allowing you to focus on building features without worrying about the intricacies of HTTP security headers.

GitHub: https://github.com/TypeError/secure

Feedback and suggestions are welcome.

Thanks, and happy coding!


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

Читать полностью…

Python Daily

Major Update: Easily Secure Your Flask Apps with secure.py

Hi Flask developers,

I'm excited to announce a major update to secure.py, a lightweight library that makes adding essential HTTP security headers to your Flask applications effortless. This latest version is a complete rewrite designed to simplify integration and enhance security for modern web apps.

Managing headers like Content Security Policy (CSP) and HSTS can be tedious, but they're crucial for protecting against vulnerabilities like XSS and clickjacking. secure.py helps you easily add these protections, following best practices to keep your apps secure.

Why Use secure.py with Flask?

- Quick Setup: Apply BASIC or STRICT security headers with just one line of code.
- Full Customization: Adjust headers like CSP, HSTS, X-Frame-Options, and more to suit your app's specific needs.
- Seamless Integration: Designed to work smoothly with Flask's request and response cycle.

How to Integrate secure.py in Your Flask App:

Middleware Example:

from flask import Flask, Response
from secure import Secure

app = Flask(__name__)
secure_headers = Secure.with_default_headers()

@app.after_request
def add_security_headers(response: Response):
secure_headers.set_headers(response)
return response


Single Route Example:

from flask import Flask, Response
from secure import Secure

app = Flask(__name__)
secure_headers = Secure.with_default_headers()

@app.route("/")
def home():
response = Response("Hello, world")
secure_headers.set_headers(response)
return response


With secure.py, enhancing your Flask app's security is straightforward, allowing you to focus on

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

Читать полностью…

Python Daily

How does sleep work under the hood in python

I was curious how sleep works under the hood? it accurate always?

Can it sleep less than the seconds specified? Can it sleep more than specified?

How is it implemented?

https://coderquill.bearblog.dev/beyond-the-pause-exploring-the-inner-workings-of-pythons-sleep/

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

Читать полностью…

Python Daily

Sharing common code

Writing a Django rest API.

There are 3 apps within the project.

One of the functions I am using needs a database table to function.

I want to use that function in all 3 of the apps.

I am still developing that function as the app grows so I do not want to package that function at this stage.

Not sure how to achieve this.

Thanks




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

Читать полностью…

Python Daily

(Almost) Pure Python Web App

A few weeks back I learned about htmx and quickly figured out that it actually allows you to do your frontend entirely in Python. So I decided to test if I can actually use it to make an SPA and how far can I go before i hit the limit. I spent a few weeks trying to create a messaging application (almost) entirely in Python. The end product is not exactly production-grade (there are minor UI bugs here and there), but I'm quite satisfied with it. This little project has allowed me to learn a great deal about htmx and its limits, and most importantly, it convinced me that htmx allows you to do quite a lot frontend stuff without having to touch JS.

Here's the project link if you're interested https://github.com/hanstjua/python-messaging

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

Читать полностью…

Python Daily

Join the Bot Battle: Create Your Own!

Hey everyone!

I wanted to share a fun project I’ve been working on involving bots that play a game where they can choose to either share or steal. The rules are simple: if both players share, they each get 10 points; if both steal, they each get 0; and if one shares while the other steals, the stealer gets 20 points.

I've implemented a few example bots, including one that always steals and another that always shares. But I encourage all of you to create your own bots with unique strategies! You can modify their behavior based on past choices, implement more complex decision-making algorithms, or even create entirely new strategies. The possibilities are endless!

If you're interested, I’d be happy to share the code and discuss ideas for bot strategies. Let’s see who can create the most cunning bot!

Happy coding!

below here is a list of some example bots

Cooly:

class Bot:
    #1 steal
    #0 split
    def init(self, name):
        self.name = name
        self.score = 0
     

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

Читать полностью…

Python Daily

PeepDB v0.1.4 - Support for MongoDB and SQLite added , GUI next time

# What My Project Does

I made a post a while ago about PeepDB. For people who don't know what the project is about, it is a CLI tool built in Python and my goal is to make it the easiest and fastest self hosted tool to view tables and data across multiple database types. I also want to make it a Python library so it can be used inside python scripts. Up until recently the project supported MySQL, MariaDB and Postgres databases.

# Target Audience (e.g., Is it meant for production, just a toy project, etc.)

peepDB is aimed at developers debugging database-driven applications, DBAs performing quick checks or audits, data analysts exploring table structures, and those learning about databases who want an easy way to explore data. It's suitable for use in both development and production environments

# Comparison

peepDB distinguishes itself from alternatives by focusing solely on quick table viewing, supporting multiple databases out-of-the-box. It requires no SQL knowledge to use, has a minimal footprint compared to larger database management tools

# What was added in this release

Because of popular demand support for MongoDB databases and SQLite, as well as enhanced security storage for passwords (not officially certified) and also the ability to switch between showing

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

Читать полностью…

Python Daily

What are your thoughts on using Django as an SPA backend?

I’m leaning more towards FastAPI, so try and change my mind!

For context, the frontend would be a Nuxt SPA with SSR. I like the Django admin and ORM, but building a REST API with Django just seems easier in FastAPI. I’d be using Django Ninja as I don’t want to pay for Django Rest Framework if I monetize the app (I can’t get past the “strongly encouranged to sign up for a paid plan” if the app is commercial).

Would you use Django or FastAPI for building the backend for an SPA?

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

Читать полностью…

Python Daily

Beginner Question - Why API?

I've recently been learning Django via tutorials and books solely as a personal challenge as I don't use coding in my career. That said, I am struggling to understand why REST API's (or API's in general), exist. I have created a blog API in a tutorial, but why? Beyond extracting data from a huge database, why isn't a regular website with data presented in html sufficient? As a corollary, what would be a good personal project that could utilize an API vs./on top of a standard django website?

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

Читать полностью…

Python Daily

Ban Transparency from Tim Peters

Tim has posted a summary of communications he had with the PSF directly prior to his recent 30-month suspension.

https://chrismcdonough.substack.com/p/ban-transparency-from-tim-peters

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

Читать полностью…

Python Daily

Why use Django when we have FastAPI for small userbase applications

People often mention that Django comes with ORM and admin support. However, I can use SQLAlchemy or raw SQL queries as well. While Django has built-in admin features, FastAPI offers a full-stack template repository with React, which has pretty decent features that meet most requirements. FastAPI is also fast due to its asynchronous nature and has a growing, enthusiastic community eager to help.

Am I wrong in saying this? Give me good reasons to use Django.

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

Читать полностью…

Python Daily

(Almost) Pure Python Webapp

What My Project Does

It's a small project to see how far I can go building a dynamic web application without touching JS, using mainly htmx and Flask. It's an exploratory project to figure out the capabilities and limitations of htmx in building web applications. While it's not production-grade, I'm quite satisfied with how the project turned out, as I have learned a great deal about htmx from it.

https://github.com/hanstjua/python-messaging

Target Audience

It's not meant to be used in production.

Comparisons

I don't see any point comparing it with other projects as it's just a little toy project.

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

Читать полностью…

Python Daily

Why iommi is so… weird
https://kodare.net/2024/09/30/why-iommi-is-weird.html

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

Читать полностью…

Python Daily

Paramorator – Simplify Parametrized Decorators, Make Type Checkers Happy ✅

In almost every project I work on I end up needing to create parametrized decorators at some point. That is, a decorator that can accept arguments before you tack it into the function or class you want to wrap. For example:

@database_session
def get_data(session: Session, key: str) -> dict[str, Any]:
...

@database_session(privileges="read_write")
def save_data(session: Session, data: dict[str, Any]) -> None:
...

It's not exactly rocket science, but to do this in a way that will make type checkers and IDEs happy can be a bit of a pain. [Paramorator](https://github.com/rmorshea/paramorator) is a dead simple (<100 line) library I created that makes that process a little easier. Here's how you could use it to implement the `database_session` decorator above:

from functools import wraps
from typing import Callable, Concatenate, Literal, ParamSpec, TypeVar

from paramorator import paramorator
from sqlalchemy.orm import Session

P = ParamSpec("P")
R = TypeVar("R")


@paramorator
def database_session(


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

Читать полностью…

Python Daily

Less activity in this community...

I (and I think many others as well) find flask so simple to work with and is great for rapid development. So why is this community so much less active than the other web-framework communities?

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

Читать полностью…

Python Daily

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/1fsif9y

Читать полностью…

Python Daily

¿Que camino tomar para ser desarrollador de python?

Hola, quiero ser desarrollador de python, osea ser un crack con ese lenguaje de programación. Pero soy totalmente autodidacta y quiero conocer métodos por gente más experta en el tema, acusa de que no quiero perder mi tiempo en aprender a enseñarme si no que quiero saber una estructura, un camino a seguir en el cual sea menos probable perderme. Cosas como cursos libros, recomendaciones proyectos entre otras cosas me serían útiles para saber que debo de hacer para cumplir con este objetivo.

GRACIAS POR SU ATENCIÓN:)
espero sus respuestas

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

Читать полностью…

Python Daily

Best way to deploy a django project with static files and a database?

I’ve just finished my django project and I’m looking to host it, however when I go to host it on vercel I follow the tutorials and for some reason my static files never load.

I was wondering is there a better way or a more informative tutorial on how to deploy it?

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

Читать полностью…

Python Daily

Looking for Advice: How’s the Job Market for Django Backend Developers?

I'm curious to know if there are any backend developers here who are using Django, DRF, Docker, AWS, RabbitMQ, Celery, etc. in their tech stack. If you're using this stack, how much are you earning based on your experience? What are your salary expectations?

Additionally, I'd love some guidance on compensation expectations as a fresher. I have experience working in production with this stack (internships and projects). What kind of salary can I expect as a fresher, and what should I aim for after gaining a few years of experience?

I’ve noticed that there seem to be a lot more opportunities for freshers in React, TypeScript, and Node.js compared to Django. While there are openings for Django, they’re often for senior roles. Would it be better to switch and focus on a different stack with more opportunities?

If you have experience with this stack, how has your career trajectory been? Any insights on pay scales or industry demand?

Thanks in advance!

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

Читать полностью…

Python Daily

WTF is ASGI and WSGI in python apps? - A writeup

I’ve been working on Python-based backend development for about three years now in various forms. I primarily use Django and FastAPI, although I initially started with Flask. However, during my backend work, I frequently encountered the terms ASGI and WSGI. For example, one of my Django deployment scripts included references to asgi_app and wsgi_app, and used gunicorn to deploy these apps. Although I initially dismissed these terms as implementation details but now got some time to go deeper. Here is a writeup:-

https://samagra.me/wtf/2024/09/27/gateway-interfaces.html

Edit TLDR:

ASGI and WSGI are protocols for communication between web servers and Python web applications. ASGI is newer, asynchronous, and more efficient for handling multiple requests simultaneously. WSGI is older, synchronous, and processes requests one at a time. The post explains their differences and provides example implementations of echo servers using both interfaces.

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

Читать полностью…

Python Daily

Zappa with Django, what's your experience.

I have been considering giving zappa a swing for my django rest framework app via aws hosting.
https://github.com/zappa/Zappa
Was wondering if anyone used it before. What are their experiences?

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

Читать полностью…

Python Daily

D Self-Promotion Thread

Please post your personal projects, startups, product placements, collaboration needs, blogs etc.

Please mention the payment and pricing requirements for products and services.

Please do not post link shorteners, link aggregator websites , or auto-subscribe links.

--

Any abuse of trust will lead to bans.

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.

--

Meta: This is an experiment. If the community doesnt like this, we will cancel it. This is to encourage those in the community to promote their work by not spamming the main threads.

/r/MachineLearning
https://redd.it/1fru46i

Читать полностью…
Подписаться на канал