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/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
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/1e13kw8
Shelly blu door and window sensor

I have a Shelly blu door and window sensor connected through a Shelly plus 2 PM. I’m trying to find a way to get the status open/closed using python or home assistant.

/r/Python
https://redd.it/1e14p0r
R Memory^3 : Language Modeling with Explicit Memory

TL;DR who needs plain text knowledge database when you can use memory?

Paper: https://arxiv.org/pdf/2407.01178

Abstract:

>The training and inference of large language models (LLMs) are together a costly process that transports knowledge from raw data to meaningful computation. Inspired by the memory hierarchy of the human brain, we reduce this cost by equipping LLMs with explicit memory, a memory format cheaper than model parameters and text retrieval-augmented generation (RAG). Conceptually, with most of its knowledge externalized to explicit memories, the LLM can enjoy a smaller parameter size, training cost, and inference cost, all proportional to the amount of remaining "abstract knowledge". As a preliminary proof of concept, we train from scratch a 2.4B LLM, which achieves better performance than much larger LLMs as well as RAG models, and maintains higher decoding speed than RAG. The model is named Memory^(3), since explicit memory is the third form of memory in LLMs after implicit memory (model parameters) and working memory (context key-values). We introduce a memory circuitry theory to support the externalization of knowledge, and present novel techniques including a memory sparsification mechanism that makes storage tractable and a two-stage pretraining scheme that facilitates memory formation.

Visual abstract:

https://preview.redd.it/7ikm0npl0ybd1.png?width=1111&format=png&auto=webp&s=0fc2c48f224324add4c8802d55232922779124d1

Highlights:

>[O\]ur model first converts a knowledge base (or any text

/r/MachineLearning
https://redd.it/1e0y7do
I've created a celebrity trivia game in Flask that uses information from their Wiki page as clues

I wrote this game a couple of years ago, and I've just ported it to a Flask app on my website.

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

Github:
https://github.com/sgriffin53/celebritytriviaapp

What My Project Does

It gives you clues from the celebrity's Wikipedia page, and you have to guess the celebrity.

Here's an example game:

(born June 22, 1973) is an American television host, radio personality, producer, and television personality.

Clue 1: had a small role on Dave Chappelle's show Chappelle's Show..

Clue 2: The Download with , syndicated (2013– ).

Clue 3: At the end of the summer of 1997, MTV hired as a permanent VJ, a position which required to relocate to New York.

Clue 4: In March 2000, Tara Reid met on the set of Total Request Live, and they began dating.

Clue 5: When social media correspondent Christina Milian departed the show in 2013, became the sole host.

The answer for this would be Jennifer Love Hewitt.

You can request as many clues as you like and it'll give you 5 random clues from the Wiki page with each request. There

/r/Python
https://redd.it/1e11nom
Is there a way to auto update apache server webpage when changes to code are made?

Before when my files were stored on apache the website seemed to auto update but now that I've migrated to an application server like flask, it doesn't seem to do this. Someone had told me that the html code might not auto update since its static type or cached but the python code should.

/r/flask
https://redd.it/1e19qux
Command mode on iPad browsers does not work

Hey, I have been trying to use JupyterLab remotely with my ipad. I have no trouble being able to connect to the host and display everything in safari. However, my issue comes when im editing a notebook. When im editing a cell and i go back to command mode (using esc key on keyboard) the commands do not work. Also, Im unable to go back to edit mode using the keyboard, i can only go back by clicking inside the cell (which is annoying because i have to reach out to the screen or to my mouse every time). I have tried JupyterNotebook, JupyterLab and different iPad browsers. I dont get this issue on PC browsers.

Is there any fix to this?


/r/IPython
https://redd.it/1e19dnk
Connection pool for Postgres

Is the psycopg2 connection pool created on a session basis? I have seen several examples but can't figure it out . Also where should I store the pool variable? Is app.config different for each session?

/r/flask
https://redd.it/1e1dxqk
Why choose Django?

I am learning front-end web development and I think it is time to choose a back-end framework. I want to use Django, but others are recommending the MERN stack. What should I choose? I don't care about the difficulty level or other factors; I only care about job demand.

/r/django
https://redd.it/1e1f3uj
What's the best and most modern e-commerce framework for Django?

I'm looking to build a shop with Django, but not sure the best way to go. I'd rather not have to build it from scratch or go with something ghastly like Woocommerce, so I'm looking for a framework that's relatively quick to set up, is easy to customise and has a good range of features.

From what I've found already:

Saleor seems the most fully featured but it also looks very complex, perhaps more than one person can set up in a reasonable amount of time. Can't be bothered with GraphQL/React etc. for a fairly basic shop.
Longclaw seems interesting, especially as it integrates with Wagtail, but it looks unmaintained and doesn't work with recent Django versions.
Django Oscar seems well maintained but it's hard to gauge what it's like as the demo site is down and the showcase sites have either been replaced or are not reachable.
Satchless was archived a while back and Plata, Cartridge/Mezzanine and LFS haven't been updated in years.

What do you do for e-commerce? Are there other approaches I've missed?

/r/django
https://redd.it/1e1g8l2
How to create PDFs with formatting requirements & dynamic content?

Hello,

TLDR: How do I (or generally speaking) generate PDFs with a specific formatting requirement using dynamic content?

I am attempting to build a web app (using Flask) for a local non-profit who hosts judged shows throughout the year. Part of their process is to print out place cards to put next to each entry (with the corresponding information). These place cards are usually printed on a standard 8.5 x 11 piece of paper. However, the paper is pre-perforated so that it is easier to just rip them apart.

So, what I am attempting to do is to use an HTML to PDF conversion tool (pdfkit) to convert an HTML page that has been separated into quadrants into a PDF document. Which I then send the client as a download.

However, every time I try this the PDF just doesnt work. Specifically, it does not keep the quadrant formatting. Rather, the page shows the quadrants as rows at the top of the page.

My question is: How does one use Flask and corresponding libraries to generate these type of dynamic content PDFs? Or, more generally, how do web apps generate PDFs in the wild?


Here is the HTML &

/r/flask
https://redd.it/1e156nm
Is pytorch faster than numpy on a single CPU?

A while ago I had benchmarked pytorch against numpy for fairly basic matrix operations (broadcast, multiplication, inversion). I didn't run the benchmark for a variety of sizes though. It seemed that pytorch was markedly faster than numpy, possibly it was using more than one core (the hardware had a dozen of cores). Is that a general rule even if constraining pytorch to a single core?

/r/Python
https://redd.it/1e1cfpt
win32com.client.GetObject('SAPGUI') error while connecting to SAP in flask

path = r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe"
subprocess.Popen(path)
time.sleep(5)
SapGuiAuto = win32com.client.GetObject('SAPGUI')
application = SapGuiAuto.GetScriptingEngine
time.sleep(5)

I'm getting the below error

Traceback (most recent call last):
File "c:\Users\AppData\Local\anaconda3\Lib\site-packages\flask\app.py", line 1498, in __call__
return self.wsgi_app(environ, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\AppData\Local\anaconda3\Lib\site-packages\flask\app.py", line 1476, in wsgi_app
response = self.handle_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\AppData\Local\anaconda3\Lib\site-packages\flask\app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()


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