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

P Analysis of why UMAP is so fast

Hi, I recently spent some time to understand the core implementation of the UMAP algorithm from the point of view how it was implemented and why it's so fast (even though it's in python). I decided to decompose the algorithm into smaller steps in which I add some minor improvements to the code (one by one), so that at the end the final results are very similar to what I can get from the UMAP.

To my surprise, most of these changes were just tricks in the optimization code to run things faster or update less important things less often. Of course, my implementation does not reproduce the UMAP algorithm in 100% as it was done in the educational purposes.

I provided a detailed explanation in my project of what I had to add in each step to move towards UMAP like algorithm. Here is the project page: https://github.com/kmkolasinski/nano-umap

If you are a person like, who likes to optimize the code for performance you may find this interesting. Here is a demo what I was able to get:

https://preview.redd.it/eww57c3x881e1.png?width=1921&format=png&auto=webp&s=ed4a345e40b47782ddf39cb93eb9d03207db1160

TLDR: in UMAP they:

use ANN library to quickly find top k-NN,
use good initialization method which makes things more stable and algorithm requires

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

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

Python Daily

🚀 Feature Friday: PostgreSQL Connection Pools!

Welcome to this week's Django Feature Friday on PostgreSQL Connection Pools!

This small-but-mighty change lets you enable connection pooling with a single line in your settings. This reduces the overhead of accessing your database, leading to improved performance.

You can turn it on like this:

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
# ...
"OPTIONS": {
"pool": True,
},
},
}

If you want fine-grained control over your connection pools, you can also explicitly configure them by passing in a dictionary of settings:

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
# ...


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

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

Python Daily

Yami - A music player made with Tkinter Now on pypi!

I would like some user feedback
**Github Link:** [https://github.com/DevER-M/yami](https://github.com/DevER-M/yami)
**Pypi Link:** [https://pypi.org/project/yami-music-player/](https://pypi.org/project/yami-music-player/)
**Some of the features**

* ***mp3 , flac, and many audio formats supported for playback***
* ***Clean UI***
* ***Can download music with art cover***
* ***it is also asynchronous***

**Libraries used**

* customtkinter
* spotdl
* mutagen

**Target audience**
This project will be useful for people who do not want ads and want a simple user interface to play music

**Comparison**
There are currently no projects that have all the features covered and is made with tkinterTo use this install all requirements in the .txt file and you are good to go

**RoadMap**
I will update it now and then

A follow would be nice! [https://github.com/DevER-M](https://github.com/DevER-M)

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

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

Python Daily

I played a minute-long video in Windows Terminal

I recently worked on a project combining my love for terminal limits and video art. Here’s what I achieved: • Rendered a 1-minute-long (almost two) ASCII video in the terminal, without graphics libraries or external frameworks. • Used true 24-bit colors for each frame, offering deeper color representation in terminal-based projects. • Processed 432 million characters over 228 seconds, translating each frame’s pixels to colors. • Optimized performance with multi-processing, running on an integrated graphics card.

Specs:

• 30 FPS
• 160,000+ characters per frame
• 2,700 frames
• 3 pixels per character for better performance

For further optimization, I reduced the font size to 3 pixels and used background colors to handle brightness.

What my project does?
While not the most practical project, it’s an experiment I’m satisfied with it. No real use, but hey, it’s fun!

Target audience
This is more of a fun project so I can't say it has a specific target audience, but I could say that people that strangely feels good coding "useless" things might like it.

Comparison
Well it is not an ASCII player anymore to be precise, but what it does now is just display video in the terminal using basically pure ANSI, I

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

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

Python Daily

Game 987, Like 2048 but Fibonacci (Made in Python)


https://987.reflex.dev/


What My Project Does

From Adhami the author: I was wondering how 2048 would feel like if instead of powers of two, we can merge consequent fibonacci numbers. Turns out to be a rather interesting game that is fairly forgiving and grows very slowly. I found it difficult to come up with an overall strategy. I had a simple search algorithm that was able to achieve a score of exactly 66,666 (not joking). Getting a 987 block shouldn't be difficult.


You can take a look into the code here: https://github.com/adhami3310/987 (the simple search algorithm is inside the code as well)

Target Audience: Anyone

Comparison: Similar to 2048 but fib



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

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

Python Daily

Help me out

https://redd.it/1gs4uzp
@pythondaily

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

Python Daily

PyPI now has attestation. Thanks I hate it.

Blog post: https://blog.pypi.org/posts/2024-11-14-pypi-now-supports-digital-attestations/

I'm angry that it got partially funded by the sovreign tech fund, when it's about "securing" uploads by giving the keys to huge USA companies. I think it's criminal they got public money for this.


I also don't think it adds any security whatsoever. It just moves the authentication from using credentials to PyPI to using credentials to github. They can be stolen in the exact same way.

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

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

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

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

Python Daily

What's the most complex/Impressive thing you've built using Django?

By complex i mean code-wise. What's something that you built that really push the capabilities of Django and maybe Python? use this as a chance to show off.

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

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

Python Daily

Is django a good choice?

Hey guys,

I currently trying to find the best solution to implement for a client of mine.

What started as a simple HRM implementation now runs more towards some kind of lean ERP solution.

I need something that can handle a lot of employee information and turnover across multiple clients and contracts types to generate accurate and pretty much automatic timesheets and invoicing.

The company is pretty only generating pay and invoices, but these have to follow pretty complex business rules.

I also have to handle a few HR processes that include on-boarding and termination along with some kind of document and signature tracking

Nothing out of the ordinary, but I couldn't find a solution that could do that without heavy customization and license fees.

I am leaning toward erpnext/frappe, but the installation process is much more complex than what I envisioned. I am also thinking about building something myself with Django and bootstraps or react, but I do not have great coding skills so build on something that is pre-existing would be much more approachable for me.

Any suggestions? I am in dire need of help here.

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

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

Python Daily

Just Finished Studying Django Official Docs Tutorials

I am a BSc with Computer Science and Mathematics major, done with the academic year and going to 3/4 year of the degree. I am interested in backend engineering and want to be job ready by the time I graduate, which is why I am learning Django. My aimed stack as a student is just HTMX, Django and Postgres, nothing complicated.

I have 6 projects (sites) that I want to have been done with by the time I graduate:

* **Student Analytics App**
* **Residence Management System**
* **Football Analytics Platform**
* **Social Network**
* **Trading Journal**
* **Student Scheduling System**

I have about 3 months to study Django and math alternatingly. I believe I can get a decent studying of Django done by the time my next academic year commences and continue studying it whenever I get the chance during my academic year.

Anyways, enough with the blabbering, I just got done studying the Django tutorials from the official docs. I love the tutorials, especially as someone who always considered YouTube tutorials over official docs. This is the first documentation I actually read to learn and not to troubleshoot/fix a bug in my code. I think it is very well written!

I wanted to ask:

* Is there any resource

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

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

Python Daily

Make your Github profile more attractive as a Python Developer

What My Project Does:

This project automates the process of showcasing detailed analytics and visual insights of your Python repositories on your GitHub profile using GitHub Actions. Once set up, it gathers and updates key statistics on every push, appending the latest information to the bottom of your README without disrupting existing content. The visualizations are compiled into a gif, ensuring that your profile remains clean and visually engaging.

With this tool, you can automatically analyze, generate, and display visuals for the following metrics:

\- Repository breakdown by commits and lines of Python code

\- Heatmap of commit activity by day and time

\- Word cloud of commit messages

\- File type distribution across repositories

\- Libraries used in each repository

\- Construct counts (including loops, classes, control flow statements, async functions, etc.)

\- Highlights of the most recent closed PRs and commits

By implementing these automated insights, your profile stays up-to-date with real-time data, giving visitors a dynamic view of your work without any manual effort.

\---

Target Audience:

This tool is designed for Python developers and GitHub users who want to showcase their project activity, code structure, and commit history visually on their profile. It’s ideal for those who value continuous profile enhancement with minimal maintenance, making it useful for developers

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

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

Python Daily

Automation question

Hey all,

I'm trying to automate a process at my work to improve my efficiency. For context, imagine I work at workplace A which has its own database of information that staff need to access. On top of this there's workplaces B and C also who have the same situation. However all 3 workplaces need to access each of the workplaces data (A, B and C) which is done via a website. On the website we have to click a link down the bottom corner of the page to "swap workplace". This opens a new page where we then select the workplace we want and click submit.

Is there anyway to automate this process of being able to just click a button and automatically be open up workplace A, without having to go into the menu.

There is no identifying feature for the workplace in the URL so I can't just bookmark different urls.

My initial thoughts were too have a process that targets particular ui elements and clicks them in series to do the job.

Thoughts?


Any help would be awesome!


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

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

Python Daily

Advice for Django Job

I recently started learning Django. I know how to make simple APIs with DRF. But I feel like there are too many abstractions like it makes it so easy to make a rest api. Anyways, Can some please tell me how to make it to full stack.... Is server side rendering and jinja templating all? Because on the other hand NextJS and React thing is very popular. I am studying AI/ML in parallel so what texh stach would be good for me?
I only want a job or internship with descent >= 5LPA salary as of now as I am in 3rd year. Whats the shortest way to do that.
PS: I also do competitive programming and am 2 star on codechef but I am kinda confused with what path to follow.

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

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

Python Daily

I'm puzzled trying to update just 1 m2m object in a form

I have a form in a template where I want the ability to check a box and it shows an interest in a game for an official. There is a many-to-many relationship between games and officials.

In the template, the form presents only the user of all officials to either check or uncheck for a game.

If the user makes any change (checks or unchecks), they essentially uncheck all users associated with that game.

Please help point me in the right direction.

Here are relevant sections of code:

[models.py](http://models.py)

class Official(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
class Game(models.Model):
game_official_options = models.ManyToManyField(Official, blank=True, related_name='officials')

[view.py](http://view.py)

def GameDetail(request, slug):
game = officials_models.Game.objects.get(slug=slug)
if request.method == "POST":
form = officials_forms.GameInterestForm(request.user, , instance=game)
if form.is_valid():
post = form.save(commit=False)


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

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

Python Daily

help me in this error

https://redd.it/1gshbjy
@pythondaily

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

Python Daily

Have started the django doc again, and got stuck.

At this part of "Writing your first app", I try to type in "py manage.py startapp polls" and it shows "ModuleNotFoundError: No module named 'polls". Why is that?

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

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

Python Daily

Hidden Trigger: Unlock Python’s Built-in Debugging Superpower with PDB

Alert: New Python Tutorial!
Did you know Python has a built-in debugger that can turn you into a bug-slaying detective? In just 5 minutes, learn all the secrets to enhance your debugging skills by using the built-in PDB tool to track down errors, set breakpoints, and inspect your code like a pro!

**tutorial link**

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

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

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

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

Python Daily

D Neurips 2024 Hotel Roommate Search

The hotels around the venue for Neurips 2024 are pretty expensive, and I'm looking for a roommate to split the cost with (my university has a limit on the nightly hotel rate they are willing to reimburse). I currently have reserved a room for Tuesday-Sunday in the Century Plaza Hotel, which is 0.9 miles from the convention center. The nightly rate is $414. If anyone wants to split the cost of a room, please reach out! Also, it would be helpful if you could share this post with your research group or other attendees that you know.

If you are unsure about rooming with a complete stranger, you can get to know me a little bit through my personal website (https://mtcrawshaw.github.io/), which has links to my google scholar page, CV, etc. I do have a paper at the conference in the area of federated learning/distributed optimization. Just a grad student trying to make conferences affordable! Thanks.

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

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

Python Daily

D When you say "LLM," how many of you consider things like BERT as well?

I keep running into this argument, but for me when I hear "LLM" my assumption is decoder-only models that are in the billions of parameters. It seems like some people would include BERT-base in the LLM family, but I'm not sure if that's right? I suppose technically it is, but every time I hear someone say "how do I use a LLM for XYZ" they usually bring up LLaMA or Mistral or ChatGPT or the like.

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

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

Python Daily

Dispatchery: Type-aware, multi-arg function dispatch for complex and nested Python types

Links: [Github](https://github.com/bolaft/dispatchery/), [PyPI](https://pypi.org/project/dispatchery/)

**What it does:**

*dispatchery* is a lightweight Python package for function dispatching inspired by the standard *singledispatch* decorator, but with support for complex, nested, parameterized types, like for example *tuple[str, dict[str, int | float]]*.

**Comparison**:

Unlike *singledispatch*, *dispatchery* can dispatch based on:

- Generic parameterized types (e.g. *list[int]*)
- Nested types (e.g. *tuple[str, dict[str, int | float]]*)
- Union types (e.g. *int | str* or *Union[int, str]*)
- Multiple arg and kwarg values, not just the first one

**Target Audience:**

Python developers who don't like having a bunch of *if isinstance* checks everywhere in their code.

**Example :**

from dispatchery import dispatchery

@dispatchery
def my_func(value):
return "Standard stuff."

@my_func.register(list[str])
def _(value):
return "Strings!"

@my_func.register(list[int] | list[float])
def _(value):
return "Numbers!"

@my_func.register(str, int | float, option=str)
def _(value1, value2, option):
return "Two values and a kwarg!"



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

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

Python Daily

I just learnt how to connect my Django app to mysql

I just connected my django application to mysql database. I feel so proud of me right now.

https://preview.redd.it/kzb1vv1ww11e1.png?width=500&format=png&auto=webp&s=53f2e376d59d5a7d7bbfca7accec6587505fa6fb



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

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

Python Daily

how to solve this

https://preview.redd.it/psusx618hw0e1.png?width=805&format=png&auto=webp&s=478ec1a14ab79568de8846d85d01909e4943e430

also when i'm switching to new powershell i'm not entering into enviorment

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

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

Python Daily

Looking for a Django dev to join my remote team

Hey everyone! A while ago I posted a job on this thread and managed to find a great developer. He's still with us, going strong, and I'm looking to expand my team again. I'm hoping this community can deliver again!

The role is for a remote Django developer. I'm open to hiring junior, intermediate, and senior developers. The company is Canadian so you must be fluent in spoken/written English, and Canadian applicants will be preferred over non-Canadians.

Please read more about the job here and follow the instructions to apply:

https://blendable.ca/about-us/careers/full-stack-software-engineer/

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

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

Python Daily

Django models reverse relations

Hi there! I was exploring Django ORM having Ruby on Rails background, and one thing really seems unclear.

How do you actually reverse relations in Django? For example, I have 2 models:

class User(models.Model):
// some fields

class Address(models.Model):
user = models.OneToOneField(User, related_name='address')


The issue it that when I look at the models, I can clearly see that Adress is related to User somehow, but when I look at User model, it is impossible to understand that Address is in relation to it.

In Rails for example, I must specify relations explicitly as following:

class User < ApplicationRecord
has_one :address
end

class Address < ApplicationRecord
belongs_to :user
end


Here I can clearly see all relations for each model. For sure I can simply put a comment, but it looks like a pretty crappy workaround. Thanks!

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

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

Python Daily

Finding a Django Learning Partner

HI All,

I am in a difficult position in my career with early layoffs and joining at time of recession. Due to all these I have derailed and have been extremely lazy to learn and lack the motivation. I am looking for a partner to learn Django together. Only motive is to share progess and keep each other motivated.

I am good with python and know only some basics of Django. I am a quick learner and academically strong. Preferable partner should be learning Django fully focused. I am a 2022 graduate (if that matters)

Mentors willing to mentor me through this rough phase are appreciated too.

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

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

Python Daily

Flask 3.1.0 Released

https://flask.palletsprojects.com/en/stable/changes/#version-3-1-0



Drop support for Python 3.8. #5623
Update minimum dependency versions to latest feature releases. Werkzeug >= 3.1, ItsDangerous >= 2.2, Blinker >= 1.9. #5624,5633
Provide a configuration option to control automatic option responses. #5496
Flask.openresource/openinstanceresource and Blueprint.openresource take an encoding parameter to use when opening in text mode. It defaults to utf-8. #5504
Request.max_content_length can be customized per-request instead of only through the MAX_CONTENT_LENGTH config. Added MAX_FORM_MEMORY_SIZE and MAX_FORM_PARTS config. Added documentation about resource limits to the security page. #5625
Add support for the Partitioned cookie attribute (CHIPS), with the SESSIONCOOKIEPARTITIONED config. #5472
-e path takes precedence over default .env and .flaskenv files. load_dotenv loads default files in addition to a path unless load_defaults=False is passed. #5628
Support key rotation with the SECRETKEYFALLBACKS config, a list of old secret keys that can still be used for unsigning. Extensions will need to add support. #5621
Fix how setting host_matching=True or subdomain_matching=False interacts with SERVER_NAME. Setting SERVER_NAME no longer restricts requests to only that domain. #5553
Request.trustedhosts is checked during routing, and can be set through the TRUSTEDHOSTS config. #5636

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

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

Python Daily

uv after 0.5.0 - might be worth replacing Poetry/pyenv/pipx

uv is rapidly maturing as an open-source tool for Python project management, reaching a full-featured capabilities with recent versions 0.4.27 and 0.5.0, making it a strong alternative to Poetry, pyenv, and pipx. However, concerns exist over its long-term stability and licensing, given Astral's venture funding position.

https://open.substack.com/pub/martynassubonis/p/python-project-management-primer-a55

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

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

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

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