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
Lil cheatsheet

/r/Python
https://redd.it/arp3z9
This media is not supported in your browser
VIEW IN TELEGRAM
Python-powered IoT device shows total # of humans online (live) on Python Discord server

/r/Python
https://redd.it/aroyp9
This media is not supported in your browser
VIEW IN TELEGRAM
My ASCII generator (image2text, image2image and video2video) written in Python (Source code: https://github.com/vietnguyen91/ASCII-generator)

/r/Python
https://redd.it/arqh4i
Does it make sense to use flask-restful to write restapi instead of use the original Flask?

Hi all,

I am new in the rest world. I have a big question, why people use the `flask-restful` or `flask-restplus` to writing the rest apis? I didn't see any advantages of that!

​

In my point of view, use Flask directly,

* you can reuse the original models, this is very convenient, if you change the models in the future, you don't need to change the api models... (I mean, in the case you also use Flask to build frontend. )
* you can use the `wtforms` to validate the form inputs. wtforms has a lot of Built-in validators. You can also create your own validators...
* `flask-restful` and `flask-restplus` are third party libraries, which are very possibly not to be maintained in the future...

/r/flask
https://redd.it/arr6za
Simple, clear and fast Web Crawler framework build on python3.6+, powered by asyncio.

## Features

* Useful http client out of box
* Things(request, response and item) can though pipelines(in async or not)
* Item extractor, it\`s easy to define and extract(by xpath, jpath or regex) one item we want from html, json or strings.
* Custom "ensure\_future" and "as\_completed" api provide a easy work flow

## Install

pip install ant\_nest

## Usage

Create one demo project by cli:

`>>> ant_nest -c examples`

Then we have a project:

`drwxr-xr-x 5 bruce staff 160 Jun 30 18:24 ants`

`-rw-r--r-- 1 bruce staff 208 Jun 26 22:59 settings.py`

Presume we want to get hot repos from github, let\`s create "examples/ants/example2.py":

from ant_nest import *
from yarl import URL


class GithubAnt(Ant):
"""Crawl trending repositories from github"""
item_pipelines = [
ItemFieldReplacePipeline(
('meta_content', 'star', 'fork'),
excess_chars=('\r', '\n',

/r/Python
https://redd.it/aru9lm
~8 years ago (I was ~14) I started this beautiful riddle and tonight i finally finished it!

/r/Python
https://redd.it/arv2qj
Got this book at pycaribbean yesterday!

/r/Python
https://redd.it/arvtmf
I need to learn Flask in 5 days for Hackathon. How do I go about this? All help is appreciated!

I have been incorporated into a hackathon team due to the untimely unavailability of a member. I have to learn flask in 5 days and implement our project in it. How can I effectively do this?

Edit: I have no prior web dev experience

/r/flask
https://redd.it/arvoyy
[AF] Best practices for multi-page forms?

Hi all,

As the complexity of my application grows, I'm noticing that I need to create forms that span multiple pages.

A simple use case I'm experiencing is when I have a form that requires a foreign key to another object (we'll call it Foo). However, my database has over 10,000 Foo records. What I would like to do is have a new screen which allows a user to search for a Foo record and return this information back to the original form screen without losing previously entered form data.

How do you all handle similar scenarios?

/r/flask
https://redd.it/ary049
[AF] Have no idea how to deal with this error: 'KeyError: <flask.cli.ScriptInfo object at [...]>'

Python 3.7.1
Flask==1.0.2

I've been using Miguel Grinberg's wonderful 'FLASK WEB DEVELOPMENT' as a reference guide when building a Social Media clone project.

I built some of it not completely following the flow of the book, so had some things he talks about later in the book set up already, but got to the point where it was time to re-structure my project as it had become quite large.

In the book, he talks about using an 'application factory' with a config.py file, and then calling from that when creating the app instance so you can use different configuration set-ups. Here is the config.py file, copied straight from the book:


import os
basedir = os.path.abspath(os.path.dirname(__file__))

class Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or 'mysecretkey'
MAIL_SERVER = os.environ.get('MAIL_SERVER', 'smtp.googlemail.com')
MAIL_PORT = os.environ.get('MAIL_PORT', '587')
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS', 'true').lower() in \
['true', 'on', '1']
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')


/r/flask
https://redd.it/arzfgt
Jump Out of the Jupyter Notebook with nbconvert

Easily Convert Notebooks to Python Scripts and Sharable Files. I wrote a little guide to using nbconvert from the command line. Feedback welcome!

[https://towardsdatascience.com/jump-out-of-the-jupyter-notebook-with-nbconvert-7d4748960702](https://towardsdatascience.com/jump-out-of-the-jupyter-notebook-with-nbconvert-7d4748960702)

/r/IPython
https://redd.it/as0mal
Celery beat without separate dyno on Heroku

Currently have Django + RabbitMQ + Celery hosted on heroku for my production servers. My procfile is as follows:


web: gunicorn uw_api_project.wsgi --log-file -
worker1: celery -A uw_api_project worker -Q uw -l info --without-gossip --without-mingle --without-heartbeat
beat: celery -A uw_api_project worker -B

Is it not possible to run celery beat in the same dyno as worker1 on production? I've read in several places that `-B` or `--beat` flags are available only for development, however, I've tried running `--beat` as well as `-B` on the same worker as suggested in this [article](https://drdaeman.github.io/heroku-djcelery-example/) to no avail. Do I really need to pay for a another dyno on Heroku to manage celery beat?


/r/django
https://redd.it/as142s
A database of notebooks for scientists and students
https://www.gited.io

/r/JupyterNotebooks
https://redd.it/aruwuf
Announcing the 1.1.0 release of my completely free and open source python project, Social Amnesia! This tool lets you wipe out old reddit and twitter items, automatically and on a schedule, with configuration tools to save the items you care about. Now with support for 2FA!

&#x200B;

https://i.redd.it/w2jiz1gqkdh21.png

[https://github.com/Nick-Gottschlich/Social-Amnesia](https://github.com/Nick-Gottschlich/Social-Amnesia)

Direct link to release with downloadables: [https://github.com/Nick-Gottschlich/Social-Amnesia/releases/tag/v1.1.0](https://github.com/Nick-Gottschlich/Social-Amnesia/releases/tag/v1.1.0)

# What's new?

\- Social Amnesia now works fully with reddit and twitter 2FA/MFA (2 Factor Authorization/Multi Factor Authorization). If you have MFA set up you will be taken to a sign on page for reddit to allow Social Amnesia to work properly without having to send a new token every hour. Twitter will have the same login process whether you have MFA set up or not.

\- I've added information text to the login page of the app so that people will know what the limitations of the API are for reddit and twitter.

# What is this?

I’m excited to release 1.0.0 of my side project, Social Amnesia! This completely free and open source software allows you to wipe out old reddit and twitter posts, comments, tweets, and favorites, automatically and on a schedule. It also allows you to configure certain items to be saved based on configuration options like number of upvotes, favorites, or retweets, whether an item has been gilded, how old an item is, or by specifically whitelisting items you would like to have saved.

# Who is this for?

You may be wary of what you post on reddit, twitter, facebook (if you even

/r/Python
https://redd.it/as0pro
How do you create a login pop up that shows on the current page, and not in a new page ? How do you process the form, via JS ?



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