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
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
Terminal Webmail - GMail in the Linux Terminal

# Terminal Webmail - GMail in the Linux Terminal

* **What My Project Does**
* GMail in the web browser is extremely slow on older machines, requires JavaScript to be enabled, and can't run in text mode.
* If you live in the Linux Terminal and you need access to GMail, you'll love Terminal Webmail.
* Features:
* Print email in terminal including inline images and gifs
* Print attachments in terminal
* Download attachments
* Mark email as read
* Reply to email using the default EDITOR on your system
* Write email
* Set to, cc, and bcc for any reply or written email
* **Target Audience**
* Anyone who lives in the Linux Terminal and needs access to GMail
* **Comparison**
* On my EEE PC from 2011, GMail in Firefox runs like a dog while Terminal Webmail is extremely performant.

Here's a link to the GitHub repo: [https://github.com/RNRetailer/terminal-gmail-client](https://github.com/RNRetailer/terminal-gmail-client)

Here's a link to the commercial webstore: [https://terminalwebmail.com/](https://terminalwebmail.com/)

/r/Python
https://redd.it/1e1x3n7
My Python project to batch convert excel files to csv/txt

I created this project last year when working with financial & accounting data and now I made it an application with tkinter.

What My Project Does

Simple and easy to understand and use, it batch converts excel files from an input folder location to csv/txt and export to an output folder.

Target Audience

Just a project I made. If you can give me some feedback, I would appreciate.

Comparison

Well, I did use ASAP utilities to do this, but the problem is that it only supports with the active sheets, i.e. the last place where you hit Save your workbook. This could mess your output, so you have to ensure the correct active sheet, and this is tedious.

In my project, I add the option to choose the sheet index to convert. This is quite handy if all files had the same layout.

Github repo: https://github.com/fusted2/Convert-Excel-to-CSV

/r/Python
https://redd.it/1e212c2
Nested routing multiple plural

I'm a beginner, and at work I got an OpenAPI spec to implement that looks like /houses/rooms/ which means "list all rooms available in all houses", and to make a new room, make a post request to this endpoint with the new room details and also the house id in the body. However, if I study at resources/tutorials online, most nested routes are always /houses/{house_id}/rooms/, which would then only list rooms of a particular home. The standard DRF ModelView also give things in this pattern.

With the one in the spec, in my house controller's/viewset I need to make a custom action called rooms and call the rooms' ViewSet list method. There, I then have to check the request path, and if its houses, then get all rooms in all houses.I can imagine this becoming a lot of if elseifs (e.g hospitals/rooms, offices/rooms, etc). I can of course make a mapping instead between the request path with the correct entity's dbset/queryset. But this whole "checking the path to determine what to do" and calling other viewsets in a viewset feels wrong. Any thoughts/ideas? Or am I wrong? This can indeed work but I'm not sure it will scale well

/r/django
https://redd.it/1e25to5
Looking for working on a side project just for learning (without compensation is fine too)

Hi,
So I am a self-taught dev currently been working in the python eco-system with US start-up since past three years. However, my job is in intelligent automation domain (for which we don't use Django) and I have been kind of feeling stagnant on the professional front. Hence, just for learning sake I was wondering if some experienced person would want a fresher Django developer for any project. My goal here is simply to work under someone who could assign me tickets and most importantly review my submissions and provide feedback. I am not looking for any kind of monetary remuneration and am just here to learn.

I am willing to give 15-20 hours per week.

I have tried experimenting it on my own through videos building and breaking things on the side but wanted to experience things in a more professional setting. The feedbacks would be immensely valuable.

Any help in this direction? I'd be really grateful

/r/django
https://redd.it/1e2glod
Computers are fast Python perf quiz

I first encountered Julia Evans' Computers Are Fast performance quiz soon after it was published 10 years ago. It was so eye opening as a new programmer to get a few of the questions wrong by a 2-3 orders of magnitudes.

I wanted to update that quiz for 2024, swapping out Rust for C and fixing a couple of places where the 2014 quiz's Python 2 code does not translate directly and obviously into Python3.

Try it out and see how you go :)

https://thundergolfer.com/computers-are-fast

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