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
Image processing in Python

Long story short, I am Computer Science with no Python experience yet (I code using C and Java), however I got offered by a Physicists to work in image processing with them, something which I have no prior knowledge about. Is it something one can pick up in not much time when someone has programming experience?

/r/Python
https://redd.it/goen4x
Safest way to store and display code blocks in html?

I have a flask backend, and I'd like to do something similar to Reddit or Stackoverflow in terms of styling and displaying code. The code and associated data would be stored in a DB, Flask would fetch it and insert it into the template.

Example

def example():
return "something like this"

How would I safely submit, store, and render code blocks?

/r/flask
https://redd.it/gogvig
Flask App - need help creating route for sql table data

Hi everyone,

I have a Flask app that pulls SQL data into a datatable working away nicely. It's intended for internal use in our warehouse. What I am trying to do is have a link attached to each item name that when clicked, opens a new table with the historical sales listed. I have this working if I manually pass in the name of the product into the SQL stored procedure but how can I get this passing in from clicking on the item in the table.My route looks like this -

\#@app.route('/prev-orders/<itemid>', methods=\['GET'\])

def previous\_orders(itemid):

cursor = cnxn.cursor()

cursor.execute(order\_history)

data = cursor.fetchall() <--this should be fetchone?

return render\_template('previous-orders.html', data=data)

&#x200B;

My href in the <a> tag is href="{url\_for('previous\_orders', itemid=ItemId)}"

Edit - I forgot to show the stored procedure for SQL -

exec Web\_ProductHistory 'APRONS ROLL WHT 2903 (2)' - again, I can manually change the parameter being passed but I need the value passed from clicking on the item name on the table.

Any help would be great and apologies if the question is phrased poorly.

Thank you!

/r/flask
https://redd.it/gogbxd
Front-end JS frameworks are an overkill for Django?

I wanted to learn Vue, so I started looking for examples of Vue projects to get some inspiration. However, most of what I find are re-implementing functionality already available in Django.

For example, adding routes is the same as adding urls, the templating system is relatively similar. So I started wondering where is the value of adding thigns like Vue or React to a Django App.

Do you have any examples of projects where front-end frameworks actually achieve something that couldn't have been done directly with Django templates? To mind, I can think only about Wagtail, which uses React (I think) to manage content.

For what I see, unless it is fairly complex user interaction there is no real gain in adding yet another framework. But I may be mistaken. Any examples or ideas to light up the discussion are always appreciated.

/r/django
https://redd.it/gof2g2
This media is not supported in your browser
VIEW IN TELEGRAM
Made a bot that sends the whole Bee Movie script via Whatsapp

/r/Python
https://redd.it/gok9dd
This media is not supported in your browser
VIEW IN TELEGRAM
A tool that copies a selected area of your screen, not as a picture, but as pastable text (GitHub in comments)

/r/Python
https://redd.it/goldxf
How to automatically activate virtualenvs

How to automatically activate virtualenvs or is there any easy to do it

/r/django
https://redd.it/gomkar
Partner for a Social Welfare Web App? (built on flask)

Hi guys,

I am a student with experience in Python, Flask, MySQL and HTML. I am currently in the process of building a web app to track general health information of impoverished children living in my area. This is a tech solution to an event that is ongoing (in jeopardy now due to Covid19 :( ) Privately message me for further details, or any other questions about this project!

/r/flask
https://redd.it/gojs1t
Advice on getting started with Channels, ultimately to be deployed to Heroku

Hello experts, I'm about to start a Django project where I will use Channels for the first time. Users will get views "pushed" to them as part of a market research activity (answering questions together as a group while on video chat etc).

I will be hosting on Heroku when it's live. I'm in the process of reading tutorials, walkthroughs etc and I have a couple of questions please.

Context:

* Installing channels is fine - **pip install channels**
* I know I need a backend and have no reason not to go with the standard Redis. But there are so many different ways I'm totally confused what to do:
* The [Channels tutorial](https://channels.readthedocs.io/en/latest/tutorial/part_1.html) recommends a docker install.
* [Redis themselves](https://redis.io/download#installation) use a wget procedure to build from source...
* [This](https://realpython.com/getting-started-with-django-channels/) realpython walkthrough recommends installing **asgi\_redis** and then **brew install redis**.
* [Heroku themselves](https://devcenter.heroku.com/articles/heroku-redis#connecting-in-python) take a different tack with **pip install redis** and **django-redis-cache**

To my questions:

1. Let's assume that I want a vanilla setup, because I'm new that this, and given that I will be deploying to Heroku, which goes through requirements.txt to install all the right packages, is the Heroku path the right way

/r/django
https://redd.it/goops8
My Python Youtube channel just hit 20,000 subscribers - buildwithpython

Hey guys,

About a 2 years ago, I started a YouTube channel because I wanted to learn python. Teaching is the best way to learn. Both the channel and I have come a long way.

I wanted to thank the Python community for being so awesome. Thank-you for sticking around.

If someone is curious about the channel - youtube.com/c/buildwithpython

Or you can just search for buildwithpython on YouTube.

Just wanted to share my happiness with the community :)

/r/Python
https://redd.it/gon77w
Connecting second site to digital ocean droplet

I am trying to connect a second domain to my server on a new port. I have connected the site successfully to the IP and port, but the domain still routes to the Apache 2 default page. Here are the 2 links:

[(raw IP and port)](http://161.35.7.202:81/)

[(where the site should be)](http://entredeveloperslab.com)

/r/flask
https://redd.it/gos6s4
Building a multiplayer chess game with Channels

Hey guys,

I've been learning django-channels lately and wanted to make a small project to understand how it works better so I thought about building a site where you can create a new game room and play chess with other people.

I've been researching the best way to build and structure my project but I have a few questions.

1. Let's say I have created a GameBoard model that represents the current state of the game, would it be a good idea to send that object over the websockets back and forth everytime the player makes a move, or clicks on a piece (to see possible moves) in order to update the board. Or should I implement some of the game logic inside the js code.
2. How do I go about rendering the game board inside the html, do I need to "redraw" the entire board everytime a change has been made? Could I use django templating here or just javascript to do this without refreshing the page.

I don't have any experience making web-games so please excuse me if anything is not understood.

Thanks in advance for any help.

/r/django
https://redd.it/gok688
Made a super basic role-requirement decorator for flask-login

I wanted to add an admin user-type to my flask app, in addition to the basic authorized user that flask-login provides. I didn't want to use flask-user or flask-security, which I understand have role-based authorization, because they require additional database tables. I wanted the bare minimum, where a User's role attribute is just a string. I just wanted the extra decorator, not anything else.

Here's the result. A single file, customizable route decorator for adding a required roll to a view.

[https://github.com/schwartz721/role\_required.git](https://github.com/schwartz721/role_required.git)

/r/flask
https://redd.it/gou2r6
Using face and hand tracking algos to detect when you touch your face (link in comments)
https://www.youtube.com/watch?v=W_OFo2MGLaM

/r/Python
https://redd.it/gp36c0
Fluxmath: multiplayer, competitive math game, made with Django
https://fluxmath.com

/r/django
https://redd.it/goyeu2
How would I approach to build a history change tracker for each of my orders? (Similar to this example pic)

/r/django
https://redd.it/gp1suf
FretBoardGtr - A package for creating svg guitar fretboard.

/r/Python
https://redd.it/gp6ey8
This media is not supported in your browser
VIEW IN TELEGRAM
I was tired of opening 100s of tabs for internship apps. So, I made an app to scrape and apply to every single job listing on Glassdoor with one click using Selenium! (source code and YT video linked below)

/r/Python
https://redd.it/gpaegj
How to have my API send data to just my front end?

Hey guys I am making a flask API using flask-restful. At this point anyone can call my endpoints and get data, but since its a user/pw application on the front end, I think building a token system would just be a waste if I just use it for a frontend/mobile in the future.

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