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
Earn arcade style Achievements while coding!

I made a package that analyzes your python script and gives you achievements based on different coding concepts you use (example in image down below). Just import the package at the top, and use your functions, loops, etc. and run it as you normally would!

https://preview.redd.it/lb594popgkf61.png?width=625&format=png&auto=webp&s=bc4a213bcdd2fc4b45aad4106878ddbb97dccfd7

Achievements have dependencies, so some need to be unlocked before others, and are persistent, so you don't need to cram them all in at once. A handful of basic concepts are implemented (from printing "hello world" up to classes and objects), and plenty more to come!

Github Link: https://github.com/raviolliii/dev-achievements

PyPi Link: https://pypi.org/project/dev-achievements/

/r/Python
https://redd.it/lcwqlf
Inspired by Computerphile's latest video, I wrote a short script to display your computer network geographically.

​

Github: https:\/\/github.com\/2435191\/TracerouteVisualization

/r/Python
https://redd.it/lcwrv4
How to use Flask-Migrate and Zappa?

I've got an Aurora DB on AWS with Flask-SQLAlchemy. Locally, I can use the convenient Flask-Migrate to run database migrations, but 'live' this is more challenging since Zappa converts Flask into lambda functions and it seems once its on Lambda, its no longer really 'flask' so I can't run Flask db migrate etc.

What have people done to handle SQL migrations with a setup like this?

EDIT:At the bottom of the Flask-Migrate documentation, it shows how the commands can be invoked directly. On the Zappa documentation, it shows how to invoke a command stored on your application. To make this work, I made a script at the top level called `commands.py` and imported from flask_migrate the functions I needed.

I can then invoke zappa invoke dev commands.migrate

/r/flask
https://redd.it/lczgmp
D Anyone else find themselves rolling their eyes at a lot of mainstream articles that talk about “AI”?

I’m not talking about papers, or articles from more scientific publications, but mainstream stuff that gets published on the BBC, CNN, etc. Stuff that makes it to Reddit front pages.

There’s so much misinformation out there, it’s honestly nauseating. AI is doom and gloom nonsense ranging from racist AIs to the extinction of human kind.

I just wish people would understand that we are so incomprehensibly far away from a true, thinking machine. The stuff we have now that is called “ai” are just fancy classification/regression models that rely on huge amounts of data to train. The applications are awesome, no doubt, but ultimately AI in its current state is just another tool in the belt of a researcher/engineer. AI itself is neither good, or bad, in the same way that a chainsaw is neither good or bad. It’s just another tool.

Tldr: I rant about the misinformation regarding AI in its current state.

/r/MachineLearning
https://redd.it/lcuq4b
I created a series in Python that takes you through every detail step-by-step (code included) on how to create your own algorithmic trading bot that trades the financial and crypto markets for free.

# How to create an algorithmic trading bot with Python

​

1. Overview \- An overview of the project.
2. Design \- Requirements and how the trader operates.
3. Getting financial data into Python \- Pulling financial data into Python from MetaTrader5.
4. Open a trade using the MT5 API with Python \- How to open a trade programmatically via MetaTrader 5.
5. Close a trade with MT5 using Python \- How to close an open trade with MetaTrader 5.
6. Creating an algotrader/trading bot with Python – Part 1 \- Creating the trading bot loop and opening trades with an entry strategy.
7. Creating an algotrader/trading bot with Python – Part 2 \- Implementing a strategy reader.
8. Creating an algotrader/trading bot with Python – Part 3 \- Closing a trade with an exit strategy.
9. Creating a strategy for your algorithmic trading bot – Part 1 \- Creating a dynamic strategy with JSON for trading part 1.
10. Creating a strategy for your algorithmic trading bot – Part 2 \- Creating a dynamic strategy with JSON for trading part 2.
11. Dynamically calculate lot size for your algorithmic trading bot \- Dynamically calculate your position size based on account size and risk.
12. Send messages from Python to Slack \- Sending

/r/Python
https://redd.it/ld81ic
Simple word-replacer script

Hi guys new to python and i made this simple script. Any advice regarding code quality and other stuff will be highly appreciated.


https://github.com/ginop-1/word-replacer

/r/Python
https://redd.it/ld5hfp
Any interesting open projects to join? Or anyone want with some good ideas want to start one?

Edit - making a virtual assistant. Anyone wanting to contribute dm:)

/r/Python
https://redd.it/ld82ds
Creating an RPG Character Builder

By popular demand from last weeks event, today I'm going to step into a realm of Python that I'm not comfortable with \~ classes. I never need to build classes in my daily life so tonight for the code along challenge I'm going to attempt to build an RPG Character Creator using classes and make the characters fight each other to the death. So in order to prepare for this I've spent the week thinking about different approaches and training relentlessly. . .

​

Training Python in the Gym

Thinking about Python while training with Cat

​

If you're interested in learning about classes, python, ask questions, hanging out with nerds, or want to come help me figure my way through this code - Join the code along and hang out with us tonight or join us in discord! We have a few folks who have been working with python daily for years and are throwing ourselves out there to help python noobies or be there for people while they learn on their own.

​

Discord for casual Python shenanigans: Minimoose Lodge

Stream for the funzies: M1N1M00SE (Tonight at 6PM EST)

/r/Python
https://redd.it/ldfaka
Nginx for static HTML?

Hey guys! I'm relatively new to server-side rendering and all the best practices, so I have a question surrounding static content.

Assuming I'm working on a Flask app with some server-side rendered content, if I have a page that requires no templating or server-side rendering, should I defer from Flask and opt for a CDN or Nginx for serving that content?

My login page, for instance, is completely static, so I'm not sure if I should be serving it from Flask.

I'm sure it would be more performant, but I'm unclear as to the best way to separate routing for Flask -served pages and the static pages. I'm sure a reverse proxy could do this, but adding configuration for static sites at this level seems arduous. Is this common? And it's just a matter of configuring proxy routing for each of the static pages? Or is this overkill, and I should just render the static HTML, given that all the other pages will be server-rendered anyway.

Also, even if Flask still serves the login page, I assume all JS and CSS would ideally be served from something more suited for static content? This one seems easier to configure.

I should mention that I'm thinking in

/r/flask
https://redd.it/ldlwn6
P Sense: Open Source Framework for Video Understanding & Action Recognition with Deep Learning

Very happy to share with the community the news that the team I work for recently released an inference engine called sense that enables developers to use RGB camera input to predict human actions. No pose estimation, no skeleton tracking, just end-to-end deep learning.

We strive to make it the all-in-one toolkit to collect and clean video data, train powerful and efficient video classifiers, and deploy to any device (with iOS and Android support).

The inference engine is accompanied by our pre-trained weights that individuals can download for free. The models are small, efficient, and run smoothly on CPUs. With the pre-trained weights, our stack supports demos such as gesture recognition, fitness tracking, fitness repetition counter and calorie counting out of the box.

You can perform transfer learning on the weights to train your own video classifier and customize the model to your use cases.

Feel free to give it a try, open an issue, give us feedback! We want to make it more fun and exciting for you to use 👉 https://github.com/TwentyBN/sense

/r/MachineLearning
https://redd.it/ld8yjz
Any good tutorials on pairing Vue with Django?

Ive been using Bootstrap and straightforward HTML files to make everything work but I wanted to start using JS and work with more languages/frameworks. I'm a little confused on how to have django interact with Vue since not only does the framework use HTMLs, but apps/components too. Im still new to Vue frankly so Im not expecting to pop out a beautifully made UI out my ass but I hope I can learn enough from a good tutorial. Thanks for any tips.

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

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/ldkzyi
New to Django, Need help accessing python manage.py runserver

Hey all,

I just started to learn Django to help build a portfolio that I wish to build. However, as I go through the steps in this website, I run into a bit of a problem that I am not sure how to address. I have managed to make a virtual environment though when trying to run

python manage.py runserver

in the cmd prompt, I am getting an error suggesting that it can't open the file, and there is no such file or directory. I believe I am running Python as an administrator but I can check again if that matters. Below is a picture of what I am getting. If anyone here could lend a hand that would be great!

https://preview.redd.it/cm5kslglzpf61.png?width=1920&format=png&auto=webp&s=7d2a6c92713ee820cb1e7d97f31c96edad108bd0

/r/djangolearning
https://redd.it/ldgnh5
P Building an End-to-End Machine Learning Application From Idea to Deployment

Hey all,

A lot of beginner tutorials out there for using machine learning don't really go beyond copy-pasting some sample code off the Tensorflow website and running it through an overused benchmark dataset.

So I thought I would describe a viable sequence for carrying a machine learning product through a more realistic lifecycle from initial idea to a deployed solution.

The domain is fake news detection and in a series of blog posts I describe:

\- project setup

\- exploratory data analysis

\- building a training/evaluation pipeline

\- error analysis

\- deploying a server and creating a Chrome extension for browser-side interaction

\- building a continuous integration/deployment solution.

Here's the first post in the series and source code. Hope you find it helpful!

/r/MachineLearning
https://redd.it/lds3z1
I've made a really good webcam-based 3x3x3 rubik's cube solver program

TL;DR: here's the project: https://github.com/kkoomen/qbr

The idea came after many years of me solving rubik's cubes in combination with my programming knowledge. I did want to make a program so that even my friends could solve a rubik's cube without knowing anything about it. Hence that I've also added a humanized-notation where all the rubik's cube notation gets converted into humanized sentences such as:

1. Turn the back side 180 degrees.
2. Turn the top layer 180 degrees.
3. Turn the front side a quarter turn to the left.
4. Turn the right side a quarter turn away from you.
...


I've started this project almost 6 years ago when I was still studying and got a decent-working version, but the color detection only worked for my room and my lightning setup. Many things were hard for me since I was still studying programming.

After roughly 6 years (and working professionally for already 6+ years), I got a nice suggestion from someone else on one of my issues on how to improve the color detection using LAB colors + the CIEDE2000 color-distance algorithm. This worked insanely good and got my really accurate results (assuming a room had regular lighting). Due to my knowledge I've built up in the

/r/Python
https://redd.it/ldx3ii
How do you add reactivity to Django templates?

I want to add some reactivity to my website, but I don't want to go the full SPA route. Moreover, I believe Django already does a great work at rendering templates, routing views, etc. So why adding more complications?

I looked into Svelte, but couldn't figure out how to combine it with Django templates, especially in cases where Svelte should display context information from the Django app.

The best I could gather was that Vue, for instance, can combine its own template tags and django tags. Perhaps React can do the same, but must check.

So I wonder, if you want to add some reactivity to the website, what route do you follow? Is there a way of integrating instead of splitting (i.e. instead of making your django app serve an API and your frontend consume it, etc.) that you think is worth exploring?

/r/django
https://redd.it/lduj9l
Moving up from sqlite

I am running a flask web app which requires a lot of database activity. At the moment I am getting around 250,000 database writes and 300,000 database queries a day.

It’s growing fast (20% a day at the moment, with potential for big spikes) and I’m worried that the current setup I have (local SQLite database) will start to creak soon. (I’ve read that 100k a day is the recommended limit).

Questions for you:

- When does SQLite actually start to struggle in a flask setup? What will happen when it does? Performance slowdown or massive explosion with data loss?

- Where is the natural place to graduate to? MySQL? Postgres? Ideally I would like something which requires the absolute minimum of code changes vs the current sqlalchemy/SQLite setup I have. I know zero about database admin/setup.

- How should I think about running the DB server? Run it locally? Cloud? Database access needs to be super quick and intuitively I’m worried that running in the cloud will introduce additional delay - but maybe I’m worried about nothing.

/r/flask
https://redd.it/ldvner