Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.8K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
D RoBERTa From Scratch!

After seeing Karpathy's from scratch GPT model, and a Llama 3 model by u/atronoskronios, I started creating my own "from scratch" implementation of RoBERTa for multiclass classification. In actuality, I did not train the initial weights or implement the attention layer. Rather, I created code to work around those given weights.

In my Github repository, I include a file for the implementation and a separate file for the tokenizer "from scratch" (I didn't have the resources to fully train the tokenizer to RoBERTa standards).

Some code could be unnecessary, but this is what I have got working.

Here is the repository-- thanks: [
https://github.com/nhemauer/Projects/tree/main/RoBERTa%20from%20Scratch](https://github.com/nhemauer/Projects/tree/main/RoBERTa%20from%20Scratch)

This taught me a ton about NLP, and I'd recommend those who have similar interests to check out the Llama 3 from scratch as well: [
https://www.reddit.com/r/MachineLearning/comments/1djyilm/p\llama_3_language_model_implementation_from/](https://www.reddit.com/r/MachineLearning/comments/1djyilm/pllama3languagemodelimplementationfrom/)

/r/MachineLearning
https://redd.it/1dzllu1
Posting - the modern HTTP client that lives in your terminal

Hi Reddit!

I just released version 1 of Posting, an open source TUI HTTP client built using Python and Textual.

# What my project does

Posting is an HTTP client TUI app.

It works over SSH, stores collections locally in a simple (and Git-friendly) YAML format, and can be operated efficiently using both keyboard and mouse.

It aims to push the limits of what you expect from a TUI app in terms of both aesthetics and efficient workflows.

# Target audience

If you work with, test, or develop HTTP APIs, you might find it interesting :)

# Comparison

You can think of Posting as sitting somewhere between Curl and Postman.

Like Curl or HTTPie, it runs in the terminal. This means it works over SSH and you can use it from remote hosts. It's can also be driven efficiently with the keyboard, although you can operate it entirely with the mouse if you wish.

It offers an environment/variables system like Postman, Bruno, and Insomnia. This means you can define variables inside external files, load them into Posting, and then refer to them inside your request.

Similar to some of the GUI tools mentioned, it stores requests in collections. Posting stores them entirely on your local machine in a simple YAML format.

/r/Python
https://redd.it/1dz775b
Photoshop API - Read and Write PSD files with Python and C++


Hey,

Emil Dohne is creating a modern and performant C++20 read/write parser of Photoshop Files (*.psd and *.psb) with fully fledged Python bindings hosted on PyPi, completely on its own.

I just wanted to help him out trying to make his work known, so that more people can utilize this incredibily useful repo and in order to find someone incredibly talented and kind people that wanted to help him out collaborating in the development! At the moment Emil is occupied by another project that he will end by the end of July and he will then be back 100% on this project.

I reckon that the hierarchy of new features needed/really wanted are the following:

1. Support for Smart Object Layers - replacing images inside of the smart object
2. Support for Adjustment Layers
3. Support for Vector Masks
4. Support for Text Layers
5. CMYK, Indexed, Duotone and Greyscale Color Modes

Thank you to whoever even takes the time to read this, let alone whoever shares this project and even more to incredibly smart people that will help Emil out.

Here's some more info about this project: https://github.com/EmilDohne/PhotoshopAPI

# What my Project does

PhotoshopAPI is a C++20 Library with Python bindings for reading and writing of Photoshop Files (*.psd and *.psb) based on

/r/Python
https://redd.it/1dzq8qk
Encountering 400 Bad Request Error on My First Django + React Web App


Hello everyone,

I am currently building my first web application using Django and React, and I've hit a stumbling block. While following a guide by TechWithTim (Django & React Full Stack Web App Tutorial from march 26 - youtube video), I've encountered a persistent 400 Bad Request error during user registration attempts.



Project Repository: You can access the complete code for the project on my GitHub: https://github.com/Drakkarok/DjangoFirstWebApp

Please feel free to fork it, take a look, and contribute any insights you might have.



Issue Description: Each time I try to register a new user through the frontend, the server responds with a 400 Bad Request. This error persists regardless of the input I use.



This is my first attempt at using Django and React (both for me are new), and my experience with JavaScript is quite limited. Therefore, there might be some fundamental misstep that I'm overlooking.



I would greatly appreciate any guidance or suggestions on how to resolve this issue, as it may be something simple that I'm not seeing due to my inexperience.



Thank you very much for your help and patience!

/r/django
https://redd.it/1e0103m
Built an Extension to Research How Scope Boundaries Affect Notebook Programming

Hi Everyone! My name is Eric Rawn. I’m a PhD student at UC Berkeley focusing in Programming Languages and Human-Computer Interaction. I primarily study how experts (like data scientists) use programming to think about their work, and how to design programming environments to better support that thinking.

I've been working on an extension for jupyter notebooks/IPython (its actually two extensions, due to how IPython and Notebooks work together) which we hope will make it easier to keep variables tidy without requiring data scientists to change the iterative, exploratory ways they use notebooks for programming. In short, it introduces scope boundaries to collections of cells, with the idea of supporting a happy medium between the structure of traditional programming and the flexibility of notebook programming.

To be honest, I find notebook interfaces both a bit miraculous and a bit aggravating, and my work has focused on trying to understand why that is! (and how we might focus more on the miraculous part). We’re evaluating how our extension aids how real users program, and so we’re running a 2-6 week study with folks who use Jupyter notebooks regularly in their everyday programming. Through interviews and some logs the extension will generate, I'd love to learn about

/r/IPython
https://redd.it/1e03fwc
Veracode static scan in vscode fails

I am trying to scan code using veracode extension in bs code I have credentials for that . The authentication step is completed and agent is also installed but when I start scanning code it runs for few minutes and then ends up with error message "static scan failed: partial scan results may be available."
And other error msg "error completing scan : server returned a failure status".

How to scan code in vscode ??

/r/IPython
https://redd.it/1e038wf
Did you ever need to switch off of sqlite for a personal project?

I like sqlite for its built-in python integration. However I am starting to wonder if for a personal project if it will ever become big enough that it will require scaling and outgrow sqlite.

Anyone have experiences to share?

/r/flask
https://redd.it/1e0453c
Django Admin runs custom function Multiple times

Hello everyone, I was writing a function in Django Model Admin and noticed the function gets executed multiple times. Here is the code:

@admin.register(User)
class CustomUserAdmin(ModelAdmin):
readonlyfields = 'custom_field'

def customfield(self, obj):
books
count = obj.books.count()
print(bookscount)
return books
count

The print statement was executed 4 times, does anyone know why this happened?

/r/django
https://redd.it/1e04ji2
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/1e0b18d
Dishka - cute DI-framework with scopes and control

In the name DI in Python I want to tell about my project dishka.

If you are not familiar with the term Dependency Injection, I can suggest reading my article here.
In short: objects should receive their dependencies as constructor arguments but not requests themselves. DI-framework is a thing that helps you to create a hierarchy of such complex objects.

Dishka is a DI-framework (IoC-container) and I wanted to make it really useful and easy to use. I can say, it is like Fastapi-Depends but without fastapi and with more control and features.

What Project Does: it helps you to manage a hierarchy of objects, initialize and finalize them following DI-approach

Target Audience: Any developer, who does more for project structure

License: Apache-2.0

Comparison:

I know that there is a bunch of other projects, so I spent some time for analysis and wrote down some requirements.
Here are some key ideas:

1. Dependencies have dependencies, some of them should be reused. It could sound obvious, but in some frameworks it is hard to share database connection between DAOs used together.

2. Dependencies can have finalization. As framework hides the hierarchy of created objects, you shouldn't trace it back to clean them up. Opening and closing resource in the

/r/Python
https://redd.it/1e02ay9
I underestimated django and t3.micro

I built my first app in django and deployed on t3.micro.. as t3 is burstable and django is built on top of pure python.. I thought django performance would be slow and it would taken up a lot of cpu. However the reality was pretty much different from the expectation.. there were about 100 visitors and cpu usage was only up to 1~3% and burst credits remains the same.. and the performance is fast enough.. django is good man..

/r/django
https://redd.it/1e0ex46
Application layers in flask

Today I got feedback on my Flask app that there's no separation between application layers, that it references the database, middle layer, and front all together. I have set up my code using Blueprints and otherwise follow a pretty standard Flask layout. Am I doing something wrong or is this the nature of Flask (everything combined together)?

/r/flask
https://redd.it/1e04vum
Best way to connect to an office 365 mail domain

Is using the msal library and graph api the best way to have a python app to read and send emails on a office 365 custom mail domain? Are there better alternatives?

/r/Python
https://redd.it/1e0lu5r
Best practice .PDF generation

I need to develop an application which is capable of generating .PDF reports with many figures. The data is stored in a django database and currently served via django-ninja to a vue frontend.

In the past, I worked with weasyprint and liked it, although, I found the styling part quite exhausting. Nevertheless, now most of the figures are rendered in the vue frontend with chartsjs and I don't want to rebuild them with matplotlib.

Can you recommend any libraries or workflows allowing me to use similar styling and figures in the classical frontend and in the PDF?

/r/django
https://redd.it/1e0pkxw
Django best practices?

I'm currently a junior developer with half a year of experience using django. I want to know what are the best practices that I need to consider? My tasks revolves around REST framework, so if you have some tips that you can share or anything that can help me, it'll be helpful. Thank you

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