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
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/1dpdhpn
Building a SaaS for Scraping and Categorizing News Articles: Need Your Help!


I'm developing artikle, a platform that processes and analyzes millions of articles and LinkedIn posts each week. The backend (python) is working perfectly.

I'm trying to setup a frontend for this app (I have 0 experience in front). I'm using dash bootstraap and flask.

Currently, I'm focusing on creating a page dedicated to store openings worldwide.

You can check it out here: Artikle - Store Openings.

I want to make the page more user-friendly and better explain its use case. Do you have any resources or suggestions to help improve it?

Thank you!

/r/flask
https://redd.it/1doybmr
Just released: Episode 1 of "Introduction to Programming"!

In a world where technology shapes our future, we believe learning to code should be an adventure. Through our engaging and entertaining cartoons, kids will embark on exciting journeys with Aadi, Gogu, and their friends. As they enjoy the fun and laughter, they'll unconsciously absorb the fundamentals of programming. Our mission is to make coding accessible, enjoyable, and second nature to the next generation.

You can watch full video on You tube :

https://youtu.be/X7L6qw1kqeA?si=bLK4dLvTD1jpzDD8



/r/Python
https://redd.it/1dpn503
Those dicts you probably needed at some point

Hi everyone!

I have created a dependency-free package those-dicts that provides some subclasses of dict with a twist: BatchedDict(no, it is not ChainMap from collections), GraphDict and TwoWayDict. At some point I have personally needed those and finally decided to materialize them. Of course there are some specialized libraries, that can provide similar functionality, but they are very bloated. And those-dicts are just dicts.

https://github.com/jakubgajski/those\_dicts

If you have some dict with a twist in mind, please open a PR or describe it to me, so I will implement it in the free time :) The only requirements for an idea to fit is: it is a dict (conforms to vast majority of dict interface) and is dependency free.

just: pip install those-dicts

/r/Python
https://redd.it/1dpnc09
What attracted you to django?

When I was previously working in some company, I used django for their internal project. I merely knew name of this framework & nothing else. When I went further on, I realised how simple & fun it was to use django, i.e. DB connection, simplicity of customizing authentication etc. Things were gr8..
And I read news about Elon Musk buying Twitter and rebranding it to "X". I suddenly thought how easy & fun it would be to change all things if Twitter engineers were using django for their backend as well as frontend. (It might sound strange tho.)
That's when I decided to make a career as Python backend developer.
So what was "turning point" for you to get attracted to django framework??

/r/django
https://redd.it/1dpmitf
Flask Architecture Question

Hope this is an alright place to ask, but worried this is "obvious" to seasoned developers and only doesn't make sense to me.

I work on a Flask API fronted by nginx. There's another team working on a React front-end that I have nothing to do with. I don't know how the front-end runs, whether it needs nginx in front of it...

My question is this - I understand the chain of nginx -> gunicorn -> Flask.

Say I wanted to stand up a web-app with my friend who is a FE developer, but has only deployed in "serverless" environments and is relying on me entirely for the architecture.

What's the "normal" way of setting things up? In other words, if my Flask API is only consumed by whatever JS front-end he builds, and is never open to the internet, and they're all running on the same server, does it go nginx -> front-end -> Flask API? Or do I need another layer of nginx between the front-end and the Flask API?

Also, should there be authentication built-in between the FE and the Flask API, even if they're running on the same server in say, a docker compose setup and commuincating over the docker network?

Sorry

/r/flask
https://redd.it/1dpnd0n
C++ binding library

I am looking for a Python binding library to expose a pretty big set of C++ classes to Python code. The following features are important to me:

Compatibility with C++ shared pointers
Function and method overloading
Operator overloading. Example: a = Vec3(1, 2, 3) + Vec3(1, 0, 0)
std::wstring has to be supported, some way, somehow, even if it involves jumping through a lot of hoops
Compatibility with the Microsoft Python Debugger for Visual Studio Code
We need to maintain compatibility with the greater Python ecosystem of libraries.

Which lib would best be suited for this purpose?

/r/Python
https://redd.it/1dpsazq
Check for Open Ports using Python

## What my Project Does
This Python script is designed to scan specified ports on one or more target IP addresses to determine if they are open or closed. It uses multi-threading to perform the scans efficiently and outputs the results in a color-coded tabulated format for easy reading. The script provides the ability to scan either a single port or a range of ports on multiple targets.

## Target Audience
This project is intended for:
- Network administrators who need to check the status of ports on various devices within a network.
- Security professionals who want to perform network reconnaissance to identify open ports that could be potential security risks.
- IT support staff who need to troubleshoot connectivity issues by verifying open ports.
- Enthusiasts and learners who are interested in network security and port scanning techniques.

## Features
- Multi-threaded for efficient scanning
- Supports scanning multiple targets
- Supports single port or port range
- Color-coded output for easy reading
- Verbose mode for detailed output

## Requirements
- Python 3.6+
- colorama library
- tabulate library

## Installation
Before running the script, ensure you have the required libraries installed. You can install them using pip:

pip install colorama tabulate


## Sourcing the script
You can download the script here on GitHub.

## Usage
Run the script with the

/r/Python
https://redd.it/1dptsb5
Favourites chrome extension for Django Admin

I was getting very tired of searching for and scrolling through links in my admin page. To solve this problem I built a chrome extension that allows you to add a list of favourite links to the top of your django admin home page. Find the extension here.

The extension runs locally and will be free forever! Hope this is helpful for you.

Example of favourites links:

Favourites chrome extension for Django Admin

/r/django
https://redd.it/1dpmt6g
Do people actually use blueprints?

I have made a number of flask apps and I have been wonder does anyone actually use blueprints? I have been able to create a number of larger apps with out having to use Blueprints. I understand they are great for reusing code as well as overall code management but I just truly do not understand why I would use them when I can just do that stuff my self. Am I shooting my self in the foot for not using them?

/r/flask
https://redd.it/1dpuf0t
Copy model instance to prefill form?

I am making a recipe application. I want to be able to copy an existing recipe and make edits to create a new recipe. How I can prefill a form/edit view using an existing model instance and then save the data into a new model instance?

Here is my current model structure, it's implementation assumes that a recipe is composed of pre-existing ingredients and, potentially, other user generated recipes.


Models.py

class Ingredient(models.Model):
"""Base ingredient class"""
name = models.CharField(max_length=500)
...

class Recipe(models.Model):
"""Base recipe class containing instructions and description"""
name = models.CharField(max_length=500)
...
ingredients = models.ManyToManyField(Ingredient, through='RecipeIngredient')
sub_recipes = models.ManyToManyField('self',


/r/django
https://redd.it/1dq7jrh
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/1dq60v8
How to not write atrocious APIs with Django Rest Framework?

I recently wrote an API with django which does a lot of things, and it got me thinking that I really have a big gap in my django/ django rest framework knowledge. It is basically creating User instances for a staff user. The API is supposed to take role and different subject ids which will be used for the SubjectTeachers model. Then, after creating a user, it sends email to the user's email through a celery task. It also handles email already being sent, and just resends it based on if the user changed their password or not.


The thing is, I don't think I'm handling this in any good way. There are no use of serializers, functions, just a big ass function doing a lot of things. I want to know how would you handle it in a proper way, following proper conventions provided by django and django rest framework. There is no proper error handling, half ass validations.

Please provide me with your insights, resources on how I should properly approach building APIs with django rest framework, and how this API should have been created.

```python

class InviteStaffApiView(APIView):


/r/django
https://redd.it/1dps3lu
FastCRUD - powerful CRUD methods and automatic endpoint creation for FastAPI

**What My Project Does**

**FastCRUD** is a Python package for **FastAPI**, offering robust async CRUD operations and flexible endpoint creation utilities, streamlined through advanced features like **auto-detected join** conditions, **dynamic sorting**, and offset and cursor **pagination**.

We recently reached 450 Stars on Github and Over 24k Downloads! With more users joining our community, there's a lot of work ahead. Whether you're a fan of Python, FastAPI, or SQLAlchemy, or just interested in contributing to open-source projects, we'd love your help!

You can contribute by:

* Opening issues
* Finding and reporting bugs
* Testing new features
* Improving documentation
* Fixing bugs
* Adding new features
* Creating tutorials


**Target Audience**

People who currently use or are interested in FastAPI with SQLAlchemy and SQLModel

**Comparison**

For the endpoint part, there's [FastAPI CRUD](https://github.com/awtkns/fastapi-crudrouter) router, but it's unmaintained (does not support Pydantic V2), for the CRUD methods the alternative would be writing from scratch.


GitHub: [https://github.com/igorbenav/fastcrud](https://github.com/igorbenav/fastcrud)

Docs: [https://igorbenav.github.io/fastcrud/](https://igorbenav.github.io/fastcrud/)

/r/Python
https://redd.it/1dq7af3
Django Middleware unable to process

I have a django project in which I am using two custom middlewares.

One of the middewares is called AuthorizationMiddleware

class AuthorizationMiddleware:
def init(self, getresponse=None):
self.get
response = getresponse

def process
view(self, request, viewfunc, viewargs, viewkwargs):
view
name = '.'.join((viewfunc.module, viewfunc.name))

if viewname in EXCLUDEFROMMIDDLEWARE:
return None

def call(self, request):
token = request.headers.get("Http-Authorization")
if token:
request.META[AUTHENTICATION
HEADER] = f'{token}'


/r/django
https://redd.it/1dqg551
Scraping Ecommerce Platforms Using Python

The online retail or e-commerce industry has seen a fast pace of growth since its launch. This boom is also witnessing the rise of 10-minute delivery models, revolutionizing how customers interact with e-commerce platforms. 

This article will explore how to scrape data from e-commerce platforms using Python.

Ream More: https://ecommerceapi.io/blog/scraping-e-commerce-platforms-with-python/

/r/Python
https://redd.it/1dqgxds
What's better memorizing codes or understanding them deeply?

I'm new to python and I'm just wondering is my strat of learning 2 syntax a day and spending maybe 1 hour learning them and understanding them. better than just memorizing them?

/r/Python
https://redd.it/1dqivtw
Error while finding module specification for 'flask.__main__' (ImportError: cannot import name 'Flask' from partially initialized module 'flask' (most likely due to a circular import)

I have this error and I have no idea how to fix it. My app.py file has the following code:

import os
from flask import Flask, render_template, session, redirect, url_for
from dotenv import load_dotenv
from users import user_bp

load_dotenv()

app = Flask(__name__)
app.secret_key = os.environ.get('FLASK_LOGIN_SECRET_KEY')
app.register_blueprint(user_bp)

Can someone point me in the correct direction please?

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