What's everyone working on this week?
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/8b7uc8
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/8b7uc8
reddit
What's everyone working on this week? • r/Python
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your...
Heroku Procfile automatically turns to .txt file
Hey guys i have been changing the Procfile name on Heroku with no extension through the cmd but every time i do a "git push heroku master" automatically the Procfile turns to Procfile.txt! What could have caused the problem?
/r/djangolearning
https://redd.it/8b7nz7
Hey guys i have been changing the Procfile name on Heroku with no extension through the cmd but every time i do a "git push heroku master" automatically the Procfile turns to Procfile.txt! What could have caused the problem?
/r/djangolearning
https://redd.it/8b7nz7
reddit
Heroku Procfile automatically turns to .txt file • r/djangolearning
Hey guys i have been changing the Procfile name on Heroku with no extension through the cmd but every time i do a "git push heroku master"...
Red Hat Confirms RHEL 8 Will Drop Python 2
https://www.phoronix.com/scan.php?page=news_item&px=RHEL-8-No-Python-2
/r/Python
https://redd.it/8bb6oq
https://www.phoronix.com/scan.php?page=news_item&px=RHEL-8-No-Python-2
/r/Python
https://redd.it/8bb6oq
Phoronix
Red Hat Confirms RHEL 8 Will Drop Python 2 - Phoronix
Phoronix is the leading technology website for Linux hardware reviews, open-source news, Linux benchmarks, open-source benchmarks, and computer hardware tests.
How do I configure Jupyter Notebooks to open in a browser?
When I open a Jupyter Notebook, I want it to open in a new tab of an existing Firefox window. In my ~/.jupyter/jupyter_notebook_config.py file, I try
c.NotebookApp.browser = '/usr/bin/firefox'
With this, I get a popup error from Firefox to the effect that "Firefox is already running", which isn't unexpected. You need to use command line flags to affect an already existing instance of Firefox, so I try
c.NotebookApp.browser = '/usr/bin/firefox -P default -new-tab'
When I do this, the terminal output from Jupyter gives the error
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/firefox -P default -new-tab': '/usr/bin/firefox -P default -new-tab'
How do I tell Jupyter to open Firefox with command-line options?
/r/JupyterNotebooks
https://redd.it/8b8mtq
When I open a Jupyter Notebook, I want it to open in a new tab of an existing Firefox window. In my ~/.jupyter/jupyter_notebook_config.py file, I try
c.NotebookApp.browser = '/usr/bin/firefox'
With this, I get a popup error from Firefox to the effect that "Firefox is already running", which isn't unexpected. You need to use command line flags to affect an already existing instance of Firefox, so I try
c.NotebookApp.browser = '/usr/bin/firefox -P default -new-tab'
When I do this, the terminal output from Jupyter gives the error
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/firefox -P default -new-tab': '/usr/bin/firefox -P default -new-tab'
How do I tell Jupyter to open Firefox with command-line options?
/r/JupyterNotebooks
https://redd.it/8b8mtq
reddit
How do I configure Jupyter Notebooks to open... • r/JupyterNotebooks
When I open a Jupyter Notebook, I want it to open in a new tab of an existing Firefox window. In my ~/.jupyter/jupyter_notebook_config.py file, I...
Best way to handle file uploads?
Im trying to setup image uploads in a local Flask app with Flask-uploads. I think Im almost there but not able to finish it.
This is my form (using flask_wtf):
class AddBookForm(FlaskForm):
title = StringField('Title', validators=[DataRequired()])
author = StringField('Author', validators=[DataRequired()])
category = StringField('Category', validators=[DataRequired()])
image = FileField('Image', validators=[FileRequired()])
this is my template:
<form action="/upload" method="post" enctype="multipart/form-data" >
<span class="btn btn-default btn-file">
Browse <input type="file" name="image">
</span>
<input type="submit" value="Upload your image" class="btn btn-primary">
</form>
and then finally these are the important bits from views.py:
from flask.ext.uploads import UploadSet, configure_uploads, IMAGES, UploadNotAllowed
photos = UploadSet('photos', IMAGES, default_dest=lambda app: os.path.basename('uploads'))
configure_uploads(app, (photos,))
@app.route('/upload', methods=['GET', 'POST'])
def upload():
if request.method == 'POST' and 'image' in request.files:
filename = photos.save(request.files['image'])
rec = Photo(filename=filename, user=g.user.id)
rec.store()
flash("Photo saved.")
return redirect(url_for('show', id=rec.id))
return render_template('upload.html')
@app.route('/photo/<id>')
def show(id):
photo = Photo.load(id)
if photo is None:
abort(404)
url = photos.url(photo.filename)
return render_template('show.html', url=url, photo=photo)
As it stands right now when I go to /upload and fill in the form with an image the file does actually get uploaded to my 'uploads' directory in my app but this error is shown in the console:
File "/Users/david/Documents/projects/flask_store/storeapp/views.py", line 236, in upload
rec = Photo(filename=filename, user=g.user.id)
NameError: name 'Photo' is not defined
there is no object named 'Photo' but if I changed the fields in my from from 'image' to 'photo' then try and upload an image again I get no errors that time but the image doesn't get uploaded to the local 'uploads' directory.
What am I missing here?
thanks
/r/flask
https://redd.it/8b8l7l
Im trying to setup image uploads in a local Flask app with Flask-uploads. I think Im almost there but not able to finish it.
This is my form (using flask_wtf):
class AddBookForm(FlaskForm):
title = StringField('Title', validators=[DataRequired()])
author = StringField('Author', validators=[DataRequired()])
category = StringField('Category', validators=[DataRequired()])
image = FileField('Image', validators=[FileRequired()])
this is my template:
<form action="/upload" method="post" enctype="multipart/form-data" >
<span class="btn btn-default btn-file">
Browse <input type="file" name="image">
</span>
<input type="submit" value="Upload your image" class="btn btn-primary">
</form>
and then finally these are the important bits from views.py:
from flask.ext.uploads import UploadSet, configure_uploads, IMAGES, UploadNotAllowed
photos = UploadSet('photos', IMAGES, default_dest=lambda app: os.path.basename('uploads'))
configure_uploads(app, (photos,))
@app.route('/upload', methods=['GET', 'POST'])
def upload():
if request.method == 'POST' and 'image' in request.files:
filename = photos.save(request.files['image'])
rec = Photo(filename=filename, user=g.user.id)
rec.store()
flash("Photo saved.")
return redirect(url_for('show', id=rec.id))
return render_template('upload.html')
@app.route('/photo/<id>')
def show(id):
photo = Photo.load(id)
if photo is None:
abort(404)
url = photos.url(photo.filename)
return render_template('show.html', url=url, photo=photo)
As it stands right now when I go to /upload and fill in the form with an image the file does actually get uploaded to my 'uploads' directory in my app but this error is shown in the console:
File "/Users/david/Documents/projects/flask_store/storeapp/views.py", line 236, in upload
rec = Photo(filename=filename, user=g.user.id)
NameError: name 'Photo' is not defined
there is no object named 'Photo' but if I changed the fields in my from from 'image' to 'photo' then try and upload an image again I get no errors that time but the image doesn't get uploaded to the local 'uploads' directory.
What am I missing here?
thanks
/r/flask
https://redd.it/8b8l7l
reddit
Best way to handle file uploads? • r/flask
Im trying to setup image uploads in a local Flask app with Flask-uploads. I think Im almost there but not able to finish it. This is my form...
Flask and nodejs
Ok i have been reading online and i see that a lot of people and alot of companies are switching to nodejs im not a professional web developer but i like to build for personal use and for learning.
Is flask or django dying and what are the benefits of nodejs over flask (which is what i use)
/r/flask
https://redd.it/8b0pc9
Ok i have been reading online and i see that a lot of people and alot of companies are switching to nodejs im not a professional web developer but i like to build for personal use and for learning.
Is flask or django dying and what are the benefits of nodejs over flask (which is what i use)
/r/flask
https://redd.it/8b0pc9
reddit
Flask and nodejs • r/flask
Ok i have been reading online and i see that a lot of people and alot of companies are switching to nodejs im not a professional web developer but...
Improving SyntaxError in PyPy
https://morepypy.blogspot.com.au/2018/04/improving-syntaxerror-in-pypy.html
/r/Python
https://redd.it/8bar30
https://morepypy.blogspot.com.au/2018/04/improving-syntaxerror-in-pypy.html
/r/Python
https://redd.it/8bar30
morepypy.blogspot.co.uk
Improving SyntaxError in PyPy
For the last year, my halftime job has been to teach non-CS uni students to program in Python. While doing that, I have been trying to see ...
RedHat 7.5 release notes warn Python 3 will replace Python 2 in next major release
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/7.5_release_notes/chap-red_hat_enterprise_linux-7.5_release_notes-architectures
/r/Python
https://redd.it/8bbbt6
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/7.5_release_notes/chap-red_hat_enterprise_linux-7.5_release_notes-architectures
/r/Python
https://redd.it/8bbbt6
Red Hat Customer Portal
Chapter 2. Architectures Red Hat Enterprise Linux 7 | Red Hat Customer Portal
The Red Hat Customer Portal delivers the knowledge, expertise, and guidance available through your Red Hat subscription.
How do you figure out whether the duck needs to quack?
I have been using Python for a while and am loving it. However, as I begin to use old code or other people's code, I have found that it is getting really difficult to determine the interface people use since they rarely explicitly state it.
In Java the interface is made explicit and you can easily look-up what methods and types you need to define in order to expand or use another piece of code. But in Python, I have been spending a painful amount of time tracing through every part of a program to try and find out what methods I need for the object I am passing to some function. And if I miss a method I may not realize it till down the road when some obscure piece of code gets hit at run-time and I find out my object didn't have all that it needed.
Am I missing something here? Is there some proper way to Python so that the object interface is obvious? Are other people just not writing good Python code?
I feel like 'duck' typing is one of the biggest assets of Python, as it lets you work with objects based on how they function, but it seems exceedingly difficult to actually figure out whether the duck is supposed to quack or not.
Note: PyCharm is okay for some of this, but really doesn't hack it for anything but the simplest programs. And should it really be left to the IDE for something so important?
/r/Python
https://redd.it/8bebmr
I have been using Python for a while and am loving it. However, as I begin to use old code or other people's code, I have found that it is getting really difficult to determine the interface people use since they rarely explicitly state it.
In Java the interface is made explicit and you can easily look-up what methods and types you need to define in order to expand or use another piece of code. But in Python, I have been spending a painful amount of time tracing through every part of a program to try and find out what methods I need for the object I am passing to some function. And if I miss a method I may not realize it till down the road when some obscure piece of code gets hit at run-time and I find out my object didn't have all that it needed.
Am I missing something here? Is there some proper way to Python so that the object interface is obvious? Are other people just not writing good Python code?
I feel like 'duck' typing is one of the biggest assets of Python, as it lets you work with objects based on how they function, but it seems exceedingly difficult to actually figure out whether the duck is supposed to quack or not.
Note: PyCharm is okay for some of this, but really doesn't hack it for anything but the simplest programs. And should it really be left to the IDE for something so important?
/r/Python
https://redd.it/8bebmr
reddit
How do you figure out whether the duck needs to quack? • r/Python
I have been using Python for a while and am loving it. However, as I begin to use old code or other people's code, I have found that it is getting...
[AF] SQLite Database Singleton
I've been cobbling together a Flask App which uses SQLite. I was wondering if someone would be prepared to weigh in on my current method of accessing the database - using a singleton?
Basically I am creating a Database singleton in *before_first_request* which connects to the database calling *sqlite3.connect()*.
I've noticed that in the Flask docs they provide an [SQLite example](http://flask.pocoo.org/docs/0.12/patterns/sqlite3/) which stores the database against the *flask.g* object.
My main concern with my approach would be with regard to thread safety, which I presume will depend heavily on the server I intend to use in production?
This flask docs article seems to be focused on connecting to the db on demand - but if requests to my app will always need to access the database, then I would assume its better to connect only once?
/r/flask
https://redd.it/89f1be
I've been cobbling together a Flask App which uses SQLite. I was wondering if someone would be prepared to weigh in on my current method of accessing the database - using a singleton?
Basically I am creating a Database singleton in *before_first_request* which connects to the database calling *sqlite3.connect()*.
I've noticed that in the Flask docs they provide an [SQLite example](http://flask.pocoo.org/docs/0.12/patterns/sqlite3/) which stores the database against the *flask.g* object.
My main concern with my approach would be with regard to thread safety, which I presume will depend heavily on the server I intend to use in production?
This flask docs article seems to be focused on connecting to the db on demand - but if requests to my app will always need to access the database, then I would assume its better to connect only once?
/r/flask
https://redd.it/89f1be
asyncio/aiohttp question
Hello, I am new to django and python in general. My django back-end calls amazon api and returns parsed response to front-end. Now I have to make it asynchronous.
My view looks something like this (very simplified):
class AmazonSearchAPI(viewsets.ViewSet):
def get_products(self, request):
response = requests.get(request_params)
return Response(response, status=HTTP_200_OK)
Question is, do I need aiohttp? Can I just add asyncio and write "async def get_products(self, request)"?
/r/django
https://redd.it/8bfgp8
Hello, I am new to django and python in general. My django back-end calls amazon api and returns parsed response to front-end. Now I have to make it asynchronous.
My view looks something like this (very simplified):
class AmazonSearchAPI(viewsets.ViewSet):
def get_products(self, request):
response = requests.get(request_params)
return Response(response, status=HTTP_200_OK)
Question is, do I need aiohttp? Can I just add asyncio and write "async def get_products(self, request)"?
/r/django
https://redd.it/8bfgp8
reddit
asyncio/aiohttp question • r/django
Hello, I am new to django and python in general. My django back-end calls amazon api and returns parsed response to front-end. Now I have to make...
[P] Deep reinforcement Learning course: Q-learning article and DQN with Doom notebook are published
Hello, I'm currently writing a series of free articles about Deep Reinforcement Learning, where we'll learn the main algorithms (from Q* learning to PPO), and how to implement them in Tensorflow.
The second article is published, it's about Q-learning and we'll learn to **implement a Q-learning algorithm with Numpy and OpenAI Gym.**
**Q-learning article**: https://medium.freecodecamp.org/diving-deeper-into-reinforcement-learning-with-q-learning-c18d0db58efe
Moreover, the third article (Deep Q Learning with Doom) will be published **this week**, but the implementation of a Doom playing agent with Tensorflow **is already published.**
**Doom Deep Q agent**: https://github.com/simoninithomas/Deep_reinforcement_learning_Course/blob/master/DQN%20Doom/Deep%20Q%20learning%20with%20Doom.ipynb
Let me know what you think! What architectures you want and any feedback.
**The Syllabus**: https://simoninithomas.github.io/Deep_reinforcement_learning_Course/
**Introduction to Reinforcement Learning**: https://medium.freecodecamp.org/an-introduction-to-reinforcement-learning-4339519de419
Thanks!
/r/MachineLearning
https://redd.it/8beohl
Hello, I'm currently writing a series of free articles about Deep Reinforcement Learning, where we'll learn the main algorithms (from Q* learning to PPO), and how to implement them in Tensorflow.
The second article is published, it's about Q-learning and we'll learn to **implement a Q-learning algorithm with Numpy and OpenAI Gym.**
**Q-learning article**: https://medium.freecodecamp.org/diving-deeper-into-reinforcement-learning-with-q-learning-c18d0db58efe
Moreover, the third article (Deep Q Learning with Doom) will be published **this week**, but the implementation of a Doom playing agent with Tensorflow **is already published.**
**Doom Deep Q agent**: https://github.com/simoninithomas/Deep_reinforcement_learning_Course/blob/master/DQN%20Doom/Deep%20Q%20learning%20with%20Doom.ipynb
Let me know what you think! What architectures you want and any feedback.
**The Syllabus**: https://simoninithomas.github.io/Deep_reinforcement_learning_Course/
**Introduction to Reinforcement Learning**: https://medium.freecodecamp.org/an-introduction-to-reinforcement-learning-4339519de419
Thanks!
/r/MachineLearning
https://redd.it/8beohl
freeCodeCamp.org
Diving deeper into Reinforcement Learning with Q-Learning
by Thomas Simonini Diving deeper into Reinforcement Learning with Q-Learning > This article is part of Deep Reinforcement Learning Course with Tensorflow ?️. Check the syllabus here. [https://simoninithomas.github.io/Deep_reinforcement_learning_Course/] Today…
Documenting a Django Rest Framework API
I'm using DRF for the first time to create a read-only API. It all works fine, but I'm trying to work out how to automatically generate some documentation for it.
I've got a Swagger UI page up and running using [django-rest-swagger](https://marcgibbons.com/django-rest-swagger/), which is OK... but some of my API endpoints have optional GET arguments and I can't see any way to document those in a nice way. I can mention them in comments on my DRF Views, but I thought there'd be a way to format them nicely, maybe have them appear as fields in the Swagger UI, like `lookup_url_kwarg`s do.
I'm going round in circles, reading the DRF [Documenting your API documentation](http://www.django-rest-framework.org/topics/documenting-your-api/), all the third-party tools they mention there, laborious workarounds like [this](https://github.com/m-haziq/django-rest-swagger-docs#advance-usage)...
Does anyone have a good, thorough example of how to nicely document a DRF API?
/r/django
https://redd.it/8b9kjo
I'm using DRF for the first time to create a read-only API. It all works fine, but I'm trying to work out how to automatically generate some documentation for it.
I've got a Swagger UI page up and running using [django-rest-swagger](https://marcgibbons.com/django-rest-swagger/), which is OK... but some of my API endpoints have optional GET arguments and I can't see any way to document those in a nice way. I can mention them in comments on my DRF Views, but I thought there'd be a way to format them nicely, maybe have them appear as fields in the Swagger UI, like `lookup_url_kwarg`s do.
I'm going round in circles, reading the DRF [Documenting your API documentation](http://www.django-rest-framework.org/topics/documenting-your-api/), all the third-party tools they mention there, laborious workarounds like [this](https://github.com/m-haziq/django-rest-swagger-docs#advance-usage)...
Does anyone have a good, thorough example of how to nicely document a DRF API?
/r/django
https://redd.it/8b9kjo
Marcgibbons
Django REST Swagger
Swagger UI / OpenAPI Documentation for Django REST Framework
JupyterCon 2018: Registration Open
https://blog.jupyter.org/jupytercon-2018-registration-open-3b52abba9cce
/r/IPython
https://redd.it/8bhraz
https://blog.jupyter.org/jupytercon-2018-registration-open-3b52abba9cce
/r/IPython
https://redd.it/8bhraz
Jupyter Blog
JupyterCon 2018: Registration Open
Dear Jupyter Community,
Adding multiple images to Django Post
https://youtu.be/jjdeOp_E7OU
/r/djangolearning
https://redd.it/8bgwgz
https://youtu.be/jjdeOp_E7OU
/r/djangolearning
https://redd.it/8bgwgz
YouTube
Learn Django - The Easy Way | Adding Multiple Images using Model Formsets | Tutorial - 39
In this video lecture, we will allow the user to upload multiple images in post detail view using Model Formsets.
Find the links below to connect with me:
linkedin Profile: https://www.linkedin.com/in/abhishekvrm444
Facebook Page: https://www.facebook.com/Learn…
Find the links below to connect with me:
linkedin Profile: https://www.linkedin.com/in/abhishekvrm444
Facebook Page: https://www.facebook.com/Learn…
How to properly implement a button to change state.
In a project I'm working on I'd like to have a button that would change an object's state from one to another
For example
`MyObject.approved = True`
Right now I'm using a button wrapped inside form tags with a csrf_token tag, is this the way to do it or is there another one?
/r/djangolearning
https://redd.it/8biczy
In a project I'm working on I'd like to have a button that would change an object's state from one to another
For example
`MyObject.approved = True`
Right now I'm using a button wrapped inside form tags with a csrf_token tag, is this the way to do it or is there another one?
/r/djangolearning
https://redd.it/8biczy
reddit
How to properly implement a button to change state. • r/djangolearning
In a project I'm working on I'd like to have a button that would change an object's state from one to another For example `MyObject.approved =...
(x-posting from r/djangolearning): Fighting with AJAX [QUESTION]
https://www.reddit.com/r/djangolearning/comments/8bhs6p/fighting_with_ajax/
/r/django
https://redd.it/8bhva3
https://www.reddit.com/r/djangolearning/comments/8bhs6p/fighting_with_ajax/
/r/django
https://redd.it/8bhva3
reddit
Fighting with AJAX • r/djangolearning
I'm working on using AJAX to allow for file uploads to my website. I don't necessarily need even a direct solution (though that would certainly be...
How does Jupyter find modules?
I'm trying to troubleshoot an issue where my Jupyter Notebook can't find an installed module, but documentation on this is sparse. How do I specify where any given instance of Jupyter Notebook looks for modules?
A possibly related question: When I use `jupyter --path`, I see a listing of directories under the "data" heading. Is this where Jupyter looks for modules, and if so, what file do I edit to change it?
/r/IPython
https://redd.it/8biqq7
I'm trying to troubleshoot an issue where my Jupyter Notebook can't find an installed module, but documentation on this is sparse. How do I specify where any given instance of Jupyter Notebook looks for modules?
A possibly related question: When I use `jupyter --path`, I see a listing of directories under the "data" heading. Is this where Jupyter looks for modules, and if so, what file do I edit to change it?
/r/IPython
https://redd.it/8biqq7
reddit
How does Jupyter find modules? • r/IPython
I'm trying to troubleshoot an issue where my Jupyter Notebook can't find an installed module, but documentation on this is sparse. How do I...
Jupyter background data storage is confusing
For example:
> from abc import xyz as 123 # creates alias 123 for xyz
Then I delete the code above, replace it with the code below and rerun the cell.
> from abc import xyz
Nonetheless, alias 123 remains functional as it stored in memory and is only erased if you restart the kernel.
This leads to confusion (or forces you to keep track of more things) when you run the code after making edits - some errors are not raised because their dependencies (such as 123) are stored an remain accessible.
Also, all variables (even those defined within a function) are global.
My intuition is that these differences (from normal ide coding environment) will result in confusion and I want to turn of this feature; however, it might be the case that I am misusing Jupyter and these features are in fact advantageous. If so, can you please educate me?
Thank you very much
Edit: formating
/r/IPython
https://redd.it/8blldv
For example:
> from abc import xyz as 123 # creates alias 123 for xyz
Then I delete the code above, replace it with the code below and rerun the cell.
> from abc import xyz
Nonetheless, alias 123 remains functional as it stored in memory and is only erased if you restart the kernel.
This leads to confusion (or forces you to keep track of more things) when you run the code after making edits - some errors are not raised because their dependencies (such as 123) are stored an remain accessible.
Also, all variables (even those defined within a function) are global.
My intuition is that these differences (from normal ide coding environment) will result in confusion and I want to turn of this feature; however, it might be the case that I am misusing Jupyter and these features are in fact advantageous. If so, can you please educate me?
Thank you very much
Edit: formating
/r/IPython
https://redd.it/8blldv
reddit
Jupyter background data storage is confusing • r/IPython
For example: > from abc import xyz as 123 # creates alias 123 for xyz Then I delete the code above, replace it with the code below and rerun...