Creating and Manipulating PDFs with pdfrw
http://www.blog.pythonlibrary.org/2018/06/06/creating-and-manipulating-pdfs-with-pdfrw/
/r/Python
https://redd.it/8ozo8k
http://www.blog.pythonlibrary.org/2018/06/06/creating-and-manipulating-pdfs-with-pdfrw/
/r/Python
https://redd.it/8ozo8k
reddit
r/Python - Creating and Manipulating PDFs with pdfrw
53 votes and 3 so far on reddit
[D] Dedicated to all those researchers in fear of being scooped :)
/r/MachineLearning
https://redd.it/8p169l
/r/MachineLearning
https://redd.it/8p169l
[R] Producing human-style explanations for AI decisions that doctors actually trust.
https://lukeoakdenrayner.wordpress.com/2018/06/05/explain-yourself-machine-producing-simple-text-descriptions-for-ai-interpretability/
/r/MachineLearning
https://redd.it/8ozh86
https://lukeoakdenrayner.wordpress.com/2018/06/05/explain-yourself-machine-producing-simple-text-descriptions-for-ai-interpretability/
/r/MachineLearning
https://redd.it/8ozh86
Luke Oakden-Rayner
Explain yourself, machine. Producing simple text descriptions for AI interpretability.
Humans explain their decisions with words. In our latest work, we suggest AI systems should do the same.
[JupyterLab] How to Run R Code AND Python Code in Same Notebook?
I am trying to run some python code, then carry those created objects through some R code, then back to python within the same notebook. I know it was possible in Jupyer Notebook as I have seen many tutorials on how to do it.
Jupyter notebook used to have things like rpy2 but that does not seem to work anymore. Does anyone know how to accomplish this in JupyterLab in anaconda?
Thanks in Advance!
/r/IPython
https://redd.it/8p4m0m
I am trying to run some python code, then carry those created objects through some R code, then back to python within the same notebook. I know it was possible in Jupyer Notebook as I have seen many tutorials on how to do it.
Jupyter notebook used to have things like rpy2 but that does not seem to work anymore. Does anyone know how to accomplish this in JupyterLab in anaconda?
Thanks in Advance!
/r/IPython
https://redd.it/8p4m0m
reddit
r/IPython - [JupyterLab] How to Run R Code AND Python Code in Same Notebook?
0 votes and 0 so far on reddit
Login through api
Hello guys what would be the best way to login through a api and to keep the user logged in like flask-login do and that can offer the best protection for the api
/r/flask
https://redd.it/8p5cnn
Hello guys what would be the best way to login through a api and to keep the user logged in like flask-login do and that can offer the best protection for the api
/r/flask
https://redd.it/8p5cnn
reddit
r/flask - Login through api
1 votes and 0 so far on reddit
Flask in Docker, some problems here.
Hello everyone,
once again i have a problem with a docker app. To be more precise i want to learn python flask development, so i created an docker image, here it is:
`FROM python:alpine`
`WORKDIR /app`
`COPY ./app/requirements.txt .`
`RUN pip install --no-cache-dir -U -r requirements.txt`
Pretty basic. Just installs flask into my container.
Then i have the following docker\-compose file:
`version: '3'`
`services:`
`flaskapp:`
`build: .`
`container_name: flaskapp`
`volumes:`
`- $PWD/app:/app`
`environment:`
`- FLASK_APP=app.py`
`- FLASK_SETTINGS=config/config.py`
`ports:`
`- "5000:5000"`
`command: flask run`
As you see, there are two environment vars that i want to pass to my container. First, the actual flask app that is in the /app folder. Then, the localtion of my config file which is in the /config directory.
Here is my app.py file:
`from flask import Flask`
`import os`
`app = Flask(__name__)`
`app.config.from_envvar('FLASK_SETTINGS')`
`@app.route('/')`
`def index():`
`return 'Index Page'`
Here is the config file:
`DEBUG = True`
`HOST = '0.0.0.0'`
So now to the actual misbehavior, when i start the container i get the following:
`docker-compose up`
`Starting flaskapp ... done`
`Attaching to flaskapp`
`flaskapp | * Serving Flask app "app.py"`
`flaskapp | * Environment: production`
`flaskapp | WARNING: Do not use the development server in a production environment.`
`flaskapp | Use a production WSGI server instead.`
`flaskapp | * Debug mode: off`
`flaskapp | * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)`
The environment variable FLASK\_APP is being read correctly, flask detects its ("`* Serving Flask app "`[`app.py`](https://app.py/)`"`"), but the config file isnt loaded ("`Debug mode: off`"), also `HOST = '`[`0.0.0.0`](https://0.0.0.0/)`'` is not set because i cant reach the app with my browser.
I assume that i have some error in my [app.py](https://app.py), but iam not sure.
Can you guys see any errors in my set up here? Wanted to learn flask and now already stuck with the basics :(
Btw, i also tried it without docker (same python files), also no luck.
Thanks in advance, have a nice day everyone!
/r/flask
https://redd.it/8p2ygx
Hello everyone,
once again i have a problem with a docker app. To be more precise i want to learn python flask development, so i created an docker image, here it is:
`FROM python:alpine`
`WORKDIR /app`
`COPY ./app/requirements.txt .`
`RUN pip install --no-cache-dir -U -r requirements.txt`
Pretty basic. Just installs flask into my container.
Then i have the following docker\-compose file:
`version: '3'`
`services:`
`flaskapp:`
`build: .`
`container_name: flaskapp`
`volumes:`
`- $PWD/app:/app`
`environment:`
`- FLASK_APP=app.py`
`- FLASK_SETTINGS=config/config.py`
`ports:`
`- "5000:5000"`
`command: flask run`
As you see, there are two environment vars that i want to pass to my container. First, the actual flask app that is in the /app folder. Then, the localtion of my config file which is in the /config directory.
Here is my app.py file:
`from flask import Flask`
`import os`
`app = Flask(__name__)`
`app.config.from_envvar('FLASK_SETTINGS')`
`@app.route('/')`
`def index():`
`return 'Index Page'`
Here is the config file:
`DEBUG = True`
`HOST = '0.0.0.0'`
So now to the actual misbehavior, when i start the container i get the following:
`docker-compose up`
`Starting flaskapp ... done`
`Attaching to flaskapp`
`flaskapp | * Serving Flask app "app.py"`
`flaskapp | * Environment: production`
`flaskapp | WARNING: Do not use the development server in a production environment.`
`flaskapp | Use a production WSGI server instead.`
`flaskapp | * Debug mode: off`
`flaskapp | * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)`
The environment variable FLASK\_APP is being read correctly, flask detects its ("`* Serving Flask app "`[`app.py`](https://app.py/)`"`"), but the config file isnt loaded ("`Debug mode: off`"), also `HOST = '`[`0.0.0.0`](https://0.0.0.0/)`'` is not set because i cant reach the app with my browser.
I assume that i have some error in my [app.py](https://app.py), but iam not sure.
Can you guys see any errors in my set up here? Wanted to learn flask and now already stuck with the basics :(
Btw, i also tried it without docker (same python files), also no luck.
Thanks in advance, have a nice day everyone!
/r/flask
https://redd.it/8p2ygx
pyupgrade: automatically rewrite format calls to f-strings (among other things)
https://github.com/asottile/pyupgrade
/r/Python
https://redd.it/8p578l
https://github.com/asottile/pyupgrade
/r/Python
https://redd.it/8p578l
GitHub
GitHub - asottile/pyupgrade: A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language.
A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language. - asottile/pyupgrade
Advice on IDE or editor for Django
I'm new at Django and currently working on a large personal project (iOS chat app with django backend). I'm using Webfaction hosting, and right now I'm just logging in through ssh, using vim to edit files, then running and opening up the error log file to debug one error at a time. Is there better way of doing this? It'd be nice to be able to use a Python "compiling" editor and run the code immediately without having to ssh files back and forth.
/r/django
https://redd.it/8p6zoa
I'm new at Django and currently working on a large personal project (iOS chat app with django backend). I'm using Webfaction hosting, and right now I'm just logging in through ssh, using vim to edit files, then running and opening up the error log file to debug one error at a time. Is there better way of doing this? It'd be nice to be able to use a Python "compiling" editor and run the code immediately without having to ssh files back and forth.
/r/django
https://redd.it/8p6zoa
reddit
r/django - Advice on IDE or editor for Django
5 votes and 24 so far on reddit
Easiest way to query a model's property?
In my user model, I have a paid member ("premium") property that checks Stripe and returns True or False.
This is fine for 90% of my site and locking away content, but there are also times when I need to sort users by premium status. Any suggestions for how to do this?
I saw something along the lines of this:
class UserProfile(models.model):
premium_field = models.BooleanField(db_column="premium")
@property
def premium(self):
if stripe.paid():
return True
else:
return False
But it looks like I might need a getter function as well? Hopefully I'm on the right track -- I just don't want to migrate or push changes unless I know I have it right. Thanks!
/r/djangolearning
https://redd.it/8p57w5
In my user model, I have a paid member ("premium") property that checks Stripe and returns True or False.
This is fine for 90% of my site and locking away content, but there are also times when I need to sort users by premium status. Any suggestions for how to do this?
I saw something along the lines of this:
class UserProfile(models.model):
premium_field = models.BooleanField(db_column="premium")
@property
def premium(self):
if stripe.paid():
return True
else:
return False
But it looks like I might need a getter function as well? Hopefully I'm on the right track -- I just don't want to migrate or push changes unless I know I have it right. Thanks!
/r/djangolearning
https://redd.it/8p57w5
reddit
r/djangolearning - Easiest way to query a model's property?
2 votes and 5 so far on reddit
Is it a good idea to use a mixin for a multi-value field?
Lets say that I have a model called 'Movie' and I want 'Movies' to have a spot to remember all the genres it belongs to (Horror, Suspense, Funny, Romance, etc... ). It seems like there are a few options. I could make a single field that stores a JSON string that holds genres as keys and booleans as values (Bad Idea). I could create a Boolean field in 'Movie' for each of the genres. But that makes for a lot of fields in a single model. Or I could make a mixin called 'GenreMixin' with a boolean field for each genre and have 'Movie' inherit from it.
What is the best practice, what will lead to the easiest to maintain down the road?
/r/djangolearning
https://redd.it/8p538x
Lets say that I have a model called 'Movie' and I want 'Movies' to have a spot to remember all the genres it belongs to (Horror, Suspense, Funny, Romance, etc... ). It seems like there are a few options. I could make a single field that stores a JSON string that holds genres as keys and booleans as values (Bad Idea). I could create a Boolean field in 'Movie' for each of the genres. But that makes for a lot of fields in a single model. Or I could make a mixin called 'GenreMixin' with a boolean field for each genre and have 'Movie' inherit from it.
What is the best practice, what will lead to the easiest to maintain down the road?
/r/djangolearning
https://redd.it/8p538x
reddit
r/djangolearning - Is it a good idea to use a mixin for a multi-value field?
2 votes and 2 so far on reddit
[AF] How to run a function after returning response (AWS Lambda)
Hey everyone! I'm using zappa to run a simple ffmpeg transcode function on Lambda with Flask. While Lambda functions can run for up to 5 minutes, the problem I'm running into is that Amazon's API Gateway times out after 30 seconds so I'm unable to just wait for ffmpeg to finish before returning a response.
I'm looking for a way to return a response immediately from my Flask function and then continue running my ffmpeg function in the background. (The Flask response will contain a JSON payload with the S3 url that the finished ffmpeg job will upload to.)
I've tried using `threading.Thread` but it doesn't appear to stay alive after my Flask function returns. Thoughts/ideas? Thank you for your help!
/r/flask
https://redd.it/8p78ev
Hey everyone! I'm using zappa to run a simple ffmpeg transcode function on Lambda with Flask. While Lambda functions can run for up to 5 minutes, the problem I'm running into is that Amazon's API Gateway times out after 30 seconds so I'm unable to just wait for ffmpeg to finish before returning a response.
I'm looking for a way to return a response immediately from my Flask function and then continue running my ffmpeg function in the background. (The Flask response will contain a JSON payload with the S3 url that the finished ffmpeg job will upload to.)
I've tried using `threading.Thread` but it doesn't appear to stay alive after my Flask function returns. Thoughts/ideas? Thank you for your help!
/r/flask
https://redd.it/8p78ev
reddit
r/flask - [AF] How to run a function after returning response (AWS Lambda)
2 votes and 3 so far on reddit
[JupyterLab] How to Run R Code AND Python Code in Same Notebook?
https://www.reddit.com/r/IPython/comments/8p4m0m/jupyterlab_how_to_run_r_code_and_python_code_in/
/r/JupyterNotebooks
https://redd.it/8p58j3
https://www.reddit.com/r/IPython/comments/8p4m0m/jupyterlab_how_to_run_r_code_and_python_code_in/
/r/JupyterNotebooks
https://redd.it/8p58j3
reddit
r/IPython - [JupyterLab] How to Run R Code AND Python Code in Same Notebook?
0 votes and 0 so far on reddit
Creating Your First Offline Payment Wallet With Django, Part-1
https://www.zeolearn.com/magazine/creating-your-first-offline-payment-wallet-with-django-part-1
/r/django
https://redd.it/8p8nfs
https://www.zeolearn.com/magazine/creating-your-first-offline-payment-wallet-with-django-part-1
/r/django
https://redd.it/8p8nfs
Zeolearn
Creating Off-Line Payment Wallet with Django | Django Offline Payment Tutorial
Are you aware of creating offline payment wallet with Django? Then here is the destination. Django is is a high-level Python web framework help to build better web apps. Explore more about Django.
How do you use Python to automate something in your daily life?
This question seems to produce new and unique responses each time it is asked, so why not give it another go? I’d love to hear how you use Python to automate something to save you time!
/r/Python
https://redd.it/8p7zjf
This question seems to produce new and unique responses each time it is asked, so why not give it another go? I’d love to hear how you use Python to automate something to save you time!
/r/Python
https://redd.it/8p7zjf
reddit
How do you use Python to automate something in your... • r/Python
This question seems to produce new and unique responses each time it is asked, so why not give it another go? I’d love to hear how you use Python...
This seems a very helpful validator for Flask API servers
https://github.com/alecthomas/voluptuous
/r/flask
https://redd.it/8p83v8
https://github.com/alecthomas/voluptuous
/r/flask
https://redd.it/8p83v8
GitHub
GitHub - alecthomas/voluptuous: CONTRIBUTIONS ONLY: Voluptuous, despite the name, is a Python data validation library.
CONTRIBUTIONS ONLY: Voluptuous, despite the name, is a Python data validation library. - alecthomas/voluptuous
Face tracking anime girl with proximity detection
https://v.redd.it/xna7lmmjwk211
/r/Python
https://redd.it/8pa8ff
https://v.redd.it/xna7lmmjwk211
/r/Python
https://redd.it/8pa8ff
reddit
Face tracking anime girl with proximity detection • r/Python
33 points and 9 comments so far on reddit
React & Django TUTORIAL Integration // REACTify Django
https://www.youtube.com/watch?v=AHhQRHE8IR8
/r/django
https://redd.it/8pb6d4
https://www.youtube.com/watch?v=AHhQRHE8IR8
/r/django
https://redd.it/8pb6d4
YouTube
React & Django TUTORIAL Integration // REACTify Django
Integrate REACT & DJANGO with this tutorial.
Code: https://github.com/codingforentrepreneurs/Reactify-Django
Project: https://kirr.co/twdy04
Blog Post: https://kirr.co/saru2p
Sections
1 - Welcome (0:00:00)
2 - Walkthrough (0:01:22)
3 - Requirements (0:04:05)…
Code: https://github.com/codingforentrepreneurs/Reactify-Django
Project: https://kirr.co/twdy04
Blog Post: https://kirr.co/saru2p
Sections
1 - Welcome (0:00:00)
2 - Walkthrough (0:01:22)
3 - Requirements (0:04:05)…
[AF] How to sort SQLAlchemy query by number of many to many relationships
Hello!
I have two tables which I've simplified below. A post model and a post likes model. When I want to create a like on a post, I create an instance of a post like which holds a backreference to the post in question.
I would like to perform a query that will grab all my posts and sort them by number of likes. However, because I'm still a bit green when it comes to SQLAlchemy, I'm not sure how to sort by number of many to many relationships (self\_likes).
class PostLike(db.Model):
post_id = db.Column("post_id", db.Integer, db.ForeignKey("post.id"),
primary_key=True)
class Post(db.Model):
_tablename_ = "post"
id = db.Column(db.Integer, primary_key=True)
self_likes = db.relationship("PostLike", backref="self_likes", lazy="dynamic", foreign_keys="PostLike.post_id")
Any help would be greatly appreciated!
/r/flask
https://redd.it/8p5wn6
Hello!
I have two tables which I've simplified below. A post model and a post likes model. When I want to create a like on a post, I create an instance of a post like which holds a backreference to the post in question.
I would like to perform a query that will grab all my posts and sort them by number of likes. However, because I'm still a bit green when it comes to SQLAlchemy, I'm not sure how to sort by number of many to many relationships (self\_likes).
class PostLike(db.Model):
post_id = db.Column("post_id", db.Integer, db.ForeignKey("post.id"),
primary_key=True)
class Post(db.Model):
_tablename_ = "post"
id = db.Column(db.Integer, primary_key=True)
self_likes = db.relationship("PostLike", backref="self_likes", lazy="dynamic", foreign_keys="PostLike.post_id")
Any help would be greatly appreciated!
/r/flask
https://redd.it/8p5wn6
reddit
r/flask - [AF] How to sort SQLAlchemy query by number of many to many relationships
1 votes and 9 so far on reddit
Python Application Layouts: A Reference
https://realpython.com/python-application-layouts/
/r/Python
https://redd.it/8pe0j5
https://realpython.com/python-application-layouts/
/r/Python
https://redd.it/8pe0j5
Realpython
Python Application Layouts: A Reference – Real Python
A reference guide to common Python application layouts and project structures for command-line applications, web applications, and more.