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
Real time collaboration whiteboard for Jupyter notebooks?

I'm finding a common scenario for remote data science meetings is that a data scientist screen shares their Jupyter notebook in Zoom or Hangouts, then proceeds to start scrolling down and explaining their results. Usually their font size is too small and somebody asks them to zoom in a little. When I ask questions about a plot or table, there's a lot of "can you scroll up a little, no too far, back down a little" before they get to the one of interest. If I want to point to an area of the plot or highlight a number in a table, I can annotate with Zoom but not Hangouts, and with Zoom the annotation locations are out of place once the notebook is scrolled.

It seems like there should be a way where the presenter can share their notebook as a collaborative whiteboard, with support for annotations that stay in place and the ability to save the annotated notebook content after the meeting is over. This would let each meeting participant highlight an area of interest that would be shown the rest of the participants ala Google Docs, except I don't even need the ability to have people edit the

/r/JupyterNotebooks
https://redd.it/vzsg09
New, free book from Al Sweigart: Python Programming Exercises, Gently Explained

Hello, I've released my new book "Python Programming Exercises, Gently Explained". You can read it for free at:

https://inventwithpython.com/pythongently

Description: Many books and websites have aggressive programming challenges for top coders. However, Python Programming Exercises, Gently Explained is for the rest of us. We want challenges that improve our coding skills, not leave us confused and discouraged. Other tutorials and books have taught you the basics of Python, but the 42 programming exercises in this book let you practice what you've learned. Selected for their simplicity, these programming problems include gentle explanations of the problem, the prerequisite coding concepts you’ll need to understand the solution, and helpful templates to put together the programs if you have trouble starting from scratch.

This is the perfect book for beginner and intermediate programmers who want to test their Python skills but aren’t ready to begin professional-level software development. You don’t need the frustration of being expected to create complex algorithms and computer science theory; you need a large set of programming challenges that meet you at your level, with gentle explanations.

/r/Python
https://redd.it/y38r6b
Starlite: v1.27.0 updates

Hi Pythonistas!

Been 3 weeks since my last post here and a lot of new stuff happened in Starlite land.

First off, lemme start with the usual intro for those who don't know what im talking about: Starlite is an ASGI (async Python) API framework. It started out as an alternative to FastAPI - built on the same foundations: the Starlette ASGI Kit and pydantic. It evolved and has been intensely developed over the past year+ and is now a sophisticated and powerful API framework with a vibrant community and several (currently 4) maintainers.

Note regarding the name: The framework is called Starlite to show the relation to Starlette. This was important to me when starting this project, although to be honest Starlite now uses Starlette only in several select places and is almost completely distinct.

With this part out of the way - lemme give some updates:

1. We implemented a new on_app_init hook that allow plugins to set all elements of application configuration (more on this lower).

2. Building on the point above, we updated the SQLAlchemyPlugin to now support creating a DB connection and injection sessions using dependency injection. This is completely optional, but it also allows using Starlite with SQLAlchemy as an

/r/Python
https://redd.it/y2w6fl
Instructor split us into teams to turn a percentage into a letter grade "using as few lines of code as possible"; here is the monstrosity our team came up with.

Had to share this because I thought it was funny; I'm currently in a programming 101 course at my university, and the challenge given today was to write a program which can turn an input percentage into a standard letter grade. He only specified "in as few lines as possible". Not sure if it is PEP compliant... any feedback?

grade = "A+" if (percentage := float(input("Enter the percentage grade: "))) >= 100 else "F"
if 60 <= percentage < 100: grade = chr(-int(percentage // 10) + 74) + '-', '', '+'((final_digit := int(percentage % 10)) >= 4) + (final_digit >= 7)
print(f"Your letter grade is {grade}!")

/r/Python
https://redd.it/y3dzhu
Having issues with flask behind httpd proxy

I'm unable to successfully pass static files from flask through httpd without having to have the root "/" proxies to my flask server which isn't an option as I have to proxy that elsewhere.

/r/flask
https://redd.it/y3hjl9
Let's assume I am making a web app that will be used in the real world outside of development. Is the admin page still meant to be used?

Imagine I have an e-commerce store and on the admin page I want to have graph displaying sales.

Is using the admin page for this kind of stuff the correct way or is the right way to do it different?

/r/django
https://redd.it/y3bfm9
Do you really need callback routes in flask?

Hi everyone, I recently started working on a new project that uses Flask for the backend. For this project, we need to interact with an external service(Netsuite): unfortunately, the calls to this service can take up to a couple of seconds to complete, and the external service seems to handle just a couple of requests in parallel. So we decided to implement a queue with redis(through the use of python rq) in order to limit the number of requests made to the external service. The problem is that we use this queue for almost every endpoint of the API: from my understanding(I'm kind of new to python and flask) since the jobs enqueued take a while to be processed, we are considering having a separate call for every endpoint(doubling, in fact, the number of total endpoints) in order to check on the status of the job. Is it really the only way to handle this type of situation in Flask?

I come from node.js, and there we use promises to handle asynchronous calls without blocking the server, but from some examples I've found online, that doesn't seem to be the preferred way of doing things in python. What would be the

/r/flask
https://redd.it/y3qf9r
Jupyter Notebook competition - 2 weeks left to enter!



Are you passionate about \#coding, \#DataScience or \#EarthObservation? 📷

Don't miss out on the chance to showcase your skills and develop new Jupyter Notebooks using \#Copernicus data, whilst also being in with a chance of winning cash 📷 prizes!

Sign up before 31 July at: https://notebook.wekeo.eu/

https://preview.redd.it/ddy750xg4bb91.png?width=1920&format=png&auto=webp&s=ac315546d7fa35fd8a99e1c834ef0d3aea3c877f

/r/JupyterNotebooks
https://redd.it/vxzbw3
Cloning a Django project from Git how to set up the environment

I just cloned a Django project from Github and I want to know how to set-up the project to run in my Pycharm IDE. Do I have to create a new venv? And how to download all of the external libraries in the Github project with PyCharm?

&#x200B;

Basically, I want to set it up to a point where I can run it.

/r/djangolearning
https://redd.it/y3vkmd
Moving from wsgi gunicorn to asgi gunicorn with uvicorn workers doubled my average response time in Django 4. Is this normal?

Basically, I'm wondering if this is par-for-the-course or if instead I have issues with my codebase that cause it to be slow when moving to `asgi`. What are other people's experience here? Did anyone get a speed up.

/r/django
https://redd.it/y3r8o7
I want your opinion on the e-commerce API I designed using DRF(still working on it)

I initially got this as a job assessment. To build an ecommerce API I couldn't meet up with the deadline so I decided to finish it and just add it to my GitHub repo as part of my projects. I've been working on this since last months. I want to know what you think about this and how to make it better. I'm currently working on addjng jwt authentication and swagger docs etc.


Repo: https://github.com/Klvxn/ecommerce-API

/r/djangolearning
https://redd.it/y43eme
auto reload browser when editing templates/css

Hi,
when editing .html templates, manually reloading the page (F5) is required to see the changes. This is absolutely annoying and I want this to happen automatically. Everytime I edit a .html template or my .css files, I want the browser window to refresh automatically and show the changes immediately.

I came across livereload and "implemented" it as described in the docs. But I'm using the factory pattern so its not completely clear to me if I did it right:

def create_app()
app = Flask(__name__)
...
from livereload import Server
server = Server(app.wsgi_app)
server.serve(host='127.0.0.1', port=5000)

return app


I run it with flask --debug run. It works as far as it reloads the webpage when editing templates. Nice! But its far from perfect:
- In the terminal I see only the output from livereload, but not the output from Flask.
- When editing .py files, Flask reloads the app and the livereload server crashes with RuntimeError: Cannot close a running event loop

While this is an 'okay solution' when working only on html/css files, it is basically unusable when also editing .py files.

Is there a way to integrate this better,

/r/flask
https://redd.it/y41bnw
calling all python users to respond to the 2022 Python Devs Survey!

The 2022 survey is now open: https://surveys.jetbrains.com/s3/c1-python-developers-survey-2022
The survey is run by JetBrains for the PSF, and getting responses from a wide range of users is very helpful for knowing who is using Python and how, and what is helpful to you:)

They're also offering a $100 gift card giveaway for responding.

/r/Python
https://redd.it/y43gag
P Easy finetuning diffusion models

Hello the community,

Since the release of diffusion models we saw many posts on that.

The one made by Lambdalabs was very interesting and fun.


However I found it personally difficult to finetune on my own data. This is why I created a repository that simplifies a bit the process https://github.com/YaYaB/finetune-diffusion.

It breaks down into several steps:
- Dataset creation and how to actually create a dataset using HuggingFace's datasets library
- Captioning if you do not have any using BLIP similarly to lambdalabs
- Finetuning based on a script released by HuggingFace on their diffusers repository


I've added a few functionalities in the whole process:
- Simplify the captioning and dataset creation in a few scripts
- Finetuning can be done on a local dataset (if you do not want or can not share your dataset on HuggingFace Hub)
- Validation prompts can be set at every epoch (to verify when the model begins to overfit)
- Model can be uploaded to HuggingFace hub every X epochs
- A script to test your model locally has been added
- A dataset card template is available
- A space app can be copied an modified


In the Results section of the README you'll find some examples of prompts based on a model finetuned on One Piece

/r/MachineLearning
https://redd.it/y3usrj
Behavior-driven development (BDD)

Hi guys I’m looking for some differences between Cucumber, FitNesse and TestLink. Since I want to determine with which tool I should work.
What make the one of them the best tool to use for test automation?

/r/django
https://redd.it/y47ynu
Saturday Daily Thread: Resource Request and Sharing! Daily Thread

Found a neat resource related to Python over the past week? Looking for a resource to explain a certain topic?

Use this thread to chat about and share Python resources!

/r/Python
https://redd.it/y4981u