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
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
Python Principles Course on Udemy!

Hello everyone! My team and I created a course for those starting their programming journey and those needing a refresher on the basics of Python. This course provides an hour of video content and offers hands-on coding exercises, where you can practice and enhance your coding skills with real-world situations. If you're unsure about the quality of our courses, we have another machine learning course, with over 400 students across 70+ countries who enrolled within a week of the course being live. Plus, this very course gained over 300 members within a week as well! If you're curious, the course is linked here: https://www.udemy.com/course/principles-of-python-programming/

/r/Python
https://redd.it/1e1oczh
What's the best deployment for a Django startup business? AWS? Heroku?

Hi All,

I’m a front end developer and I’m pretty close to wrapping up a side hustle project which is a Django e-commerce application locally on my machine and I would like to deploy this onto either AWS or Heroku. 

What would you guys suggest would be the best recommendation? 

I was looking into: 

 - Lightsail which is $7 a month for an instance of Django 4.2.13. 

 - Elastic Beanstalk with a free tier RDS. That would be $15/month.

 - Heroku (I have William Vincent’s books on Django and that’s what he uses so I was thinking of doing the same.)

Currently, I have both an AWS and Heroku account. 

Also, I have a domain name purchased for my side project in AWS. 

I’ve been messing around with Elastic Beanstalk this week and successfully was able to get their sample application out so I can get used to AWS. 

Ideally I would like to have a total of 2 environments (Staging and Production).

I’m also thinking about if this application gets lots of traffic in the future what would be the best out of the two. 

Heroku seems more straight forward with someone that has limited experience doing devops and deployments, but I’m not sure. AWS seems like I can screw something

/r/django
https://redd.it/1e1jkbo
Help Unable to import WTForm class to my controller.py file

```
.venv
|____applications
| -__init__.py
|-config.py
|-controllers.py
|-forms.py
|____templates
|-name.html
|____static
|____main.py
```

Considering my file structure above

I am unable to import NamerForm from forms.py to controllers.py. Getting ImportError

main.py

from flask import Flask
import os, application.config
from application.config import LocalDevelopmentConfig
from application.database import db


app = None

def createapp():
     app = Flask(name, template
folder='templates', staticfolder='static')
     app.config['SECRET
KEY']='somekey'
     if os.getenv('ENV',"development") == "production":
          raise Exception("Currently no production config is set up.")
     else:
          print("Starting Local Development")
          app.config.fromobject(LocalDevelopmentConfig)
     db.init
app(app)
     app.appcontext().push()

     return(app)

app = create
app()


from

/r/flask
https://redd.it/1e1pb97
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/1e1wj7h
How to secure the source code of my django app?

I created a management system in django for a store, the app will be run on the local server of that store. How can I secure the source code? I am afriad that the store manager will take my app and give it to other people to use it and thus prevenetig me from reselling my app

/r/django
https://redd.it/1e1hzlk
Free-threaded CPython is ready to experiment with!

https://labs.quansight.org/blog/free-threaded-python-rollout

> Yesterday, py-free-threading.github.io launched! It's both a resource with documentation around adding support for free-threaded Python, and a status tracker for the rollout across open source projects in the Python ecosystem

/r/Python
https://redd.it/1e1s08n
First python project

I have been studying python for about 1 to 2 weeks and I have been really enjoying the language, I just wanted to show off what I made as my first big program/project.

What My Project Does
Its a very basic investing game I made to attempt to teach an investing motto that I think is very important, time in the market beats timing the market. It is completely console based so to be honest its pretty boring and it takes too long to play, but I am proud of it.
Target Audience
No target audience, just a project I did
Comparison
I can't really give it any comparisons, I just made it based off of an idea i had

Here's a link to the GitHub repo:
https://github.com/erikhox/Market-Game

/r/Python
https://redd.it/1e1twdj