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
Testing without tests

I have seen many developers (mostly amateurs and intermediates) write code without tests. When asked about it, they say that they test their code locally, and therefore, dont feel the need to write tests separately.

Is this approach okay? Is TDD really important, or can you get away with simply testing code without writing tests?

/r/Python
https://redd.it/bezsyu
Flask, Vuejs, Celery, and MongoEngine project I've been working on

Though I would share my project I'm working on so others can use it as a template. Took me hours to get a module backend that worked well with Celery, Flask, MongoDB and Sockets.

Technologies:

* Flask
* Flask-Scoketio
* Flask-RESTful
* Flask-Login
* Eventlet
* Gunicorn
* Vuejs
* Celery
* MongoEngine
* Docker

​

[Link](https://github.com/jsbroks/coco-annotator)

/r/flask
https://redd.it/bf1212
Flask textbox fields?

Still very new to flask, so I'm sure there are probably some things that I could have done better/ didn't know you could do. Let me know if there's anything I should do for better practice.

​

I have a program that will take in a bunch of textbox inputs. After clicking a button, I want the result to be displayed. As of right now, the only thing I could really think of was:

form.result.label.text = result

However, that only changes the text box's label. Is there anyways I can have the result be posted into the textbox field? Or is there a label attribute I can use like a gui label? Thanks

#form.py
from flask_wtf import FlaskForm
from wtforms import StringField, IntegerField, SubmitField
from wtforms.validators import DataRequired

class information(FlaskForm):
studentName = StringField('Name', validators=[DataRequired()])
toeflScore = IntegerField('TOEFL', validators=[DataRequired()])
sopScore = IntegerField('SOP', validators=[DataRequired()])
lorScore = IntegerField('LOR', validators=[DataRequired()])


/r/flask
https://redd.it/bf47wz
[P] Python package to easily retrain OpenAI's GPT-2 text-generating model on new texts + Colaboratory Notebook to use it w/ GPU for free

Hi all! I just open-sourced a [Python package on GitHub](https://github.com/minimaxir/gpt-2-simple) that lets you retrain the smaller GPT-2 model on your own text with minimal code! (and without fussing around with the CLI like the original repo)

I have also made a [Colaboratory Notebook](https://colab.research.google.com/drive/1VLG8e7YSEwypxU-noRNhsv5dW4NfTGce) which handles both training w/ a GPU **for free** and file I/O to the notebook (which with GPT-2 is a tad tricker).

Let me know if you have any questions! I plan on releasing more demos soon!

/r/MachineLearning
https://redd.it/bf137p
Anyone hiring Django devs?



Hi, I'm Michael. I've been developing software and web applications for 7 years, proprietary (used by Fortune 500 companies, various colleges, and other clients) and open source.

I have experience in data analysis and visualization (pandas/numpy, highcharts/d3), (including geospatial analysis and visualization (Mapbox, leaflet, Highmaps, Google Maps)), and a bit of machine learning (scikit-learn, numpy).

I typically code in Python/Django, use a PostgreSQL or MySQL database, and use Javascript/Jquery for the front end, though I prefer backend development. I also use git, and I work on a Linux OS.

My latest project is https://datafix.io, which I created in about 150 hours, if you'd like to see some of my work. It's a service where users can either make dataset requests (request that a dataset is created/cleaned), with or without a reward, or make money creating/cleaning these datasets for other users. Please message me with your email for my resume.

Asking for $65k-$85k+ yearly. I am looking for remote, full-time work. I would love a backend role, but I can do full-stack as well

Best, Michael

/r/django
https://redd.it/bf2g7l
Expanding magics

How could I extend the Jupyter Redshift magic module to respond to a commands like %DESCRIBE DOMAIN member, which would then pull catalog info from a Data Calogue and present it to the user as SQL results?

/r/JupyterNotebooks
https://redd.it/bf7oax
Live Data Plotting with Matplotlib

Below is a program I am using to read and plot the value of a sensor (simply a potentiometer at the moment). I am using two DIGI XBEE Pro SX Modems to transceive the data. The majority of the code below is provided by DIGI. The program displays the value of the sensor on the screen but when the compiler reaches the plotting section it simply doesn't execute. There are no errors. I am using Python 3.8, jupyter notebook, and anaconda.

\#########################################################################

from digi.xbee.devices import XBeeDevice

from [digi.xbee.io](https://digi.xbee.io) import IOLine, IOMode

​

import matplotlib.pyplot as plt

import matplotlib.animation as animation

import time

import re

import csv

import serial

import datetime as dt

import math

%matplotlib notebook

​

​

\# TODO: Replace with the serial port where your local module is connected to.

PORT = "COM13"

\# TODO: Replace with the baud rate of your local module.

BAUD\_RATE = 9600

​

REMOTE\_NODE\_ID = "REMOTE"

​

IO\_SAMPLING\_RATE = 1 # 0.5 seconds.

IOLINE\_IN = IOLine.DIO3\_AD3

i=0

​

def main():



\#print(" +----------------------------------------------+")

\#print(" | XBee Python Library Handle IO Samples Sample |")

\#print(" +----------------------------------------------+\\n")

​

device = XBeeDevice(PORT, BAUD\_RATE)

global i

​

try:

[device.open](https://device.open)()

\# Obtain the remote XBee device from the XBee network.

xbee\_network = device.get\_network()

remote\_device = xbee\_network.discover\_device(REMOTE\_NODE\_ID)

if remote\_device is None:

print("Could not find the remote device")

exit(1)

​

\# Set the local device as destination address of the remote.

remote\_device.set\_dest\_address(device.get\_64bit\_addr())

​

\# Enable periodic sampling every IO\_SAMPLING\_RATE seconds in the remote device.

remote\_device.set\_io\_sampling\_rate(IO\_SAMPLING\_RATE)

​

\# Register a

/r/IPython
https://redd.it/bf8dg2
[P] Flattr, a book scanner app using TensorFlow Lite for realtime preview

Hello reddit!

We've just launched an app called **Flattr** that scans books quickly and beautifully, flattening the curved pages with the help of deep learning.

It uses TensorFlow Lite to flatten a page of a book and shows the flattened & cropped page in realtime. (The performance of the app may vary depending on your device.)

​

To see how it works, here's a demo video: [https://youtu.be/SlQbIQU62P4](https://youtu.be/SlQbIQU62P4)

​

Currently, its features are:

\- Live preview of the flattened book page

\- Auto-cropping

\- Scanned page enhancement that makes the flattened page much easier to read

\- Save pages to your gallery

​

You can download the app from here: [https://play.google.com/store/apps/details?id=com.voyagerx.flattr](https://play.google.com/store/apps/details?id=com.voyagerx.flattr)

​

The app is at an **early development stage** but we're improving fast and some of the features that could be added later are ...

​

**Our todo list**

\- Improve the quality of the scanned pages

\- Improve the page flattening model

\- Compile scanned pages into a book

\- Export to PDF

\- Support various document types

\- Add OCR: Recognizing texts in images

\- Add auto-scan: No need to touch the preview screen

\- Add auto page number detection & page sorting

Oh and it's **FREE!**

​

Give it a try and tell us your thoughts, thanks!

​

**Comparisons with existing apps**

\- Adding some comparison pics since there was a question about the how Flattr differs from existing solutions.

​

​

[CamScanner](https://i.redd.it/7snzgwa8idt21.jpg)

​

​

[MS Office Lens](https://i.redd.it/sxfbd6t9idt21.jpg)

​

[Flattr](https://i.redd.it/dnpn6wjdidt21.jpg)

I think

/r/MachineLearning
https://redd.it/bf8u41
The best production-ready Docker + Django configuration

Hi, there is a lot of tutorials and examples of Docker + Django config but where can I find the best one, production-ready? Perfectly with GitLab CI/CD. Can you recommend any article or github repo? Thanks!

/r/django
https://redd.it/bfb5lt
How to set up a 200,000 hits per second django server

Hi i need to set up a server that can handle ~200,000 hits per second. Specs are 128 core cpu, 64 gb ram.
Most requests will be within 1kb return and most of them are exactly same so caching will be possible.
I was thinking of nginx(for images) and redis with django .
Any help will be highly appreciated

/r/django
https://redd.it/bfb4zc
Python Tutorial: How to Read-Write Excel Files, Web-Scrap Google and Create Interactive Maps in 20 lines of Code

The following short article shows just how simple it is to use Python programming language in a data science project.

In this example, we’ll first go to Statista.com (public dataset provider) and download the MS Excel dataset that contains the list of 100 largest companies in the world. The file that contains only two columns, the company name and their current market value. Our goal is to use Python to read the rows and cells inside the Excel file and use it to search the internet for some additional information, such as the company’s headquarters location and it’s map coordinates (latitude and longitude). You’ll see how easily this can be done by using Python web-scraping capabilities.

We’ll also show how to write the newly found information back into the Excel sheet and use it to create an infographic that shows the headquarter location of 100 of the world’s top companies on the map.

https://www.joe0.com/2019/04/20/python-tutorial-reading-writing-excel-files-data-gathering-by-web-scraping-google/

As far as 20 lines, I know, better-formatted post could easily end up being 25 or even 30 lines long, but hey :)

Enjoy!

/r/Python
https://redd.it/bf9cgz
Django Wedding Site

I made a Django site for my wedding, which was last month. The site has a working RSVP and a comment section. Feel free to check it out! I'm not much of a style guy, so the CSS may not appeal to you, but let me know what you guys think.

[https://www.wilsonegoavil.com](https://www.wilsonegoavil.com)

I applied a login required decorator at the comment and RSVP sections so you'd be required to login before use of those features. If you've got any questions or criticisms, let me know.

Source code can be found at [https://github.com/shanewilson007/wedding-site](https://github.com/shanewilson007/wedding-site).

/r/django
https://redd.it/bffdml