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
Saturday Daily Thread: Share your resources!

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/ktfa01
Heroku deployment



Hi guys so i tried to deploy on heroku and it didn't work so I tried again and this time i used the "heroku create [name\] to create another app. And then ran git push heroku master after commiting changes but the error i got was

( ! [remote rejected\] master -> master (pre-receive hook declined)

error: failed to push some refs to 'old appname'.

So I wanted to know why it pushed to the old one and not the new one and how to fix it

Also another different question, do you guys have two settings like "local_settings.py and settings.py" or only one.

/r/django
https://redd.it/ktf7t0
Confusion regarding django channels

I recently is thinking about making asynchronous apps , I know about django channels but I feel they are not production ready.I have not known any company use django channels.What are your opinions about django channels?

/r/django
https://redd.it/ktimi5
How do you bind a file (not uploaded but internally generated) to a model's FileField after the model has been saved?

I have a model that takes, among other fields, a video as a `models.FileField()`, two text files as `models.FileField()` and an image as a `models.ImageField()`. Now, of these four fields, only the video and one text file are uploaded by the user, the other text file and the image are generated internally and—I think, so far—need to be bound to model fields. The image needs to be displayed in a page and the text file will be available for download. I still don't know how to offer this download, but I'm trying to have it as a model field.

Something like this ([`models.py`](https://models.py)):

class Project(models.Model):
project_name = models.CharField(unique=True, max_length=80)
video_file = models.FileField(upload_to=user_directory_path)
original_text_file = models.FileField(
blank=True,
upload_to=user_directory_path
)
generated_text_file = models.FileField(blank=True)
# This image is generated with

/r/django
https://redd.it/ktk9iq
Good Django libraries to read to really understand class-based views?

Are there any Django libraries that make extensive use of class-based views that I might study if I want to gain an in-depth understanding of how to use them? The Django documentation is OK at explaining what they are and how they work but most of the examples are very trivial in nature. I'd like to become a "power user" and for that I need lots of code to study. I've looked at the Classy Class-Based Views examples but they seem too "meta" to me to shed any real light on how to use them in practice. Thanks.

/r/djangolearning
https://redd.it/ktbx5i
I automated a full time full before it could be advertised

Thought this was funny. I work as an Accountant and last week my Manager let me know that due to a Government audit we would be required to fully itemise our government funding client statements.

The problem is that our client statement involve charges from third party companies who are paid from this government funding and all these invoices are held on a third party website.

The third party website said they couldn't help and it was determined that due to how slow the website is as well as other factors (the invoices are all listed as individual download links, some invoices are password protected pdf's, some are jpg's, the website layout is terrible) that it would require 160-180 hours of manual work and therefore a new admin person would need to be hired.

So I wrote something in Python that opens a headless browser, grabs all client names, then goes through each clients account and downloads every invoice, skips any client with no invoices, converts all jpg's to pdf's and resizes them so they fit correctly on the page and merges all invoices into one file per client to form our new statement file.

It takes about about an hour to

/r/Python
https://redd.it/ktj4jq
Application data flow between browser, Nuxt and Django for simple CRUD app with session authentication (repo, article & diagram in comments)

/r/django
https://redd.it/kts9xw
This media is not supported in your browser
VIEW IN TELEGRAM
[P] [D] ML algorithm that can morph any two images without reference points.

https://redd.it/ktnwcv
@pythondaily
Sunday Daily Thread: What's everyone working on this week?

Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.

/r/Python
https://redd.it/ku2q3e
As a thank you to the community, here is my new book: Slither into Data Structures and Algorithms

Hi everyone!

A couple of years ago I released "Slither into Python" for free online which was an introduction to Python for complete beginners. I released it for free as a thank you to the Python community in general. You can view that here.

The feedback was amazing (thank you all, I'm delighted you enjoyed it!). It inspired me to write another book that I felt was the natural extension to it - focusing on data structures and algorithms. In fact, I had a lot of requests for it after the last two chapters of that book so that inspired me even more to write this.

I had started on it a while back but work became super busy and last year happened so I kind of forgot about it. However I recently came across the files and decided to pick it back up.

It's now complete: "Slither into Data Structures and Algorithms: A concise guide to the backbone of the digital world through Python" and you can check it out here: slitherintoalgorithms.com.

The chapter on Graphs is up and free to read on the site! Again, I'd like to thank everyone on this subreddit that gave such amazing feedback and improvements for my last

/r/Python
https://redd.it/ku09n3
D Color coding equations

I've seen this done in a few places and wanted to give it a try - where you color code parts of mathematical equations so that it's easier to follow them around, or to group them.

At a glance it seems easier to follow around and see some relationships. Wonder whether it can be a distraction when reading the text. What are your opinions on it?

Example: (screenshot from https://lab-ml.com/labml\_nn/transformers/relative\_mha.html)

https://preview.redd.it/ir7zouvns8a61.png?width=1062&format=png&auto=webp&s=c603bb1681a83efbbbacf382ccf8e511c51efafb

/r/MachineLearning
https://redd.it/ktkuay
Sane: Makefile for Humans

Despite being a great and flexible tool (proof of which is how long it's been around for!), I've always been a little frustrated by Make in two aspects:

1. How cumbersome and opaque the grammar of Make is ($* $< $@?!)
2. How hard it is to keep state (which usually ends up in having a recipe be a single long bash line with a lot of \s --- and that's ugly and hard to read.)

`Sane` (`sane-build` in PyPI) is an attempt to create an alternative that incorporates the ideas of Make, but provides the full flexibility of Python in terms of writing logic.

From the project's README:

> - Recipes are python functions with recipe/file/hook dependencies.
> - If a recipe A depends on recipe B, recipe B is checked. If B is ran, then A is ran afterwards.
> - Recipes are ran if its dependency files are newer than its target files (or if either cannot be found).
> - Recipes with no dependencies are always ran.
> - Hooks are a way to tag dependencies. Recipes depending on a hook depend on all recipes with that hook.
> - Everything else is standard Python.

Like its name indicates, sane tries to be as uncomplicated as possible

/r/Python
https://redd.it/ktxk80
A list of tutorials for beginners

I have been working on a series of videos to show the basics of Python Programming to beginners. If you are new to the language, programming in general, or would like a quick reference to some basic concepts, this will hopefully be a good resource for you!

[Introduction](https://youtu.be/eJt-leDZqls)
Creating, Using, and Manipulating Variables
[Working with Arrays and Dictionaries](https://youtu.be/BsgfRXaVTik)
Controlling Program Flow with Loops
[Recycling Code with Functions](https://youtu.be/Dwkb2rcoT2U)
Creating Abstract Objects through Classes
[Relating Objects to One Another with Inheritance](https://youtu.be/POkIYB1vlcA)
Replacing Parent Methods by Overriding Functions
[Utilizing Static and Class Variables](https://youtu.be/u55vEYcMWko)
Creating Virtual Environments

The tutorials follow a long-term series where I build bigger projects, so the list will grow over time. I would love to hear suggestions for more videos to make!

/r/Python
https://redd.it/ktqnce
How to use Billplz secret key for FPX payment in Flask



Hi there good day, I am new to payment gateway and would like to integrate it with Flask. I am currently using Billplz as my FPX payment gateway. I do not have any examples on using Billplz with flask and hence I am stuck at here currently. They have provided a secret key with a few API references on payment methods. Can I use to call the payment gateway like this http/API/secretkey/bank. Is my understanding wrong? Appreciate if can share any guidelines on how to setup payment gateway with only secret key.

This is their website by the way. https://www.billplz.com/api#introduction

/r/flask
https://redd.it/ku9nnc
I finally did something I feel was worth while

I work in the public health sector, an area with very bad technology debt. A lot of data is still on paper, scattered throughout spreadsheets, or somewhere else and deemed to exist so it's fine we don't need to track that. It's totally fine.

Well, I work in research and evaluation and for a very large grant, I needed to connect our student records to a federal database that tracks where they are out in the field once they have started medical residency and become established as doctors.

We only had names of students, and many python headaches later I ended up with a script to write all of the results for each API call to an Excel file, except I had to enter each first and last name manually.

We were going to make a graduate student do the manual entry of it all. It probably would've taken months. But then I realized I could just make a little script to do the entries instead.

It was very stitched together, and it almost certainly could have been more elegant, but it worked and only took a couple of days for it to go through all of it.

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