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
Chrome Extension for scheduling Jupyter Notebooks

We're currently developing a [Chrome Extension](https://chrome.google.com/webstore/detail/seekwell/mefkdbekccdbdihhondepjimindlbpfg) for Jupyter Notebooks that includes:

- Scheduling (e.g. automatically run a notebook daily, hourly, or every 5 minutes)
- Tight integrations with Google Sheets and Slack (e.g. automatically send DataFrames to Google Sheets to share with non-technical teammates)
- Collaboration features (e.g. share code amongst your team)
- A dark theme

We're looking for beta users to help test and shape the product. The first version is live on the [Web Store](https://chrome.google.com/webstore/detail/seekwell/mefkdbekccdbdihhondepjimindlbpfg), so please give it a shot and let me know if you run into any problems or have any suggestions to make it better!

A little more on scheduling:

1. Open the extension while on the Notebook you want scheduled
2. Select your interval (e.g. daily, hourly, etc.)
3. Save the schedule

This notebook will now run on a Google Cloud Compute Engine at your set interval. The engine image is one of Google's [Deep Learning VM's](https://cloud.google.com/deep-learning-vm/docs/images), which comes with many popular Python packages, but if you need another package, please let me know! I'm keeping a running list of the most requested packages and will add them this weekend.

/r/JupyterNotebooks
https://redd.it/bch98s
[D] PyTorch implementation best practices

Hi r/MachineLearning! Let's discuss PyTorch best practices.


I recently finished a PyTorch [**re-implementation**](https://github.com/joel-huang/zeroshot-capsnet-pytorch) (with help from various sources) for the paper [Zero-shot User Intent Detection via Capsule Neural Networks](https://arxiv.org/abs/1809.00385), which originally had Python 2 code for TensorFlow.


I'd like to request perhaps a critique on the code I've written so far (it's not perfect, yet!) and any suggestions if there are best practices specifically in PyTorch, for implementing directly from research papers as well as converting them from other frameworks.


Some thoughts I had while programming (feel free to raise more!):

1. I've been implementing a Dataset class and custom batch functions for every dataset I've been working with. Is this the PyTorch best practice?

2. Where is the optimal place to shift `Tensors` to `.cuda()`? I've been doing this in the training loop, just before feeding it into the model.

3. How to manage the use of both `numpy` and `torch`, seeing as PyTorch aims to reinvent many of the basic operations in `numpy`?


If you're a fellow PyTorch user/contributor please share a little!

/r/MachineLearning
https://redd.it/bcfyo2
I'm on a windows machine, I want flask to serve HTTPS, I don't want "we don't trust this website" whenever I browse to my app. What do I do to fix this?

I know it's because I'm using self-signed certs, but I don't see a way to use Let'sEncrypt / Certbot on windows. So, as a windows python user, is there a way to have Flask serve HTTPS without raising flags on the browser?

/r/flask
https://redd.it/bchuay
Serving files using Flask

I am currently trying to server a few static files using the following code, however no files seem to be hosted by the site, any ideas on what I'm doing wrong?

​

​

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

All help is appreciated!

/r/flask
https://redd.it/bcjm9c
Linux Python devs, what distro do you use and why?

I am curious what others are using and why? So far I have been using CentOS, because it is the default (mandatory) one in my organisation.

/r/Python
https://redd.it/bcn90f
Is Django a popular choice for real-time applications like messaging apps?

Is Django with Channels a popular choice for real-time apps? I'm curious about building a messaging app and I'm wondering if Django is a good choice, compared to Node or Go.

/r/django
https://redd.it/bcm6gs
Real world projects recommendation for go to next level

I have some background in django: drf basics, models, forms etc etc. But my projects are just cruds and basic things, such as requests lib to call github apis and view some data about repos, wagtail for basic cms, such as site for articles.

But in the projects could have more complex things, such as: get the posta with more comments in the week, learn pillow to image manipulation etc.

but I do not know much more to learn than this, and I want something that is more than four or five lines of a slightly more complex queryset.

I try learn react for learn about auth with api in the front end, but js and react is not easy, and by fact that i'm not proficient in back-end, i'm learning more about django, python (i will read the fluent python in the next week too), and i need finish the sql/postsgres book and maybe learn mongodb. After some months, i will learn js using ydkjs books (really learn) .

I read about some companies looking for "backoffice", but I'm not quite sure what that is and how to build it. I also saw a vacancy needing to create a website

/r/django
https://redd.it/bcnj2u
Flask mobile friendly web app

Hi:)
Noob here.
I would like to know if its easy to trasnform a web app made with flask in a mobile friendly form...

What should I look for ?

/r/flask
https://redd.it/bcq26b
Scientific programming recommendations

Hello, does anyone have any book recommendations for learning scientific programming?

I've automated the very little I could at work with Python and now I want advance a bit further

​

Thanks!

​

p.s. I have a background in physics so anything related would be ideal.

/r/Python
https://redd.it/bcp2oe
Feedback requested: I released my first Python package to pypi. It makes reading and managing config files convenient.

[https://pypi.org/project/gconf/](https://pypi.org/project/gconf/)

It is a very small package, just 330 LoC, including tests. But I use it in almost all of my other projects because it makes using config files just a no-brainer. Currently only yaml-files are supported.

A few weeks ago, I decided to make it public.

Please let me know what you think and if you see ways to improve it! Thanks and have a great weekend.

/r/Python
https://redd.it/bcqnpb
Storing Data / Object State Between URL's in a User Session

I am working to make a machine learning model / simulation web app, but am still pretty new to Flask. The model and simulation is a multi-step process and I'm struggling with the best way to handle data sharing across different url's within a user session. The workflow consists of:

​

* route(/index): User enters basic inputs into a webform
* These inputs are combined with a database table (every session will use the same data here), a quick model is trained, and a custom dataset for the current user's simulation is returned.
* The user is also automatically redirected to route(/simulation)
* This step requires \~10-15 seconds
* The returned custom dataset is \~25MB

​

* route(/simulation): User enters different parameters into a new webform, which are combined with the custom dataset generated from the previous step and a simulation is run that returns the final result
* This process should be iterative. The webform input parameters will be constantly updated, but the custom dataset generated in the first step will stay constant.
* This process should be as fast as possible. The simulation itself takes 1-2 seconds if the custom

/r/flask
https://redd.it/bcx6uj
[Ask Flask] Background update of a global dictionary shared between requests

I need to update a configuration dictionary of service (uri) lookups (< 1k entries) in the background of a flask app.
What’s the most lightweight way to achieve this?

I would like to keep everything in process and I don’t want to make another network request to something external.

It doesn’t matter if a dirty read is performed from the dictionary as the app is fault tolerant and will retry.

/r/flask
https://redd.it/bcxr3f
Formset: Saving Unchanged data

Formsets only pass changed fields via request.post to the post form.
There are fields in the form which are not changed but I want to post to a model.
These are new posts to a model and not changes to existing data.

For example:

Class Name(models.Model):
first_name = models.CharField(max_length=25)
last_name = models.CharField(max_length=25)

class NameForm(ModelForm):
class Meta:
model = Name
fields = '__all__'

if the first name is changed but not the last name; Only the first_name will be passed as last_name was not changed.

Given this, the form will not save because it is not valid; it is missing the last_name.

I believe setting 'has_changed' = True for all form fields will work but I am unsure how to do this.

So how do I get all the form data so it will be valid?

Thanks

/r/django
https://redd.it/bcwvn4
How to implement Django query filter using with AND

I'm trying to find a more efficient way to retrieve data from the database. My scenario is that I want to get a bunch of posts from the Post model based on the condition that the post must have a particular tag and that the post belongs to a person I follow and if the post belongs to such a person I shoud only get their public posts. Along with that, I want all of my posts too for that tag and if they are my posts, then I should get all public and private posts. Currently, I've come up with this Post.objects.filter(tags\_\_field = tag, owner\_id\_\_in= user\_ids, privacy\_setting\_\_in= privacy\_options) How can I use the and condition to get the result I want?

/r/django
https://redd.it/bcyf6h
I converted MIT’s OpenCourseWare ”learn python course” to a layout which views better on all devices

I had been working on a project to give more depth to a YouTube playlist by allowing other media such as documents and sites all from the web. It morphed into this and one of my first personal projects using it was with MIT’s OpenCourseWare site. It just groups the URL’s and streams them from the creator.

First is my version of the Python course

[My version - introduction to python programming](https://collectyv.com/Course/saaaaaaab)

And now, MIT’s version.

[MIT’s version - Python Programming Course ](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and-programming-in-python-fall-2016/)

/r/Python
https://redd.it/bcxtwm
Created a webapp that displays the bond-line structure of any chemical compound/molecule.

/r/Python
https://redd.it/bd355n