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
How often do you guys use Lambda?

I'm just curious as if it's really necessary and if I should learn it. Thank you for your time!

/r/Python
https://redd.it/10ey6cw
stacked quantiles

This is going to be niche, but just in case. I use this code a lot, so I uploaded it. For those of us who work with pixels and such where you might have 10k of the same value.

stacked-quantile · PyPI

ShayHill/stacked\_quantile: Treat weighted values as multiple values. (github.com)

​ 'Stacked' quantile functions. Close to weighted quantile functions.

These functions are used to calculate quantiles of a set of values, where each value has a weight. The typical process for calculating a weighted quantile is to create a CDF from the weights, then interpolate the values to find the quantile.

These functions, however, treat weighted values (given integer weights) exactly as multiple values.

So, values (1, 2, 3) with weights (4, 5, 6) will be treated as

(1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3) If the quantile falls exactly between two values, the non-weighted average of the two values is returned. This is consistent with the "weights as occurrences" interpretation. Strips all zero-weight values, so these will never be included in such averages.

If using non-integer weights, the results will be as if some scalar were applied to make all weights into integers.

This "weights as occurrences" interpretation has

/r/Python
https://redd.it/10ew7am
Secret messages in coding?

Is it possible to make short secret that only could be read when ran or by other programmers? I’m new to python, and I want to make a album cover that could hold a hidden text or something of the sort in a small bit of code. Just an idea I’m throwing around

/r/Python
https://redd.it/10eso5l
Delivery driver tip tracker: tkinter and openpyxl

Greetings, im current a delivery driver for a pizza chain and I wanted a way to track my tips, so I created a gui interface that allows me to input data and add it to an excel sheet, im really happy with this project as not only didnt I create it, I was able to recreate it in an object oriented way, if you have any criticism or anything I can improve on let me know!

youtube video on the project

github of the code

/r/Python
https://redd.it/10fb96m
A heavily tested (2k lines) and commented classic Red Black Tree implementation in Python and Ruby. Great for learning the material.

Back when I was trying to implement the structure, I could not find any open source implementations that were well written and commented.
I did not manage to find any implementation that had any significant amount of tests and as such was not sure if it even worked correctly.
I tried my best to describe the different operations needed thoroughly and have written a lot of tests (functional too) covering all operations, with drawn out trees in comments.

https://github.com/stanislavkozlovski/Red-Black-Tree

Any feedback is greatly appreciated :)

/r/Python
https://redd.it/10fev4r
Using Gaussian Elimination instead of a Monte Carlo simulation?

Using Python or R (or another program), let’s say I have two CSV sheets. One has a sample and the other is a reference sheet ( illustrated here: https://i.imgur.com/duNFu3w.jpg <-Sample

https://i.imgur.com/Ar9lO9Y.jpg <- Reference ). The sample is represented by numbers under element categories (Iron, Copper etc).

I want to get the sample classified in terms of percentages of the reference sheet categories. The output would be something like this for example: sample is “ 71% Category15, 8% Category9, 21% Category6. “

I have an existing Monte Carlo simulation in R and the process is slow and doesn’t yield results that are too accurate.
What alternatives exist to using a Monte Carlo simulation on this?


An existing Monte Carlo simulation would run combinations of the categories in the reference sheet to reach a combination similar to that in the Sample, so preferably the alternative would have a computationally similar output.

—— —— —— —— ——- —— —— ——- ——- ———- —-

I posted the question in another forum and received the following reply. Can someone give their opinion in terms of accuracy? (ie: do you think it will work given the problem above?)


“ Unless I didn't understand the problem at hand, linear algebra could

/r/Python
https://redd.it/10fckk2
What's your favourite thing about automated tests?

Hi there. I'm curious about how developers feel about writing automated tests like unit tests. What's the one thing you like, or have found helpful, about writing automated tests like unit test?

/r/Python
https://redd.it/10f935p
Can Flask Simply Run My Python Code?

Hi all,

I have a fairly simple python script (its a single class, about 200 lines) that helps me do my job and I want to share with members of my team and am unsure the best way to do this.

Some (important?) details:

1. The program does have a few user inputs and will return a single word/number (based on the inputs)
2. The other members of my team are NOT technical users - I would not trust them with having to install python or running anything from the terminal or an IDE.
3. security is not any security concerns here - anyone can see the source code (but am curious if you are able to see source code in flask)

I'm fairly proficient in python, but have never wanted to share a program with someone who's unable to run a .py file. I think a web app might be the best way to allow the non-technical users to access the program, but am unsure what might be the simplest way to create that? Currently I run the program in my terminal if that helps.

Would this be a good use case for Flask? Most tutorials I see online for flask seem to be blogs

/r/flask
https://redd.it/10fftz3
AMA: Ask me how I built amigoingonholiday.co.uk - Friday 20th Jan. at 18:00 GMT

Hi everyone,

I'm Dom (aka: u/SecondaryPath), the author of https://amigoingonholiday.co.uk. I'm hosting an AMA with members of the r/Flask community this Friday (20th Jan. 2023) at 18:00 GMT.

Feel free to ask me questions on how I built this Flask application, as well as anything else Flask/Python/Web Dev related!

YouTube live link: https://www.youtube.com/watch?v=4eCHYvcbAhg

/r/flask
https://redd.it/10fe89u
how can I redirect to another page from an html template in flask

I have a template where I have a back button as follows:

<div class="ui basic segment center aligned">

<i class="link arrow circle left big icon" onclick="handleBackButton()"></i>

</div>

At the moment, this handler just calls some dummy JS method but what I would like to do is redirect to the `index` page on flask. I know from the python code, I can call something like:

render_template("index.html")

or

redirect(url_for("index"))

I wonder if I can do the same from the HTML side of things. I could find many examples of doing this from the python side but nothing from the template side.

/r/flask
https://redd.it/10fejrp
I'm creating an app based on Flask, Zappa, Plotly/Dash and AWS Lambda. Do you have any examples/templates/python codes of apps built on Flask? The idea is create a simple one-page website with a sign up/sign in section and an app based on a csv file stored in s3 (It will be displayed through Dash).



/r/flask
https://redd.it/10f4g33
Flask-sqlalchemy

Is it better to have quite a lot of small tables in a database or fewer, much larger, tables?

I am currently making an app that is data intensive and I can’t decide whether to split out tables as much as possible to make it simple or to keep the data together in 1 table.

I think smaller tables would be better as it won’t take as long to query them (not that I’ll have millions of rows, so that probably isn’t a factor).

Please let me know what you think.

P.s. I’m currently using sqlite3 if that’s relevant

/r/flask
https://redd.it/10bt9n8
Help with a good Jinja Extension?

I'm just starting to learn Flask and working in VSCode. I tried using better Jinja, but when it only works when I set the language mode to Jinja-HTML. But when I do that, VSCode treats HTML as just plain text, and the language mode is HTML it treats Jinja as just plain text. Is there a way for it to handle properly handle both at the same time? The videos I'm watching seems to do exactly what I'm looking for, but of course the instructor makes no mention of it.

/r/flask
https://redd.it/10bvy4u
Thursday Daily Thread: Python Careers, Courses, and Furthering Education!

Discussion of using Python in a professional environment, getting jobs in Python as well as ask questions about courses to further your python education!

This thread is not for recruitment, please see r/PythonJobs or the thread in the sidebar for that.

/r/Python
https://redd.it/10fmmy9
Best python tutorials, codecamps, courses for begginers in 2023?

I am extremely interested in learning how to code and get a job in tech. After watching many videos on coding for begginers I have come to the conclusion to start with python as that is what 99% of everyone says to start as a first language. Therefore, I was wondering what the best tutorials, codecamps and courses (preferably free but I am willing to pay if its below £250) there are to learn as fast and efficient as possible as a begginer who has little to no experience coding and wants a job in tech. Also, if people can reccomend any good youtube channels or websites/blogs or email newsletters that would be amazing!

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