pythondaily | Education

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

Subscribe to a channel

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

Sunday Daily Thread: What's everyone working on this week?

# Weekly Thread: What's Everyone Working On This Week? 🛠️

Hello /r/Python! It's time to share what you've been working on! Whether it's a work-in-progress, a completed masterpiece, or just a rough idea, let us know what you're up to!

## How it Works:

1. Show & Tell: Share your current projects, completed works, or future ideas.
2. Discuss: Get feedback, find collaborators, or just chat about your project.
3. Inspire: Your project might inspire someone else, just as you might get inspired here.

## Guidelines:

Feel free to include as many details as you'd like. Code snippets, screenshots, and links are all welcome.
Whether it's your job, your hobby, or your passion project, all Python-related work is welcome here.

## Example Shares:

1. Machine Learning Model: Working on a ML model to predict stock prices. Just cracked a 90% accuracy rate!
2. Web Scraping: Built a script to scrape and analyze news articles. It's helped me understand media bias better.
3. Automation: Automated my home lighting with Python and Raspberry Pi. My life has never been easier!

Let's build and grow together! Share your journey and learn from others. Happy coding! 🌟

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

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

Python Daily

D Flagged a potential dual submission case to program chairs but they don't care.

Regarding https://www.reddit.com/r/MachineLearning/comments/1f7axjm/d\_potential\_dual\_submissions\_2\_similar\_iclr\_24/

A while ago I came across these two papers, and I noticed they are highly similar. I sent an email to ICLR 2024 program chairs asking them about this, including:

Katerina Fragkiadaki (CMU)

Mohammad Emtiyaz Khan (RIKEN AIP, Tokyo)

Swarat Chaudhuri (UT Austin)

Yizhou Sun (UCLA).

https://preview.redd.it/4ia3rvgr3mrd1.png?width=1390&format=png&auto=webp&s=a6697aa0b319f3b5b2821073dc6b2e48eea99357

But none of them replied at all. It's clear that they don't care anything about integrity and honesty. No respect for rules.

Science is just a game of money.

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

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

Python Daily

Learning a language other than Python?

I’ve been working mostly with Python for backend development (Django) for that past three years. I love Python and every now and then I learn something new about it that makes it even better to be working in Python. However, I get the feeling every now and then that because Python abstracts a lot of stuff, I might improve my overall understanding of computers and programming if I learn a language that would require dealing with more complex issues (garbage collection, static typing, etc)

Is that the case or am I just overthinking things?

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

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

Python Daily

Lightweight Celery alternative

I just want to give this package some recognition. I have started using it as a background worker and I love it.

It's maintained by the people at Dabapps and is well worth a look if you're looking to create asynchronous tasks in your Django app.


Check out django-db-queue

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

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

Python Daily

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

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

Python Daily

D R What is the next frontier to AI?

I work as an undergraduate research assistant. I'm curious about what do you think is the new frontier for AI?

For example, we're full of LLM models, which are so good for language and vision tasks. But they are very poor when it comes to planning, control, real-world interaction, out-of-distribution thinking, etc.

What are those topics that remains at the shadow within research niches, but have the capacity to become the new cutting-edge paradigm? Biased opinions are very encourage.

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

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

Python Daily

How do I test this custom template tag I created for my project?

Here's a custom template tag I created for my project:

@register.simple_tag(takes_context=True)
def custom_csrf_token(context):
context_csrf_token = context.get("custom_csrf_token")
if context_csrf_token is not None:
csrf_token_input = mark_safe(f'<input type="hidden" name="csrfmiddlewaretoken" value="{context_csrf_token}">')
else:
request = context["request"]
csrf_token_input = mark_safe(f'<input type="hidden" name="csrfmiddlewaretoken" value="{get_token(request)}">')
return csrf_token_input

For it, I want to write two tests. One who triggers the `if` , the other who triggers the `else` I have troubles with the `else` one. In it, I need to render a fake template with my tag in it and pass a request in the context when I render it. Here's what it looks like for now:

class TestsCustomCsrfToken(SimpleTestCase):
def setUp(self):
self.factory = RequestFactory()



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

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

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

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

Python Daily

First Work Project

I’m starting my first work project and settled on using Django.

I’ve done some front end projects before but nothing that went into production. Just some portfolio stuff with flask and JS.

I spend most of my days doing data engineering work or data science stuff. The organization is moving off of some old COBOL based stuff and into some staging databases, still on prem. Well, there’s a huge technical gap. The resident tech talent is mostly from 20 years ago and is focused solely on SQL and DOS like functionality. I’m the personality who’s trying to drive them to something more modern.

The enterprise that owns our org has power platform licenses but none of the cloud environments to back it which make them accessible or interoperable with Python. Yet, they’ve hired a few people who are mass producing power apps which I know will not be scalable or sustainable in the long run.

I’ve had our IT department start setting me up a proper dev environment using some containers which will be used to host the application.

The first proof of concept is going to be replicating a single user interface which simply allows them to update / insert a row to

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

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

Python Daily

How do I help the world using django?

So, I'm a 24M. I was introduced to django this year on May during my industrial attachment. My supervisor was very kind and helped me through any challenges I faced with django. As a result I learnt very quickly. Something also happened, the way this guy helped me sparked something in me. I feel like using my skills to help people. Problem is, i dont know how to do it. Are there platforms I can use my django skills to help people who are in need? Or is there any way i can just help people using this skill? Thanks.

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

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

Python Daily

Second Django app in project not working

I'm working on a Django project with two apps, and I'm running into issues with the second app, called Management. The first app, Base, works perfectly, but after setting up Management using the same steps, it’s not functioning as expected. I’m not sure what I might be missing.

Here’s what I’ve done:

Created Management using python manage.py startapp

Added Management to the INSTALLED_APPS in settings.py

Defined models, views, and URLs for Management

Applied migrations for Management (python manage.py makemigrations and python manage.py migrate)

Linked Management's URLs to the main urls.py using include()

Checked for typos and configuration issues
Despite following the same steps I used for the Base app, the Management app isn’t working. Am I overlooking something when setting up multiple apps in Django? Any help would be greatly appreciated!

This is the repo incase you want to take a look

https://github.com/kingmawuko/GigChain.git



EDIT:

The issue was resolved by placing the Base app's URL pattern at the bottom of the urlpatterns in the main urls.py. This ensured that more specific routes, such as for the Management app, were matched before the fallback routes in Base.





/r/djangolearning
https://redd.it/1fqbfj1

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

Python Daily

Help help

For the past years, I've been developing using react and nodejs. But now I've decided to learn django. So, for database, I'm looking for a free cloud database. Also, for node, we can save image in cloudinary and retrieve, similarly, what can be used in django? Or has anyone used cloudinary for django too? Any suggestion would be highly highly appreciated.

/r/djangolearning
https://redd.it/1fqlwyn

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

Python Daily

A simple example of a Dockerized Flask application using Ngrok to expose the local server to the internet, with a proxy integration to help mitigate potential Ngrok connection issues.
https://github.com/mdeacey/docker-flask-ngrok-proxy

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

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

Python Daily

Proper access control

Hello everyone! I'm making a management system for an online school and I need to do a rather convoluted authorization,

where I need to check the relationship between two users before giving access to a particular resource

I have written the rules as follows (CUD - Create, Update, Delete):

Student:

* Can view their own and their teacher's media
* Can only edit his/her profile
* Can view his/her profile and his/her teachers' profile
* Can only perform CUDs on their own media files.

Teacher:

* Can view his/her own media and media of attached students
* Can only edit his/her profile
* Can view his/her profile and the profile of attached students
* Can perform CUD with his/her own media and the media of attached students

Admin:

* Can attach students to teachers
* Can view all users' media
* Can edit the profile of all users
* Can view the profile of all users
* Can perform CUD with all users' media

I can't figure out how I can do it right without creating a huge amount of groups and permissions. Can you help me?

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

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

Python Daily

I have a complicated task that I need insight on

I'm creating a project, we'll call this project 'My Phone'. My Phone has many apps on it.

* Weather
* Notes
* Calculator

I want to be able to maintain **each app in it's own repository**, as opposed to putting them all in the 'My Phone' repository, but **I still want them to be linked**.

**FURTHERMORE,** I want to deploy each app individually.

For visualization purposes, I want to be able to go to:

>[weather.myphone.com](http://weather.myphone.com)

instead of

>[myphone.com/weather](http://myphone.com/weather)

I don't know if this makes sense or if it's even possible. please help

I've been led to understand this may be the worst idea in the history of programming SO ToT, please let me know what you think is a better idea?

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

Читать полностью…
Subscribe to a channel