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
Use Python to Build a free Stable Diffusion app (with a GPU backend)

Hey everyone!

I wrote a tutorial on **using Python to build a free Stable Diffusion web app**. The app uses free Colab GPUs to power Stable Diffusion so you can access it for free in your browser!

You'll learn:

1. How to a basic web app using Python (and a little HTML and CSS)
2. How to expose Colab GPUs for use through ngrok

The app itself is very barebones, but I can build a more thorough React app if there is some interest! I mostly just wanted to highlight the working principles/mechanics of how someone would go about doing this so that you don't have to pay to use Stable Diffusion! Not a production solution, but great for hobbyists and people learning :)

Let me know what you think!

​

https://preview.redd.it/6l2n1d0eu0da1.png?width=1055&format=png&auto=webp&v=enabled&s=e0cc74ab76068d414c5fce12a3a37f6f7fe43268

/r/Python
https://redd.it/10g5nay
AmazonMe



Hello everyone,

I have been working on this scraping project to polish my scraping skills and wanted to share it with this awesome Python and web scraping community. It's an Amazon scraper that scrapes the product information according to the URL provided by the user. The scraper utilizes playwright automation to automate and extract the data. (Will add more functionalities)

The code is very beginner friendly and will help beginners to get their hands dirty on websites like Amazon. Your feedback is highly appreciated

/r/Python
https://redd.it/10gekp4
for example, I want to develop a whatsapp-like application for ios. is it possible to write the design and interface with swift and all the remaining codes with python?

I wanna learn it

/r/Python
https://redd.it/10gr2z6
Appending data to a file....

Hello,

I am trying to append data to a file that I am reading from in the path "01Resources/name.json", and this file contains the following data..

{"Name" : "Robert", "Gender" : "Male","age" :"23"}

{"Name" : "peter", "Gender" : "Male","age" :"24"}

{"Name" : "james", "Gender" : "Male","age" :"25"}

{"Name" : "janet", "Gender" : "Female","age" :"26"}

{"Name" : "mary", "Gender" : "Female","age" :"27"}

And here is my code..

####################
# 0. Data to be appended.
data = {"Name": "Roberta", "Gender": "FeMale","age":"35"}

####################
# 1/ read the the JSON data and append by writing new data in.

fdataOut1 = open('01Resources/name.json', "a")
data_strng = str(fdataOut1)
# the data must be string to write to a file
fdataOut1.write(data_strng)
#fdataOut1.write("This is test of appended data")
fdataOut1.close()


fdataIn1 = open('01Resources/name.json', "r")
data1 = fdataIn1.read()
print("")
print("####################")
print("Now the file has more content")
print("contents of whole input data file: " + data1)


fdataIn1.close()

When I run this code, I get the following in the file "01Resources/name.json"....

{"Name" : "Robert", "Gender" : "Male","age" :"23"}

{"Name" : "peter", "Gender" : "Male","age" :"24"}

{"Name" : "james", "Gender" : "Male","age" :"25"}

{"Name" : "janet", "Gender" : "Female","age" :"26"}

{"Name" : "mary", "Gender" : "Female","age" :"27"}<_io.TextIOWrapper name='01Resources/name.json' mode='a' encoding='UTF-8'>

&#x200B;

With Python, I am still "on my trainer wheels on my bike". and so how

/r/Python
https://redd.it/10gr475
I'm kinda noob in Portfolio's World

So I'm trying to get into portfolio's world and I made a website all by myself with Python and Django, if someone could help me with tips to improve, features that would be nice to implement on backend or just saying that is good already it would help much. Thank you :)

My Portfolio

/r/django
https://redd.it/10gsyez
Creating a database before starting django project

Is it possible to use an existing database in a django project or does the data base have to be created as part of making the django app?

&#x200B;

Thanks for your time.

/r/django
https://redd.it/10gspzs
How to code it is so that section 1 automatically links to discussion a. I'm using topic 1,2,3 to organize the discussions and the {%for post in page.get_parent%} in the template to make a navigation system. I want section 1 to always link to discussion a.

/r/django
https://redd.it/10gsn1x
Best way to load initial data and maintain it in production ?

We develop surveys for regulatory purposes and we expose them via an API (DRF).

Each survey has questions and we'll have different set of questions for each of our client (wording and number of questions can vary).

We are going live soon, and we haven't settled yet on how to initially load thatdata and how to maintain it (ie. wording may change over time, new question can be added, etc...).

Here's our feeling so far:

Fixtures: We use them extensively in our unit tests and our test environments but it doesn't feel right for production for several reasons:
No tracking of what has been run or what has not yet been run
Force us to deal with PKs
One fixtures can easily be forgotten
Migrations with raw SQL: idea would be to have a folder for each client with the different scripts to be run
Harder to generate and maintain (no loaddata / dumpdata)

What's your take on this ?

Thanks

/r/django
https://redd.it/10gcrw8
Aggregate posts from your Mastodon timeline (built with Django)

Hey all, I built https://fediview.com/ with Django. It surfaces posts from your Mastodon timeline with a very simple algorithm -- super useful to just "catch up" on posts you might have missed.

Hopefully it's useful if anyone is on Mastodon. I'd love to hear any feedback!

/r/django
https://redd.it/10glm2u
Jupyter + copilot

Anyone had success setting these two up together?

/r/JupyterNotebooks
https://redd.it/10gnx7k
How long will data be stored in RAM?

Since I use notebook as a demo for images and plots when I do data analysis, I often have my jupyternotebook on and leave it on for weeks incase I need to use/check certain notebooks ocassionally.

&#x200B;

In the jupyter notebook, there are often multiple cells, and there are some variables being stored and pass to the next cell. And my question is that, how long will the intermediate data be kept, and can I run the cell even after weeks and trust the output as long as there is no error reported?

&#x200B;

My guess is that if the RAM throws away certain groups of data, then I should not be able to run the cell since the intermediate data it needs is no longer available, which means, as long as it can run, the data is still there.

Also, I am using m1 Macbook, which I know will use the hard drive as RAM in certain cases, not sure if this means the intermediate data will be kept on some temporary files on the hard drive, which sounds to be a safer place to store.

/r/JupyterNotebooks
https://redd.it/10gjv8j
Parsing and validating pyproject.toml files with msgspec

The upcoming release of msgspec
(my fast & friendly
serialization library) adds builtin support for YAML & TOML formats, on top of
the existing JSON & msgpack support.

To demonstrate this, I wrote up a quick example of parsing and validating
pyproject.toml files using msgspec:

https://jcristharif.com/msgspec/examples/pyproject-toml.html

It applies the following standard msgspec workflow to the pyproject.toml file
format:

1. Define a schema using standard python type annotations. If you're already a
dataclasses/attrs/pydantic user this should feel pretty familiar. msgspec
supports a wide selection of common stdlib
types
. Any
additional needed types can also be added via an extension mechanism.

2. Pass that schema to one of the supported decode functions (here we're
using msgspec.toml.decode). The decoder will parse and validate that the
input data matches the schema. If it's valid the specified type is returned,
otherwise a user-friendly error message is raised detailing where the data
is malformed.


The same technique can be applied for any of the formats msgspec supports,
allowing msgspec to be a one-stop-shop for serialization & validation in
Python.

Note that unlike the existing JSON & msgpack support, these new formats rely on
external parser libraries (msgspec includes a fast, custom JSON parser). This
has a

/r/Python
https://redd.it/10gzbgo