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
Python Library for Grammar and Writing Style? (Grammarly Immitator)

Hello folks,

I see ads for Grammarly and I like some of the things it does (like finding weak wording, checking for passive voice, etc.), but I'm not paying for it. I'd like to instead find Python libraries that can do some of the things Grammarly does, like:

* Detecting weak word choice and offer alternatives
* Detecting passive voice
* Detecting word repetition
* Detecting bad grammar
* Find paragraphs that are too long (a paragraph should be about one topic; if it's wandering around in its topics, it should be revised)

That is, it would be nice to have an automated editor (by "editor" I mean "I read your stuff and give feedback", not a text editor like vim). I like writing my blog posts using markdown in a text editor like vim (like George R. R. Martin, I like simple with no distractions, and white-on-black of a terminal is just boss), so writing some vim commands that use a Python library that find bad style and spelling errors would be great when writing posts.

Do any such libraries exist?

/r/Python
https://redd.it/6dd0up
Help needed !

I need your advice and suggestions. Actually I'm using matlab scripts for numerical analysis envolved in the final project of my career. Now I want to migrate to python.
Would you please suggest me any tutorial for linux mint?

/r/Python
https://redd.it/6de8k4
Combining Javascript and Django?

I'm new to web programming and have been working with Javascript and Django independent of each other. Are there ways to combine them? By this I mean is it possible to do a database query in Javascript, send data gathered with Javascript to Django code, etc.

/r/django
https://redd.it/6det21
Hand-crafted Python 2 and 3 boilerplates with argparse, logging, Flask, pytest, tox, and more
https://www.python-boilerplate.com

/r/Python
https://redd.it/6dgkka
I've created a Django project template for myself long ago, thought I'd share. I've made dozens of site using it. There is dev, staging, production separation, deployment scripts and Apache configs for Webfaction and some other useful stuff. Any critique is welcome.
https://bitbucket.org/andreyshipilov/django_temple/

/r/django
https://redd.it/6dfh11
Flask CSRF protection causes error?

So i am making a contact form and it all works but the CSRF protection causes an error, it says
> jinja2.exceptions.UndefinedError: 'form' is undefined

It is the only thing that causes it, and i have looked up every soloution i can and none of them work.

Ill post all my code here so you can see for youself.


[1 - Contact.html , This also doesnt work if i use form.csrf_token](https://hastebin.com/rodelacegi.http)


[2 - app.py](https://hastebin.com/bawedewuza.py)


/r/flask
https://redd.it/6dcsts
Django Rest Framework Token Auth w/ Django Channels?

Is there any way to get Django REST Framework's Token Auth scheme working with a websocket connection (Channels)? I'm essentially looking to authenticate the user in the same way I do my REST API.

/r/django
https://redd.it/6dl65v
Not sure how to optimally making apps reusable when they depend on resources that used between other apps?

For example if several of my apps depend on a shared .css file?

Since it would not be efficient to split the css file into several css files.

Should I just make a readme file for the app that says, the app is made to be used in a project that uses for example twitter bootstrap?


/r/djangolearning
https://redd.it/6dl7hl
My first book - Tkinter By Example - now available (Free, CC BY-ND)

Hi everyone.

I've read a LOT of programming books, so I decided it was time to give one back to the community. Since I love working with the Tkinter library to create GUIs, I decided to write a book which will hopefully help teach newbies how to get started with writing their own GUI applications.

I've finally finished and released Learn Tkinter By Example. It's free, released under Creative Commons with the Python source code released with the MIT licence. The Latex source code is also available alongside the PDF book, should anybody want that for any reason.

The book is available from my Github here, along with more details:

https://github.com/Dvlv/Tkinter-By-Example

All feedback is welcome (preferably constructive rather than just insults!) As the book states towards the end, I am completely open to working on developing it further if need be. Source code comments, questions, and changes can be sent to me through Github, and anything book-related can be messaged to me directly here or through twitter (@Dvlv292).

I hope this book will be of use to some of you.

/r/Python
https://redd.it/6dnfsw
Best practices for giving a single user customization options on an otherwise application-wide available object/model

Hopefully that title wasn't too gory, I tried describing this particular issue without knowing exactly what it is.

Here's a scenario to (hopefully) paint a better picture of what I'm talking about; I'll use RSS feeds and their respective entries for this example.

class Feed(models.Model):
href = models.URLField()
title = models.CharField()


class Entry(models.Model):
# A Feed may have many entries
feed = models.ForeignKey(Feed)

content = models.TextField()
href = models.URLField()
title = models.CharField()


class User(models.Model):
...

# A User may have many feeds, a Feed may have many users
feeds = models.ManyToManyField(Feed)

Since many users of this service may subscribe to the same RSS feed, we won't create a new record every time a user requests to add that subscription -- we'll just create a relationship between the existing records. Same goes for a Feed's entries: instead of duplicating an Entry potentially many times, we'll just connect an Entry to it's Feed, and that Feed will be connected to a User.

**The Rub**

If, for instance, we want to give the User the ability to mark a particular Entry as "read," what would be a smart way of going about this? Obviously, adding a `read` field to the Entry model wouldn't be a great idea because one user will be able to mark that Entry as "read" for every other user which is subscribed to that Entry's Feed.

My initial approach was to create a separate, sort-of proxy model which would give the functionality of being able to mark a single Entry as "read" without disturbing all other users; for instance:

class EntryProxy(models.Model):
entry = models.ForeignKey(Entry)
user = models.ForeignKey(User)

read = models.BooleanField(default=False)

This way, a user has their "own" Entry to mark as "read." Doing things this way just seems a bit fragile; I feel like I'm not thinking things through correctly.

I'd appreciate any insight you may have on how to best tackle this situation. Also, it's very likely I'm going about this whole problem incorrectly. In that case, I'd equally appreciate any insight you're able to contribute in helping me on my way.

Thanks for your time.

/r/django
https://redd.it/6ddm5x
How to search the database and return json and then update website without reloading?

Sorry I'm really knew to all of this. If someone could guide me in the right direction that would be amazing.

1. When first visiting the website, the main page will load. I have this working.

2. I want a search bar. For example, the user can search for "Apple"

3. I want to look in the database for "Apple" and get serialize json for that entry. So things like its color and price etc. I want to json to be given to the user. Idk how/where tho without leaving the main page.

4. The front-end library I am using has a $.getJson field. I want to load that json in that field and run that function.


I understand how to filter the database and serialize json. I'm just really confused on how to send the search bar data and how to handle it and where do I send the json back without redirecting the webpage to the json?

If I manage to get the json back, how do I load it in my library?

Thanks so much!


/r/django
https://redd.it/6dd3v2
[AF] Question on deployment to server running apache

I'm trying to deploy my flask application to an internal company wide apache webserver. We do ip based server names, so for example if I were to have an application called TestApp, and the ip address of our internal server is 176.124.10.114, we would want the address to the application to be 176.124.10.114/TestApp

I've installed mod_wsgi (for python 3 under apache 2.4), but I can't get apache to connect to mod_wsgi using the wsgi file in my project directory.

This is what my VirtualHost file looks like:

<VirtualHost 176.124.10.114:80>
ServerName 176.124.10.114/TestApp
WSGIDaemonProcess TransferTrack user=user group=users threads=5 home=/path/to/flask/app/directory
WSGIScriptAlias / /path/to/flask/app/directory/app.wsgi

<Directory /home/path/to/flask/app/directory>
WSGIProcessGroup TestApp
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Require all granted
</Directory>
</VirtualHost>

My app.wsgi file looks like this:

import sys

# Specify path to virtual env instance of python
activate_this = "/path/to/flask/app/venv/bin/activate_this.py"

with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))

sys.path.insert(0, '/path/to/flask/app/directory')

from routes import app as application

Are my VirtualHost and .wsgi file hosed up? And also, can I store the flask app anywhere on the file system as long as the VirtualHost file is pointing to it property or does it have to be in a certain directory related to apache?

/r/flask
https://redd.it/6dq6fa