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

Website To Easily Develop Tkinter GUIs

# What My Project Does

I've been working for a while in this project where you can easily create Tkinter Interfaces.

It's a website where you can just drag and drop widgets in a figma-like interface to customize them. Afterwars, you just gotta click Translate to Code and it will translate your interface to Tkinter Code!

# Target Audience

As a wise man once said DEVELOPERS DEVELOPERS DEVELOPERS! To make your life easier when creating tkinter interfaces!

# Comparison

I used to use a website called VisualTK, but it is down since a while.

# GitHub

https://github.com/arthurdeka/CustomTkinter-Templates/tree/main?tab=readme-ov-file
(First link on README)

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

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

Python Daily

Django rest framework

Hey, everyone can you guys just suggest to me the best resource to learn django rest framework(drf) for beginners.

Also, I want to ask that I have the experience of backend development using NodeJS and express but I am confused do I have to learn about normal template based django first and then shift to drf or I can directly start with drf.

I have limited time so I want to learn it faster.

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

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

Python Daily

Reasons why you love building with Django?

What are the reasons you love working with Django?

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

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

Python Daily

Flask to Quart

Migrated from Flask to Quart using the steps on this page: https://quart.palletsprojects.com/en/latest/how\_to\_guides/flask\_migration.html
Took about 15-20 minutes to get everything back up and running again. I had to use CoPilot to help fix a couple of glitches. Also, changed from gunicorn to uvicorn. Deployed and it seems to work. From what I read there is a 2-5 times performance improvement. I don't have metrics. But it "feels" faster and seems like an easy win. Want to hear what y'all have to say about this.

But question...what limitations and bugaboos have you run into with Quart in moving from Flask? Should I fully commit to Quart?

edit: Since both Flask and Quart are part of pallets project, they are not really "competing" frameworks. I mean, Quart may be where Flask is headed. Am I right?

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

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

Python Daily

What ORMs do you use and why?

Hello !
I am building a Flask application and up until now I've only used SQL queries.
But now I am building a larger application (a forum) and I am considering to use an ORM.
The biggest reason for this is to have a layer capable translating all my stuff to any relational DB.
Another thing is maintainability. It feels easier to implement models to be honest.
What ORMs do you use? I heard SQLAchemy is the most popular and the most "used in industry". But people call it off for being hard to use and having poor performance.
I found PonyORM and it looks like a great alternative. I love the syntax and how lightweight it is.
Also PeeWee seems interesting.
What ORMs do you use? And, why is SQLAchemy much more popular? Is it because of the name? What does SQLAchemy have that other ORMs don't have?

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

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

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

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

Python Daily

completed 20mins long django tutorial and done with first project. what is next? can you share some other tutorials?

https://preview.redd.it/ute7x56e5cgd1.png?width=1848&format=png&auto=webp&s=4d20c68926d40a22dedfc777e28c8778f73311d1



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

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

Python Daily

D Is the new norm for NLP papers "prompt engineering" papers?

So many papers seem to essentially be "how can we make LLM 1 do this without training?" I haven't published in a while and have been in industry for the past few years. I recently joined a new company in a slightly more research-y position and am working with research scientists and graduate interns. I've noticed that every single one of them is working on something that I would have been reprimanded by my PI for in graduate school. Basically, "how can we make LLMs do this really complicated task without doing any training?" And perhaps somewhat unsurprisingly, in many cases, you can't. I think that's why these days there are so many negative result papers in NLP.

Is this the new norm? It's become a pain to go through the CL section of arXiv. 98% of the papers are something like "how come LLaMA can't understand numbers?"

I'm wondering if I'm just being the senile old man in the corner of the bar or if everyone else feels the same.

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

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

Python Daily

What are popular sites that use Django template engine?

I know Pinterest used Django in backend but I haven't seen any popular company site that uses Django's built in html template engine. Do you know any?

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

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

Python Daily

Compress JSON: the missing Python utility to read and write compressed JSONs.

**What My Project Does**
I have always found working with compressed JSON files cumbersome, as for the life of me I cannot recall how to use Python's compression utilities. Plus, when you need to handle multiple possible formats, the code gets ugly quickly.

Compress-json abstracts away the complexities of handling different compression formats, allowing you to focus on writing clean and maintainable code.

**Installation**

You can install compress-json quickly using pip:

pip install compress_json

**Examples**

Here's how you can use compress-json to compress and decompress JSON files with minimal effort. Here it uses automatic detection of the compression type:

import compress_json

# Your JSON data
data = {
"A": {
"B": "C"
}
}

# Dumping data to various compressed files
compress_json.dump(data, "data.json.gz") # gzip compression
compress_json.dump(data, "data.json.bz") # bz2 compression
compress_json.dump(data, "data.json.lzma") # lzma compression



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

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

Python Daily

Inertia JS equivalent for Django

I found Inertia JS to be a handy tool for using Laravel at the backend and React / Vue at the frontend without the hassle of building API.

Do we have similar solution in Django world ?

The inertia website says that we can use it with Django but it is fine tuned for Laravel.



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

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

Python Daily

Best Approach to Styling Django Forms

I am always struggling to style Django forms(field, label, field/form errors), how are you guys dealing with this? What will you propose as the best approach(or library)?

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

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

Python Daily

help to deploy python api


I am building a fullstack application using MERN, there are some features in it which requires AI/ML, so I've integrated python with this project. I can deploy the Node.js on vercel, but don't know how do I deply the python, as vercel doesn't allows python deployment. please suggest me some good platforms, should be free, to deploy python.

thank you

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

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

Python Daily

Best practice for including a ton of error checking in a functional api view?

Hi, I'm doing an integration which involves taking data from service A, parsing it, sending it to service B, then returning a response back to service A. Service A has given a list of error codes that it expects when my server detects specific issues, so I've implemented them, but found that the code I wrote is quite lengthy to read.

I have implemented permission classes for things like this before, like detecting an api key or something, but the problem here is that the error checks vary per endpoint slightly, so I'd be writing at best a permission class per endpoint. I suppose I could try to create a permission class which checks for any similar errors, but it would still not solve the issue of having a bunch of error checking sprinkled into the views. Creating a separate file that contains functions that check for the errors is possible, but I just want to get a sense of best practice here. There are 5 endpoints, and each have similar if/else blocks for error checking per service A's requirements.

Here is an example of the if/else block for the error checks that service A wants, any suggestions on refactoring

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

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

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

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

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

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

Python Daily

How should I handle errors, aborts, logging and audits in my endpoint?

I have a login endpoint (api/auth.py) that receives the request, and uses an auth service (services/auth_service.py). Btw I'm using Flask for backend React for frontend.
I was handling things like this, for a clean endpoint, and letting auth_service to do the logic:

auth.py
@authbp.route("/login", methods=["POST"])
def login():
data = data.get
json()
response, status = AuthService.login(data)
return jsonify(response), status

authservice.py
class AuthService:
@staticmethod
def login(data):
email = data.get("email")
password = data.get("password")
if !validate
credentials(email, password):
abort(401, description="Email or password incorrect")

# Token creation here

return {"success": True, "accesstoken": accesstoken}, 200

So basically, anything other than a successful login triggers an abort. I had no problem with this,

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

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

Python Daily

Pastebin Command Line App | PasteCMD

# What my Project Does?

PasteCDM makes using Pastebin much more simple, with a CLI app. As of now, you can:

1. Upload text sentences
2. Upload file contents

# Target Audience

Anyone who uses Pastebin service

# Comparison

N/A

# GitHub

GitHub Link: https://github.com/rohankishore/PasteCMD

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

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

Python Daily

A script to batch convert media with ffmpeg

# What My Project Does

This is a Python script that batch-processes videos using ffmpeg. The script evaluates the list of input files and directories provided and converts all files to the specified output directory. The conversion is done with ffmpeg using the command line argument from one of the available presets.

It also provides a nice formatted output to the console with colors and progress bars.

# Target Audience

Myself and any other that has a bunch of media to transcode

# Comparison

Better than a batch file, there are colored progress bars to stare at for hours while the media is converted.

# GitHub

https://github.com/ts-manuel/ffmpeg-batch

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

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

Python Daily

socket POC where tasks are triggered by the client and responses are sent as pickled Python objects.

I made a POC of a socket client-server communication

what my project does?

it allows communication between client-server,

client gets to trigger tasks in the server and receive task response as an unpickled python object

target audience?

just for fun or for people to read as reference

comparison?

well its just a minified version of the FastAPI -> Redis -> Celery flow

workflow ?

* Client connects to the socket server.
* Server accepts the client connection and handles the connection in a separate thread.
* Client creates a payload using `._create_payload(b"EVENT", body)` and sends it using `.send_event(tag, args, kwargs)`.
* Server always attempts to read 13 bytes (value from :`struct.calcsize("!5sQ")`).
* The first 5 bytes represent the event scope, which is either `EVENT` or `RESLT`.
* The following 8 bytes represent an unsigned integer indicating the body's length.
* Server determines the event controller by tag.
* Server Pickles the controller response and creates a payload using `._create_payload(b"RESLT", body)`.
* Meanwhile, the client blocks execution until 13 bytes are received.
* Client determines the body length n, attempts to receive n bytes (body), and unpickles it.
* `.send_event(tag, args, kwargs)` returns the unpickled result.

here's the source code if anyone would like to code review it : [https://github.com/achaayb/Montagne](https://github.com/achaayb/Montagne)

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

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

Python Daily

Django with ESP32

I am trying to connect my iot project with django development server as I have not deployed my system as if yet. The main problem lies in the server connection, I have to run all port server i.e. 000.0.0:8000 inorder to run my laptops ip server with my sensors url to post data via ESP32. Due to this setup it fails to connect with the server and does not post data untill it wishes to do so and with this my logic for the code gets messed up. I have done all experiments with the settings of cors & firewall. Once I am able to post data I can store the info easily, is there any alternative or correct path that I should follow to sort this out

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

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

Python Daily

Which famous sites use Django's built-in template engine?

There are many famous companies that use Django as backend framework but I haven't seen companies that use Django's built-in template engine. Do you know any?

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

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

Python Daily

dir-assistant: Chat with your current directory's files using a local or API LLM.

# What my Project Does

Dir-assistant is a CLI LLM runner that chooses the best info from your current directory (recursively) to include with your prompt. It is designed to improve programmer efficiency by speeding research and automatically writing code. It has been tested on a repository with 900k lines of code, and it produced useful contextually aware code.

Demo gif (images are not allowed in r/Python)

Setup is quick:

pip install dir-assistant
dir-assistant models download-embed
dir-assistant models download-llm
cd directory/to/chat/with
dir-assistant

It works with almost all local and API LLMs.

Yesterday I released the first major release, 1.0.0, which added pip install support and many quality of life improvements. I am aiming to support more operating systems, so if you would like to help by testing, please submit a github issue with your results. Other contributions including PRs are welcome as well.

# Target Audience

Coders who want to improve productivity

# Comparison

Other LLM runners are not aware of your files, perform badly, or are designed for small snippets. Dir-assistant is the best solution currently available for large projects.

# GitHub

GitHub Link: https://github.com/curvedinf/dir-assistant/

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

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

Python Daily

Help in getting new project ideas, primarily backend based

I have created many app projects with django, DRF and channels, but I am sick of creating just basic CRUD/chat apps. Can you guys give me any ideas on more projects which are primarily backend based, can use different concepts, and domains/fields I can integrate them with ?

I don't want to create a Netflix or Amazon clone or something like that too. Please help me out here guys.

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

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

Python Daily

Developing Secure Mobile Applications: Tips and Best Practices
https://www.quickwayinfosystems.com/blog/best-practices-secure-mobile-applications/

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

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

Python Daily

making a api endpoint start a routine that fetches from external API

Hello everyone,


So I'm trying to make this thing where when this api point is called i fetch data from another external API to save.

I think the process must be somehow asincronous, in the way that when I call it I shouldn't wait for the whole thing to process and have it "running in the background" (I plan even to give a get call so that I can see the progress of a given routine).


How can I achieve this?

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

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

Python Daily

Django devs from Colombia, are you there ?

Hi guys what are you up to these days in Colombia, how is the django scene moving ? I'd love to connect with fellow django devs currently in Colombia 👋

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

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

Python Daily

Picked up an old project again and upgraded to the latest dependencies. Now I receive this error: "The current Flask app is not registered with this 'SQLAlchemy' instance." and I cant wrap my head around it.

Hey folks, I picked up an old project of mine, upgraded the versions in my requiement file and I receive this odd error for something that must have worked years ago.

I'd like to explain what's going on by guiding you through one request that triggers it, but should work.
I's a request to see if the username that's used to sign-up already exists.

Requirements:

Flask==3.0.3
flasklogin==0.6.3
Flask-Migrate==4.0.7
flask
sqlalchemy==3.1.1
requests==2.32.3
Werkzeug==3.0.3
dnspython==2.3.0
email-validator==1.3.1
urllib3==1.26.14


My app.py (simplified)

from flask import Flask, rendertemplate, makeresponse, sendfromdirectory, jsonify, request
from flasksqlalchemy import SQLAlchemy
from sqlalchemy import text
from flask
migrate import Migrate

app.secretkey = b'supersecret'

app.config['SQLALCHEMY
DATABASEURI'] = 'mysql+pymysql://dbuser:password@mariadb/kinda?charset=utf8mb4'

app.config['SQLALCHEMY
TRACKMODIFICATIONS'] = False
app.config['SECURITY
DEFAULTREMEMBERME'] = True


db = SQLAlchemy(app)

# Initialize Flask-Migrate


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

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

Python Daily

Jeremy Howard has announced FastHTML, Dynamic modern html pages using python!
https://fastht.ml

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

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

Python Daily

New interesting funeral brochure and donation website with django htmx my second project will django

https://anytribute.com

Hi this is my second project with Django
Can you check it up and give me your feedback. It’s free to use.

Stack
Django
Bootstrap
Htmx
Hyperscript
Django widgets tweeks
Djago all auth


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

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