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

Tips on structuring modern python apps (e.g. a web api) that uses types, typeddict, pydantic, etc?

I worked a lot on python web/api apps like 10-15 years ago but have mostly used other languages since then. Now I'm back to building a python app, using all the latest tools like type hinting, FastAPI, and Pydantic which I'm really enjoying overall.

I feel like code organization is more of a headache than it used to be, though, and I need better patterns than just MVC to keep things organized. E.g. a simple example - if I define a pydantic class for my request body in a controller file and then pass it as an argument to a method on my model, there's automatically a circular import (the model needs to define the type it takes as its argument, and the controller needs to import the model).

I know you can use "if TYPE_CHECKING" but that seems messy and it means you can't use the type at runtime to do something like "if type(foo) = MyImportedType".

What are some good file structure conventions to follow that make this easier?

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

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

Python Daily

SQLAlchemy Helper (for VS Code)

Hey guys, wanted to share this VS Code chat extension that makes it easier to use SQLAlchemy. It's basically a RAG system trained on SQLAlchemy's docs that developers can query through VS Code.

https://marketplace.visualstudio.com/items?itemName=buildwithlayer.sqlalchemy-integration-expert-jYSzG

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

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

Python Daily

🇧🇷 Marketplace de Veículos. Consegue me ajudar?

Fala galera, beleza?



Meu nome é João, e to desenvolvendo um Marketplace de Veículos. Obviamente pretendo atuar regionalmente a princípio, com plano de escalar pra nível estadual, a depender da adoção do mercado. Pra resumir bastante trabalho com revenda de veículos usados já tem uns 8 anos. Minha família empreende no ramo tendo mais duas outras empresas do mesmo nicho na nossa cidade, e eu recentemente (junho de 2022) abri a minha própria loja de motos. Diante dessa experiência prévia no mercado de revenda de veículos, ao observar o quanto do orçamento de marketing é direcionado pra esses marketplaces como WebMotors, iCarros, e muitos outros a nível regional do seu Estado, pensei: tem espaço pra mais um.



Não é uma ideia inovadora, nem disruptiva, é um mercado consolidado e validado com grandes players bem estabelecidos. Mas a depender da região e da abordagem de marketing e vendas, existe uma lacuna.



Vamos falar de desenvolvimento. Tenho uma pequena experiência com Flask, HTML, CSS, Bootstrap e JS. Já construí alguns projetos com essas tecnologias e me atenderam bem até onde precisei ir. Mas quando se trata de um marketplace de veículos com múltiplos usuários, múltiplas sessões simultâneas, alto volume de upload de imagens, eu sinceramente

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

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

Python Daily

Hello, any solution to this error?

https://preview.redd.it/16vnss1u1opd1.png?width=1920&format=png&auto=webp&s=d696e4e490922125618d1a8a4098e46107ffa7b2



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

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

Python Daily

Django unit tests are now supported in VS Code (1.93)
https://code.visualstudio.com/updates/v1_93#_python

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

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

Python Daily

D The autoencoder architecture for vision in 2024?

I’d like to train autoencoder on images to get useful latent representation, so I can later use it to train a diffusion and autoregressive model for image generation. What is the SOTA architecture I should pick?

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

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

Python Daily

Introducing FastAgency: the fastest way to deploy a console or web app from your AutoGen workflow

Hey everyone! I’m one of the core developers of **AutoGen**, a very popular open-source framework for developing AI agents with over 30k stars on GitHub.

I’ve been working with my team on an open-source project called **FastAgency**. We designed it to help developers quickly take a prototype built in AutoGen straight to production. We just released a version that lets you run your workflow as either:

A simple console application (great for debugging)
A web application using Mesop with just a single-line change!

We would love for you to check it out, give feedback, or contribute! The project is open-source, and contributors are always welcome :)

https://github.com/airtai/fastagency

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

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

Python Daily

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

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

Python Daily

Simon Willison: "Things I've learned serving on the board of the Python Software Foundation"

Pretty good insights on what the PSF is and how it relates to the Python language from Django co-creator Simon Willison:

https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/

The entire post is worth reading, but here are links to specific sections:

[What is the PSF?](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#what-is-the-psf)
The PSF employs staff
[A lot of this is about money](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#a-lot-of-this-is-about-money)
The PSF does not directly develop Python itself
[PyPI—the Python Package Index](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#pypi-the-python-package-index)
PyCon is a key commitment
[Other PSF activities](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#other-psf-activities)
Work Groups
[Acting as a fiscal sponsor](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#acting-as-a-fiscal-sponsor)
Life as a board member
[The kinds of things the board talks about](https://simonwillison.net/2024/Sep/18/board-of-the-python-software-foundation/#the-kinds-of-things-the-board-talks-about)
Want to know more?

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

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

Python Daily

R First Published ML Paper - From a quick glance does anything stand out in terms of peer review notes?

# Long story short I've published my first paper through a conference proceeding, but my peer review was a little short. I am wondering if anyone here with experience in time series forecasting or XAI has any notes for me? would be kindly appreciated. No problems if not.

https://dl.acm.org/doi/abs/10.1145/3674029.3674035 (Is open access under ACM).

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

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

Python Daily

Service Reliability Math That Every Engineer Should Know

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

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

Python Daily

Open-source Dash app that features dashboards with varying levels of complexity

What My Project Does: This Dash app, whose source code is available here, demonstrates how to use Dash to create a series of interactive online visualizations, ranging from from simple charts to more complex interactive setups.

Target Audience: These dashboards and their corresponding source code will hopefully serve as a useful reference for developers who are evaluating different ways to represent data using Dash.

Comparison: This project has been released under the MIT license and thus offers developers more flexibility than projects released under more restrictive terms. In addition, this app may be more cost-effective than ones created with propietary tools like Tableau, as such tools may require the user to pay a significant amount in licensing fees. Finally, the live demo (available via the following link) allows users to easily review each of the sample dashboards.

Click here to view the Google Cloud Run-hosted version of this app. (If no one has accessed the app recently, it will take several seconds to load, as the app is set to run on demand in order to save costs.)


## Dashboard overviews:

The Fixed Dashboard page shows a very simple dashboard setup that lacks user-defined filter and comparison settings.


The Simple Interactive Dashboard

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

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

Python Daily

Maelstrom 0.12.0: Isolate your tests, and run them fast.

We’re excited to announce Maelstrom 0.12.0, a test runner for Python that can run tests locally or on a cluster. Our new UI features real-time information about running tests, output from the build, and a new progress bar.

Maelstrom is a suite of test runners, built on top of a general-purpose clustered job engine. Maelstrom packages your tests into micro-containers, then distributes them to be run on an arbitrarily large cluster of test-runners, or locally on your machine using a custom-built, super-fast container runtime.

https://github.com/maelstrom-software/maelstrom

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

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

Python Daily

I don't know shit about my project

I want to build and deploy a SpongeBob API similar to the One Piece API and I was having a couple of questions that maybe some of you can help me with

1.- Is it legal? I'm not quite sure what data can I and cannot use. For instance I'm pretty sure I can't use images from the show, but what about data about characters, places, songs related to SpongeBob. The whole point of this is to finally have something mine on internet and people can see it, if I can't show this legally I don't see the point on bulding it

2.- Can I have a section to receive donations? (again, is it legal?)

3.- Is it a good idea/practice to use the same django project for the web app (documentation, about page, donations, contact) and for the API? Or is it better to make 2 different projects and maybe different frameworks/libraries for the front?

4.- what security concerns do I have to keep in mind? I want it to be a public API I was thinking about limiting the request per minute and maybe store the data in the cache to improve perfomance, what else do I

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

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

Python Daily

I created a modern and customizable tooltip library for PyQt and PySide

Hey guys,

since I couldn't find any good libraries for showing modern-looking and customizable tooltips in PyQt, I made one myself.



What My Project Does:

It supports fixed placement, automatic placement, fallback placements, an optional triangle, animations, delays and much more. Basically anything can be completely customized and it's extremely easy to use. Also, since it's developed with QtPy, an abstraction layer for multiple versions of PyQt and PySide, you can use it with PyQt5, PyQt6, PySide2, and PySide6.



Target Audience:

This is useful for any Python developer who is working with PyQt or PySide and wants to add modern and customizable tooltips to their application.



Comparison:

To my knowledge, there are no comparable libraries out there.



Preview image: https://github.com/user-attachments/assets/0313ffc7-560b-4665-a652-e1e2601fcbaa

Demo video: https://github.com/user-attachments/assets/fa768d30-f3cc-4883-aa8b-fed3a8824b23

Github: https://github.com/niklashenning/pyqttooltip



Hope some of you will find this useful :)

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

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

Python Daily

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

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

Python Daily

Best way to eliminate or reduce redundancy in views?

I'm in the process of building a live chat using django\_channels and frontend as reactJS. In this project, I'm trying to be more familiar with class based views and utilize them as much as I can . The question that I have is what is the convention or best practice when eliminating or reducing redundancy in the views. I have three sets of snippets in the bottom and all of them are using .list() method to implement .filter(). Is there a way to reduce this or better way to this with less code? Any info will be greatly appreciated. Thank you very much.

class CommunityMessagesView(ListAPIView):
queryset = CommunityMessage.objects.all()
# authentication_classes = [TokenAuthentication]
# permission_classes = [IsAuthenticated]

def list(self, request, *args, **kwargs):
queryset = self.get_queryset().filter(community__name=kwargs['community_name'])
serializer = CommunityMessageSerializer(queryset, many=True)


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

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

Python Daily

Looking to hire Django developer with strong frontend skills

I run a med student education platform (Geeky Medics) built on Django with several hundred thousand users. You’re welcome to sign up and explore the app's various elements (app.geekymedics.com). I've been working on it for the last 14 years, alongside my training as a doctor.

We already have a couple of awesome, senior Django developers, but I’m looking for someone who is particularly strong in frontend development/UI/UX (even if junior from a Django perspective). 

Our stack is straightforward Bootstrap 5, JS and some recent sprinklings of HTMX (no fancy JS frameworks).

We’re fully remote and async. I'm looking for someone able to commit to 1-3 days a week, ideally. I'm happy to discuss rates, etc. You can message me with some details of your experience, and I’ll get back to you ASAP.  

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

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

Python Daily

I am using flask and bootstrap. I wondering, what is the best way to create admin features for flask?

Just to clarify I'm asking because I never built admin features before. I am just wondering what are the standard features.



I have a few options.



1)

I could use flask admin .

2)

Someone recommended this https://flask-appbuilder.readthedocs.io/en/latest/ .

3)

I could write the code myself the problem is I don't know all the features to implement.

I could write a wrapper like "@login_required" called "@admin_required". But like stated what other features should I add.

4)

An Alternative way.

If someone has any other suggestions for an alternative way please state them.

Thank you for the responses.











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

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

Python Daily

Django-Routify for routing your views in classic Django

Just dropped beta version for my own package which provide decorator routing for your views.

More details in PyPi:
https://pypi.org/project/django-routify/

I'll also appreciate for star in repo ;D

Simple example:

https://preview.redd.it/pa22t6540kpd1.png?width=1039&format=png&auto=webp&s=ae349c01d5e9d93dcfdbfa82176c5eab7aec7dc0

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

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

Python Daily

Space Invaders in Python - Tutorial

Hello friends!

There is a continuation of the game development series in Python. This time, it’s Space Invaders.

Space Invaders in Python for Beginners | Programming Basic Concepts (youtube.com)

Enjoy!

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

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

Python Daily

This is outrageous what do you do all day

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

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

Python Daily

I made an (opinionated) little Django DRF API template for anyone to use

This template focuses on my take for a nice and realistic Django developer experience.

Github repo: https://github.com/laaraujo/django-api-template

* Containers (Docker and Compose) for anything but tests
* Django Rest Framework
* PostgreSQL (sqlite3 for automated tests)
* Pytest + Coverage for testing
* Djoser for authentication (with email + password auth by default)
* Automatically generated API docs
* Whitenoise for static file serving (docs and admin)
* Pre-commit hooks for linting (ruff)
* A nice and clean Makefile for local dev env commands
* Github Actions for running tests on push and/or PR submissions
* Dependabot with monthly checks

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

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

Python Daily

Best Django learning books from zero to very expert?

What books do you recommend that will teach you Django from the beginning phase to the most deeply and very advanced one?

Thank you in advance!

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

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

Python Daily

Best way to communicate database updates to Flask web app?

Hello, I'm writing a simple flask app that displays a table containing rows of detection records. These detection records come from a sqlite db that is populated by a classifier python script. Both the web app and the classifier are run by main.py, that uses multiprocessing to spin up each process.

The app currently works, but I need to refresh the web page to show any new detection records that are inserted into the database after the page is loaded. I would like this to instead be a live page that automatically updates the table when a new record is inserted into the database. I figured the best way to do this would be to use flask socketio and pass a multiprocessing queue to both the web app and classifier, and then insert a detection into the queue at the same time the record is added. Then, within the web app, spin up another two processes: one for the web app, and the other being a consumer that is constantly watching the queue and calls the socketio emit whenever a detection is pulled from the queue. This doesn't work, and I'm curious if it is

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

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

Python Daily

Help me optimize my table, Query or DB

I have a project in which I am maintaining a table where I store translation of each line of the book. These translations can be anywhere between 1-50M.

I have a jobId mentioned in each row.

What can be the fastest way of searching all the rows with jobId?

As the table grows the time taken to fetch all those lines will grow as well. I want a way to fetch all the lines as quickly as possible.

If there can be any other option rather than using DB. I would use that. Just want to make the process faster.

This project is made in Django, so if you guys can provide suggestions in Django, that would be really helpful.

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

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

Python Daily

Edifice is like React, but with Python instead of JavaScript, and Qt Widgets instead of the HTML DOM

Edifice v1.0.0 was released last month.

https://github.com/pyedifice/pyedifice

Edifice offers a declarative framework for Qt which is like React, but with Python instead of JavaScript, and **Qt Widgets** instead of the HTML DOM.

# What My Project Does

- Modern declarative UI paradigm from web development.
- 100% Python application development, no language inter-op.
- A native Qt desktop app instead of a bundled web browser.
- Fast iteration via hot-reloading.

# Target Audience

Developers who want to make a desktop user interface in Python because their useful libraries are in Python (think PyTorch).

# Comparison

## Edifice vs. Qt Quick

Qt Quick is Qt’s declarative GUI framework for Qt.

Qt Quick programs are written in Python + the special QML language + JavaScript.

Edifice programs are written in Python.

Because Edifice programs are only Python, binding to the UI is much more straightforward. Edifice makes it easy to dynamically create, mutate, shuffle, and destroy sections of the UI. Qt Quick assumes a much more static interface.

Qt Quick is like DOM + HTML + JavaScript, whereas Edifice is like React. QML and HTML are both declarative UI languages but they require imperative logic in another language for dynamism. Edifice and React allow fully dynamic applications to be specified declaratively in one

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

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

Python Daily

Best library for creating graphic PDF documents?

I have an application for which I need to auto-generate some diagrams as PDF files. The graphics aren't anything particularly fancy, just line drawings and some text.

My first instinct was to generate LaTeX code in Python to draw the graphics with TikZ, but I feel like there's probably a better way without the middleman. I see there are a variety of different libraries for generating PDFs, so I'm looking for someone who has used one or more of them to maybe point me towards one which would suit my needs the best.

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

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

Python Daily

Wednesday Daily Thread: Beginner questions

# Weekly Thread: Beginner Questions 🐍

Welcome to our Beginner Questions thread! Whether you're new to Python or just looking to clarify some basics, this is the thread for you.

## How it Works:

1. Ask Anything: Feel free to ask any Python-related question. There are no bad questions here!
2. Community Support: Get answers and advice from the community.
3. Resource Sharing: Discover tutorials, articles, and beginner-friendly resources.

## Guidelines:

This thread is specifically for beginner questions. For more advanced queries, check out our [Advanced Questions Thread](#advanced-questions-thread-link).

## Recommended Resources:

If you don't receive a response, consider exploring r/LearnPython or join the Python Discord Server for quicker assistance.

## Example Questions:

1. What is the difference between a list and a tuple?
2. How do I read a CSV file in Python?
3. What are Python decorators and how do I use them?
4. How do I install a Python package using pip?
5. What is a virtual environment and why should I use one?

Let's help each other learn Python! 🌟

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

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

Python Daily

Is every backend framework just an API at this point?

Is spring, flask, django .NET, node, etc all just functioning as APIs at this point?

Most apps you're building are probably built with a javascript framework like react in the frontend and then one of the languages/frameworks I mentioned above as a backend?

If that's the case ,what is the point of jinja, making forms etc in flask/django? I suppose we shouldn't practice this and just go straight to building APIs only and if that is the case, why aren't we all just using FastAPI? What's the point of Flask/Django?

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

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