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

Recommended Tutorials for Network Programming Using Django as a Beginner?

I’m a network engineer currently studying Django to build a front end for my Python script. I’ve started watching some video tutorials and reading through the Django documentation, but I’m still looking for resources that specifically focus on network programming or tools for beginners using Django.

Does anyone have recommendations for tutorials, video courses, or guides that might help someone in my position? Thank you

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

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

Python Daily

D Resources to get up to the speed with the state of the art evolutionary optimization

There're plenty of good books letting you get close to the state of the art in the field, on Machine Learning, and Deep Learning in particular. However, are there any good modern books on evolutionary optimization? Are there any good courses?

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

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

Python Daily

Introducing My New Favicon Extraction Tool

## What My Project Does

I've created a tool that extracts favicons from any website. It works by parsing HTML pages, checking fallback routes for icons, and even supports inline base64-encoded images. The tool can also verify availability, guess missing icon sizes, and download the favicons for further processing. It aims to streamline favicon retrieval for web scraping, data analysis or just curious exploration.

## Links

- Source code: https://github.com/AlexMili/extractfavicon/
- Documentation:
https://alexmili.github.io/extractfavicon/


## Target Audience

The project is designed for developers and data enthusiasts who work with web metadata. Whether you’re building a crawler, enhancing a web directory, or simply analyzing website branding. My intention is to maintain and improve it, making it stable and ready for production use cases.


## Comparison

While there are other favicon extraction libraries out there, many of them have become unmaintained or lack features like asynchronous support, thorough availability checks, and automatic size guessing. My project is actively maintained, built with modern Python standards, and provides a more robust, flexible solution than many existing alternatives.

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

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

Python Daily

Proof of PCAP Certification?

For those of you who have taken (and passed) the PCAP, did you receive anything other than the paper printout after the exam? (I know the PCAP isn't particularly useful, but my company offered me a 3% raise if I passed it so...) I'm just wondering if I should expect an email with some official looking certification or if I should just show the exam printout to my company.

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

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

Python Daily

Django Web Application Hosted on LAN

Is it possible to set up a centralized application server that hosts a Django web app and a local database, allowing clients on separate computers to access the app for CRUD operations (e.g., managing mail/blacklists) while storing updates locally? The server would also communicate with a ROS2 system on another computer (running AI models and managing daily logs) and optionally sync data to the cloud. Are there any potential challenges or considerations with this architecture?

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

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

Python Daily

D Why are the Stella embedding models so much smaller than other models of similar quality?

On the MTEB Leaderboard, stella_en_v5 is currently ranked 3rd overall, while using one fifth the memory of all non-Stella models in the top 10.

stella_en_400M_v5 is ranked 10th, while using 15-20 times less memory than the models ranked near it. This appears to be relatively consistent across several subtasks of the benchmark (for English).

What is the secret sauce here? Alternatively, what is the catch? There is no paper yet. Anyone know details?

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

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

Python Daily

Question about storing audio files

I am creating a web application where you can put music files inside that are added to a list where you can start, delete and eventually download in the future all your files that you have put. Now, what I was thinking of doing was using a database that keeps the path where each user's files are (divided into folders and subfolders; example: songs/Amanda56/song.mp3). I was thinking of creating these in urls that are added dynamically over time (example: when a user registers with the nickname Giorgio192, a url called: https:/www.mysite.com/storage/songs/Giorgio192/ will be created. The songs url already exists, the one that will be added is Giorgio192 (his username therefore). When Giorgio192 adds a new song to his list, this song will be stored in songs/Giorgio192/song.mp3 while the url that is used to extract the songs from there will be saved in my database. Is this method strange? Would it slow down my site a lot over time? If so, how? Is there a way to do what I want?

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

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

Python Daily

Inventory management Schema

I figured this would be more appropriate asked in a database design group, but since I'm using Django, I'd like to get a better understanding with Django.

How would you handle items with different sizes and quantity in an inventory. For example, a pack of cigarettes has 12 pieces, a crate of eggs has 30 eggs. I procured 3 crates of eggs and 2 packs of cigarettes, how do I track that? How about if I have a liquid that comes in 20 liters, 30 liters and 10 liters bottles. How do I track these items including those properties in an inventory.




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

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

Python Daily

Looking for a mid-ish level web project in django or flash more info below

I am working on transitioning some data projects to the web. I know an okay amount of HTML CSS and a bit of JS so I could do it that way. I would rather build a couple sites just using python using flash or django. I just can't seem to find a repo or tutorial thats not super basic or advanced. Anyone have one that falls in the middle area they would be willing to share?

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

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

Python Daily

Difference between get and filter? Cant understand even after reading several posts.

I am trying to write a function which requires to get some values from the database.

following is the model.

class Questions(models.Model):
    category = models.CharField(maxlength=50)
    question = models.CharField(max
length=255)
    answer1 = models.CharField(maxlength=255)
    answer2 = models.CharField(max
length=255)
    answer3 = models.CharField(maxlength=255)
    answer4 = models.CharField(max
length=255)
    answerkey = models.CharField(maxlength=25)

so in shell when I use Questions.objects.get(id = 1) I get <Questions: Questions object (1)>

but when I use

Questions.objects.get(id = 1).values() i get an error.

AttributeError: 'Questions' object has no attribute 'values'

When I use Questions.objects.filter(id = 1).values()

I will get <QuerySet [{'id': 1, 'category': 'gk', 'question': 'What is the 10th letter of english alphabet?', 'answer1': 'K', 'answer2': 'j', 'answer3': 'l', 'answer4': 'i', 'answer_key': 'answer2'}]>

So what's the difference? All articls/post answers say that filter will filter results and will give all objects where id = 1 (in this case id is default primary key so its only one), while get will get you exact match. But then why cant values() does not work with get if it has found

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

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

Python Daily

I build PdfDing with Python

Hi r/Python,

over the last six months I have build PdfDing. You can find it on GitHub.

What My Project Does

PdfDing is a selfhosted PDF manager and viewer offering a seamless user experience on multiple devices. Some of its features include:

Remembers current position - continue where you stopped reading on any device
Share PDFs with an external audience via a link or a QR Code. Shared PDFs can be access controlled
Dark Mode, colored themes and custom theme colors
Inverted color mode for reading PDFs
SSO support via OIDC

 I have used the following tech stack:

the web app is build using Python (Django)
The frondend is build using Alpine.js, htmx, jQuery and Tailwind CSS
Mozilla's PDF.js is used for viewing PDF files in the browser

Target Audience

Homelabs or businesses who want a self-hosted solution for their PDFs.

Comparison

There are solutions like self-hosted ebook readers. However, they are using the inbuilt PDF viewer of the browser. This works fine on desktops and laptops but on smartphones it will simply download the PDF file and not display it in the browser (at least it is like this on my mobile devices). This solution also does not allow you to continue reading where you stopped on another

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

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

Python Daily

Looking to Transition from Web Development to Python – Seeking Tips and Insights

I’ve been working as a JS web developer for over 8 years now, but I’ve found myself losing interest in it. I’m really looking to make a switch to something new, and I’ve been getting advice to get into Python and move into that field. However, I’m not entirely sure what the career opportunities in Python are like, or how I can best break into it.

Has anyone else made a similar transition? I’d love to hear about your experiences and any advice you have on how to make this switch successfully. Specifically, I’m curious about:

The job market for Python developers
The skills and projects I should focus on to get noticed. How much time would it take.
Any roadmaps or resources you’d recommend.

Thank you in advance!

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

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

Python Daily

DNS server written in Python

Hi All

I am researching the DNS protocol in depth (security research) and have written a DNS server in Python that relies on responses from a upstream service (Quad9,for now). Hope you all like it. Do recommend improvements.

Link: https://xer0x.in/dns-server-in-python/

PS: I am aware of the Blocklist parsing inconsistency bug.

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

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

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

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

Python Daily

Best way to serve media files via flask?

Hello,

Working on a flask project currently which will serve a lot of media files. Photos aren't really an issue just videos, im not streaming them since the hadware isn't great enough to do so.

What would be the best way to serve them with low hardware? Use object storage? Or even use flask?

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

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

Python Daily

Django's built-in test client or pytest?

For testing in a Django project, what should I use Django's built-in test client or pytest?

Or what's the benefit of using one of them instead of the other one?

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

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

Python Daily

How to test Flask with dummy DB

Hi, I have been making a Flask CRUD API, I am using pytest to test the models and everything that can be done without having to initialize the Flask App. However, now I really need to start testing the endpoints. I have checked https://flask.palletsprojects.com/en/stable/testing/ and I am getting a general idea on how to do so, however, I am still a bit lost on how to initialize the database and populate it during the testing. Would love any tips :)

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

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

Python Daily

The hand-picked selection of the best Python libraries and tools of 2024 – 10th edition!

Hello Python community!

We're excited to share our milestone 10th edition of the Top Python Libraries and tools, continuing our tradition of exploring the Python ecosystem for the most innovative developments of the year.

Based on community feedback (thank you!), we've made a significant change this year: we've split our selections into General Use and AI/ML/Data categories, ensuring something valuable for every Python developer. Our team has carefully reviewed hundreds of libraries to bring you the most impactful tools of 2024.

Read the full article with detailed analysis here: https://tryolabs.com/blog/top-python-libraries-2024

Here's a preview of our top picks:

General Use:

1. **uv** — Lightning-fast Python package manager in Rust
2. **Tach** — Tame module dependencies in large projects
3. **Whenever** — Intuitive datetime library for Python
4. **WAT** — Powerful object inspection tool
5. **peepDB** — Peek at your database effortlessly
6. **Crawlee** — Modern web scraping toolkit
7. **PGQueuer** — PostgreSQL-powered job queue
8. **streamable** — Elegant stream processing for iterables
9. **RightTyper** — Generate static types automatically
10. **Rio** — Modern web apps in pure Python

AI / ML / Data:

1. **BAML** — Domain-specific language for LLMs
2. **marimo** — Notebooks reimagined
3. **OpenHands** — Powerful agent for code development
4. **Crawl4AI** — Intelligent web crawling for AI
5. **LitServe** — Effortless AI model serving
6. **Mirascope** — Unified LLM

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

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

Python Daily

Nodriver - The next step in web scraping

Hey guys! Scraping is something we've all needed at some point, whether for personal or professional reasons. But nowadays I feel like I get blocked immediately if I go to any website and tbh I don't want to setup complex patches and go through all that stuff for like a tiny thing. Nodriver solved this problem for me.

Here's an article I wrote about getting started with nodriver and how it faces up with the competition - https://www.hyperbrowser.ai/blog/nodriver_:_The_next_step_in_web_automation


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

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

Python Daily

Did an open source tool for code exploration

# Description

Treeline is a code analysis and visualization tool designed to help developers understand the quality and structure of their Python codebases. It does some complexity metrics, detects code smells, and generates an interactive HTML-based visualization for relatively easy exploration. I hope it will give developers some insights into architectural dependencies, complexity hotspots, and maintainability issues.

# Links

* [https://github.com/duriantaco/treeline](https://github.com/duriantaco/treeline)
* [https://pypi.org/project/treeline/](https://pypi.org/project/treeline/)

# What My Project Does

* **Dependency Analysis**: Identifies which modules import others, which classes belong to which modules, and which functions call which, creating a complete dependency graph.
* **Metrics Computation**: Calculates cyclomatic complexity, cognitive complexity, maintainability index, function length, and code smell occurrences.
* **Visualization**: Renders an interactive HTML report using D3.js, where each node represents a module, class, or function. You can hover over nodes to see detailed metrics, search for specific elements.
* **Quality Reporting**: Produces Markdown and HTML reports summarizing complexity hotspots.

# Target Audience

* Anyone using Python

# Extra Details

Started of as a simple ASCII tree generator. Promised to add more stuff so here i am.

# Conclusion

Hopefully you guys will find it useful. If you think it's a stupid idea or ways to improve, do let me know too. I'm open to criticisms and constructive feedback. If you find any bugs

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

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

Python Daily

D From Unemployment to Lisp: Running GPT-2 on a Teen's Deep Learning Compiler

A couple months ago I found myself unemployed, uncertain about what to do next. I wanted to learn more about deep learning, but from a systems prespective. Coming from Andrew's Ng course on supervised learning, I was eager to learn more about how deep learning frameworks (or deep learning compilers) like Pytorch or Tinygrad.

I started to poke around Tinygrad, learning from the tutorials I found online, and I found it fascinating because it was an actual compiler, it took conventional python code and translated them into an Abstract Syntax Tree that was parsed into UOps and ScheduleItems, to finally have a codegen layer. While the design was interesting, the code was hard to read.

That's when I stumbled across something completly unexpected, A deep learning compiler built on Common Lisp, maintained by a Japanese 18-year-old during his gap year. And currently we have acomplished something great, it can run gpt2!

For now, it just generates C-kernels, but in the future we would like to support cuda codegen as well as many other features, and serve as a learning tool for anyone who would like to get to work on deep learning compilers in Common Lisp.

This is an open source project and anyone

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

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

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

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

Python Daily

Where would you host a web app expecting only about ~100 visitors per month?

Where would you suggest a relatively new dev host a django app expecting about \~100 users per month, with a postgres database containing about 100-200 entries? I have experience with Heroku and pythonanywhere but Heroku is a bit too expensive for now($5 hosting + $9 postgres). I've also used DO spaces but never hosted there and don't want to deal with DevOps right now. I've also seen Namecheap suggestions but not a lot of reviews.

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

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

Python Daily

Pype - Python Desktop App Framework

I created a python framework that easily enables users to create reactive desktop applications with Python backend and HTML frontend.

What My Project Does

Easily enables the user to create desktop applications with a Python backend and a HTML frontend. Using the frameworks functions listed in the documentation reactive variables, state-management and dynamic UI-s can be created with ease.

Feel free to use it if you see fit. Also im very much open to discussion as this is my first public project that i published, errors have a very high chance of appering.

PyPI pype-framework

Pype Github


edit: I used a post template so i can post here and forgot the delete the post templates text...

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

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

Python Daily

Django-tenant: Accessing tenant data in public domain

I was working on Django-tenant where I have tenant model called Appointment now I want to get the appointment of a specific tenant from the public domain but I'm having an issue when rendering it in the template

class OrganizationAppointmentList(LoginRequiredMixin, TenantMixin, ListView):
templatename = 'main/appointments/listappointment.html'
paginateby = 10

def get
queryset(self):
tenantid = self.kwargs.get('pk')
try:
tenant = Organization.objects.get(id=tenant
id)
self.schemaname = tenant.schemaname
with schemacontext(self.schemaname):
queryset = Appointment.objects.all()
return queryset


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

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

Python Daily

3rd year university student with solid skills developing in Django, looking to work on projects or under someone. I can send link to my resume and some projects I've worked if interested.

On winter break from university and looking for some things to do, hoping to learn and expand my skills. Been applying to internships, but no luck so far. Reach out if interested.

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

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

Python Daily

Suggestions

I have been working with Django framework for like 1.5 years or more. Built couple of projects.However at this point i m confused, if i am eligible for the entry level job.What kind of code will we be writing in the actual workplace and what essential topics are required to master in backend frameworks like django or flask or restapi

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

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

Python Daily

How do we send email using django-allauth now when Less Secure Apps are disabled?

Is there any way to use Oauth2.0 with django-allauth to keep sending verification emails now? I cant find anything on how to do this ( too dumb to figure it out )

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

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

Python Daily

Flask socketio production server

I have a flask application that is only accessed by me. It is hosted on a google cloud linux VM and I have a firewall set up to only allow my IP.

I've been using socketio.run(app) for now, but get the warning that this is a development server. I tried following tutorials for gunicorn and nginx but encountered problems with socketio and selenium chromedriver (there is so scraping that periodically runs in my app).

Since I don't have problems using the development server and I'm the only person accessing the web app, is there any problem with me leaving my app running like this? I've spent a whole day trying to get a production server up following various tutorials but always seem to have problems.

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

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

Python Daily

D Has anyone managed to train an LLM with model parallelism?

Hello,

I am working on fine-tuning Llama-3.1 for my master’s thesis research. Unfortunately, my current situation forbids access to high-memory GPUs such as A100s. Instead, I have access to setups with multiple lower-memory GPUs, such as 4×3090 or 8×V100.

Therefore I need to implement model parallelism to train my model as it doesn’t fit into a single GPU. However, I’ve noticed that most frameworks primarily focus on data parallelism, which doesn’t address my needs.

Has anyone successfully trained a model by splitting it across multiple GPUs? If so, could you recommend frameworks or approaches I should explore? I am specifically looking for full training, although I am interested in hearing if someone managed this using LoRA.

Also, if there’s a more suitable subreddit for this type of question, please direct me to there.

Thank you!

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

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