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
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/1dzhlys
Anyone moved to Django?

If you moved to Django from other frameworks like (Asp.net, laravel, nodejs, etc) share your experience. And why you found Django to be better.

/r/django
https://redd.it/1dzce7g
I wrote a quit smoking tracker website in Flask

**What My Project Does**

This is a quit smoking tracker website intended for people quitting smoking to be able to track their progress and see health and money milestones to motivate them to stay quit.

**Target Audience (e.g., Is it meant for production, just a toy project, etc.**

It's just a toy project that I wrote in a night, but I'm hoping it can be useful for smokers to stay motivated to quit.

**Comparison (A brief comparison explaining how it differs from existing alternatives.)**

The main difference between this and other stop smoking apps is that this is a website. I haven't been able to find any websites that were similar to the stop smoking apps you can get for your phone, which is partly what motivated me to write this.

Site: https://jimmyrustles.pythonanywhere.com/quitsmoking

Source: https://github.com/sgriffin53/quitsmoking_app

This is a screenshot of what the site would look like for someone who's been quit for 6 months: https://i.imgur.com/8ayu0yu.png

You enter your name, quit date, and how much you spend on smoking per day, and it creates a page that you can come back to.

As you can see, you unlock health benefits and "things you can buy" with your saved money the longer you stay quit.

The things you can buy is based

/r/Python
https://redd.it/1dzij6s
I made (or attempted to make) a better web interface for creating and sharing flashcards than Ankiweb.

It is a prototype of a web interface for Anki that is supposed to be better than ankiweb.net. It may currently be used to create and study basic flashcards, but it is incompatible with Anki files (*.apkg) and lacks many of the features that Anki offers.

I created it as a learning project and to experiment with my really basic idea of sharing and cloning decks using a web interface. I’ll continue to work on it to improve it further, but it isn't meant to be a full-fledged web application.

You can check out and live demo and repo:

Live Demo \- Repo

I’m using Flask for handling all the client requests, validating forms, and handling the database side of things.

However, the one part of the website, which fetches the card from the server for the user to study and then cycles through those cards based on user response, is built in Javascript here, which has been bothering me for some time. Because I believe it would be more interesting to handle it on the backend side. So it will be the next thing I work on.

If you have any suggestions or comments on the project or code, please share.

/r/flask
https://redd.it/1dzl1jj
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