Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
how to implement django template with react js ?

can i implement django template with react js without building the react js into production and also without django rest frameworks just using react js code as a template.

/r/django
https://redd.it/1ccxp7t
D Why transformers are not trained layer-wise?

It seems to me that thanks to the residual path the gradient that flows to each layer is the same regardless of the transformer layer/block. Example:

ProjectionAndCost(X + L1(X) + L2(X + L1(X)) + L3(X + L1(X) + L2(X + L1(X))) ...)

Since the input to ProjectionAndCost is just sum of outputs from all layers and initial embeddings then the gradient that comes to the layer L1 is the same as the gradient that comes to L2 or L3.

So we could:

first train only L1: ProjectionAndCost(X + L1(X))
freeze L1, include L2 and train: ProjectionAndCost(X + L1(X) + L2(X + L1(X)))
freeze L1 and L2, include L3 and train: ProjectionAndCost(X + L1(X) + L2(X + L1(X)) + L3(X + L1(X) + L2(X + L1(X))))
.. and so on

We can't train first L2 then L1, because the input to L2 depends on L1, but we could train lower layers first then gradually add and train deeper layers. Is there any problem with that approach?

/r/MachineLearning
https://redd.it/1cct38r
Python Test 219: Building Django Apps & SaaS Pegasus - Cory Zue

Listen at podcast.pythontest.com/219

When starting a SaaS project using Django, there are tons of decisions. I've asked Cory Zue, creator of SaaS Pegasus, to help me sift through some common SaaS/Django decisions.

/r/Python
https://redd.it/1cctlon
๐Ÿ”ญ OpenTelemetry Architecture: Python SDK Overview

Hey folks,
I have just posted an article for those who want to go a little bit beyond the basic usage of OTEL and understand how it works under the hood. The post quickly touches on:
\- ๐Ÿ”ญ History and the idea of OpenTelemetry
\- ๐Ÿงต Distributed traces & spans. How span collection happens on the service side
\- ๐Ÿ’ผ Baggage & trace ctx propagation
\- ๐Ÿ“ˆ Metrics collection. Views & aggregations. Metrics readers
\- ๐Ÿ“‘ OTEL Logging integration
\- ๐Ÿค Semantic conventions and why that is important
Blog Post: https://www.romaglushko.com/blog/opentelemetry-sdk/
Let me know what do you think and hope this is helpful for someone ๐Ÿ™Œ

/r/Python
https://redd.it/1ccn8vf
Django PDF Templates

We currently use django-wkhtmltopdf and have noticed a number of bugs recently when trying to implement more complicated templates. Looks like wkhtmltopdf is no longer maintained so we are looking for suggestions on alternative packages. Required functionality:

Tables of data
Image resizing (either css or another method)
Control over pdf quality (for affected file size)
A method to better paginate if possible when data extends over multiple pages (rows tables for example)

​

​

​

​

/r/django
https://redd.it/1cd1rrc
Installing ffmpeg in Vercel?

Hey is it possible to install ffmpeg in Vercel in the system path something like the below

sudo apt install ffmpeg


I'm using flask for the backend

/r/flask
https://redd.it/1cd9z2g
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/1cd6xa3
D What are your horror stories from being tasked impossible ML problems

ML is very good at solving a niche set of problems, but most of the technical nuances are lost on tech bros and managers. What are some problems you have been told to solve which would be impossible (no data, useless data, unrealistic expectations) or a misapplication of ML (can you have this LLM do all of out accounting).

/r/MachineLearning
https://redd.it/1ccz2cq
Issue with Concurrency in Flask and IIS

Let me preface this by saying I'm a fairly novice web developer. I have a degree in CS and have built a few websites during my education but that's about all my experience in web dev.

I've built a website with Python & Flask on the back end with html, css and JavaScript on the front end that will be used by my company internally to reset a password in a simple system we use for our business. It will save countless calls to the service desk team yearly. I've been stuck for a few weeks now with an issue I can only replicate in production on IIS and I'm not sure where to look or what to try at this point.

My website will only run one request at a time. If 2 or more people fire off requests to reset their password, they will have to wait until the requests fired off earlier complete. I tried several ways to do this. But the one I found to be the most clean and most effective was using the python queue data structure with a lock. Essentially it works like this

1. POST form submission enqueues parameters like username, employee id, etc.
2. Then

/r/flask
https://redd.it/1cd3ii1
What's the best thing you've automated?

Mine is automating my social media posts with some AI magic.

Now I just have to check if the post is okay.

Took a lot of prompt mangling but hey it reduced a 10-mins task to 1-mins task. Over a course of a year, that's a lot of time.

So what's your thing?

/r/Python
https://redd.it/1cdctvv
Python for backend? Please enlighten me

I have finished my front-end web dev part. I'm confident in my skills and want to move to the backend section. But the problem is, most influencers promote MERN stack for the backend, and since it's easy to promote as both front end and back end use the same language.

While researching, I found Java, but it's been on a constant decline since 2017, with a 1 percent yearly fall. And languages like Golang and Python are on the rise.

In online debate threads on Reddit, people often mention Python as not scalable and secure, and being very slow. Is that true?

Also, there aren't many Golang courses online.

/r/Python
https://redd.it/1cdc65u
Python Quality Standards

Hey, happy Friday (don't push to prod). Me and some friends are building a no-code platform to run code improvement agents (really in BETA) .

We want to have a quality agent for each language, and I would really appreciate your feedback on python best practices and standards. The agents are created by defining the steps that you want to apply in natural language. Right now our Python agent has the following steps:

* Use descriptive naming for functions and variables.
* Add Type Hints.
* Add proper docstrings.
* Make docstrings follow PEP-257 standard.
* All variables and functions should be snake\_case.
* Add proper input validation that checks for type and not null. If the input validation fails raise an Exception.
* Add useful logs for debugging with the logging library.

In case you want to check our tool, we have a free playground right now at [GitGud](https://gitgud.autonoma.app?utm_source=reddit&utm_medium=post&utm_campaign=reddit-post&utm_id=reddit-post) and are working on github PR integrations.
Happy coding and thank you in advance for your help!

/r/Python
https://redd.it/1cdmls1
Deploying a flask app

Im currently building a small flask app.

Ive got it running locally while im building it. just running it on a development server using flask run.

I plan to deploy it to something like pythonanywhere.

Ive seen people online say to use something like Gunicorn since you should use development servers for production.

Im trying to wrap my head around it, but do i need to use a production ready server? wont that be handled by pythonanywhere once i launch it?

/r/flask
https://redd.it/1cdiwys
I made a Python app that turns your Figma design into code

Link: https://github.com/Axorax/tkforge

Hey, my name is Axorax. I have been programming for a few years now. I started making a lot more projects in Python recently and this is one of them. I decided to call the project TkForge.

What My Project Does TkForge allows you to turn your Figma design into code. So, you can make the UI for an app in Figma and add input fields, buttons and much more and name them properly then you can run TkForge to convert your Figma design into code. The names need to be the element that you want. For example; if you want a button element then you can name it "button" or "button Hello World!". The "Hello World!" portion will just get ignored. All of the text after the first space is ignored. However, for some elements, they matter. Like, if you want a textbox element with the placeholder text of "Hello" then you need to name it "textbox Hello".

Target Audience It is meant for anyone who wants to create a GUI in Python easily. Dealing with Tkinter can be a pain a lot of times and it also

/r/Python
https://redd.it/1cdo8uj
terminal not working

Cannot open Local
Failed to start [powershell.exe, -NoExit, -ExecutionPolicy, Bypass, -File, C:\\Program Files\\JetBrains\\PyCharm Community Edition 2024.1\\plugins\\terminal\\shell-integrations\\powershell\\powershell-integration.ps1\] in C:\\Users\\RT\\PycharmProjects\\pythonProject1, [columns=151, rows=8\], envs={PROCESSOR_IDENTIFIER=>AMD64 Family 25 Model 80 Stepping 0, AuthenticAMD, CommonProgramFiles=>C:\\Program Files\\Common Files, APPDATA=>C:\\Users\\RT\\AppData\\Roaming, =::=>::\\, LOCALAPPDATA=>C:\\Users\\RT\\AppData\\Local, ProgramData=>C:\\ProgramData, COMPUTERNAME=>BYSASNET, SystemDrive=>C:, USERDOMAIN=>BYSASNET, TMP=>C:\\Users\\RT\\AppData\\Local\\Temp, CommonProgramFiles(x86)=>C:\\Program Files (x86)\\Common Files, SystemRoot=>C:\\Windows, HOMEPATH=>\\Users\\RT, TEMP=>C:\\Users\\RT\\AppData\\Local\\Temp, JEDITERM_SOURCE=>C:/Users/RT/PycharmProjects/pythonProject1/.venv/Scripts/activate.ps1, TERMINAL_EMULATOR=>JetBrains-JediTerm, LOGONSERVER=>\\\\BYSASNET, SESSIONNAME=>Console, PUBLIC=>C:\\Users\\Public, HOMEDRIVE=>C:, ProgramFiles=>C:\\Program Files, windir=>C:\\Windows, USERDOMAIN_ROAMINGPROFILE=>BYSASNET, PyCharm Community Edition=>C:\\Program Files\\JetBrains\\PyCharm Community Edition 2024.1\\bin;, Path=>C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\dotnet\\;C:\\Program Files (x86)\\dotnet\\;C:\\Program Files\\PowerShell\\7\\;C:\\Users\\RT\\AppData\\Local\\Programs\\Python\\Python312\\Scripts\\;C:\\Users\\RT\\AppData\\Local\\Programs\\Python\\Python312\\;C:\\Users\\RT\\AppData\\Local\\Microsoft\\WindowsApps;;C:\\Program Files\\JetBrains\\PyCharm Community Edition 2024.1\\bin;;C:\\Users\\RT\\.dotnet\\tools;C:\\Users\\RT\\AppData\\Local\\Programs\\Microsoft VS Code\\bin, PROCESSOR_LEVEL=>25, POWERSHELL_DISTRIBUTION_CHANNEL=>MSI:Windows 10 Pro, ComSpec=>C:\\Windows\\system32\\cmd.exe, NUMBER_OF_PROCESSORS=>6, IDEA_INITIAL_DIRECTORY=>C:\\Users\\RT\\Desktop, PROCESSOR_ARCHITECTURE=>AMD64, PROCESSOR_REVISION=>5000, OS=>Windows_NT, JETBRAINS_INTELLIJ_COMMAND_END_MARKER=>ukbCYHEYKqV5YqsolTRdkxYLo4Ec1DMXFE78Tz7xGYcq1VltE50mw15ptRTwwOEM, USERPROFILE=>C:\\Users\\RT, ALLUSERSPROFILE=>C:\\ProgramData, USERNAME=>RT, ProgramW6432=>C:\\Program Files, CommonProgramW6432=>C:\\Program Files\\Common Files, TERM_SESSION_ID=>668cf38d-70fb-463c-a1ed-b592339c0d12, ProgramFiles(x86)=>C:\\Program Files (x86), PSModulePath=>C:\\Program Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules, PATHEXT=>.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC}
See IDE log (Help | Show Log in Explorer) for the details.
i'm getting this problem , i tried reinstalling PowerShell and pycharm itself , i also tried changing the shell path to cmd.exe , nothing worked

/r/Python
https://redd.it/1cds24v
What is the standard around using number vs UUID for primary field?

I understand using primary key as number sequence might not be best thing to do as it makes it easy to guess url but using uuid can be slow to index and search. I used slug filed before with name and last 8 characters or so from uuid. The easiest to implement common fields like this and created by, created at fields is using inheritance but not all models have name .
Wondering how is everyone handling this? Also want is the best way to get current user here?

/r/django
https://redd.it/1cde0ug
Weird NOT NULL constraint error

Hi all


I'm new to Django, but have been coding for a long time.


I have a simple model with very few fields in one table. There are no foreign keys. I am using SQLite as the DB as I'm learning all this out. I have Django auto-creating the ID field for my model.


From what I have discovered reading online, this should work:
def delete(request, goal_id):
g = Goals.objects.get(pk=goal_id)
g.delete()

However, that throws a not null constraint on the name field. What is confusing to me is, isn't this deleting the entire row? Why would a constraint issue appear here?


When I go directly to the DB from the python command line, I have no issues:

>>> conn = sqlite3.connect('....../db.sqlite3')
>>> cur = conn.cursor()
>>> sql = 'delete from pps_goals where id = 10'
>>> rs = cur.execute(sql)
>>> conn.commit()


For completeness, here is the relevant portion of models.py
class Goals(models.Model):
objects = models.Manager()
name = models.CharField(max_length=50)
total_duration = models.DecimalField("total_duration","total_duration",5,3)

Any ideas what I'm messing up?

/r/django
https://redd.it/1cdwz59
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/1ce0l10
American Airlines scraper made in Python with only http requests

Hello wonderful community,

Today I'll present to you pyaair, a scraper made pure on Python https://github.com/johnbalvin/pyaair

Easy instalation

` ` `pip install pyaair ` ` `

Easy Usage

` ` ` airports=pyaair.airports("miami","") ` ` `

Always remember, only use selenium, puppeteer, playwright etc when it's strictly necesary

Let me know what you think,

thanks

About me:

I'm full stack developer specialized on web scraping and backend, with 6-7 years of experience

/r/Python
https://redd.it/1ce1qi4
I am getting a error when I try to verify the password with argon2. It always come back as False.

What am I doing wrong? Here are the docs https://argon2-cffi.readthedocs.io/en/stable/howto.html Put simply

ph.verify

always returns

argon2.exceptions.VerifyMismatchError: The password does not match the supplied hash

ph = PasswordHasher() ph.verify(...)

Here is the code.

​

routes.py

from argon2 import PasswordHasher, exceptions
from flask import flash

def comparehashedpasswords(hashedpassworddb, plaintextpasswordform):
'''
The code runs in the /login route.
Compares the hashedpassword in the db and plaintext password form.
ph.verify(...) returns True if it matches and returns False if it doesn't match.
'''
ph = PasswordHasher()
try:
verify
password = ph.verify(hashedpassworddb, plaintextpasswordform)
flash(verifypassword)
return verify
password
except

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