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
This media is not supported in your browser
VIEW IN TELEGRAM
First Program / GUI EVER! (Follow Up Video) | This is a continuation from last week where I posted my flooring calculator CLI program that everyone was so supportive of. Just wanted to let everyone know I have made a GUI for it. Not quite finished but it works flawlessly! :D

/r/Python
https://redd.it/aup5bi
Simple Flask Apps (no db)

I'm teaching a Flask course at the moment, and the requirements are that students do *not* use a database (introduced next unit). There's no flexibility around this requirement.

​

What are some ideas for apps that students can create? Here are a couple I've come up with:

* Madlibs
* Coin toss
* Random numbers
* Random student from list
* Tax calculator
* Home loan repayment calculator

​

Some simple APIs that they've experimented with:

* Chuck Norris
* ISS

/r/flask
https://redd.it/aus1jh
Trouble rendering wtform validator error

With the below I have a simple form with a text input box. I have set the `InputRequired()` validator on `SignUpForm`; however when I run localhost I don't get the validator message "Wrong value" if no input is supplied when I push the submit button.

​

from flask import Flask, request, render_template, redirect, url_for
from . import forms

app = Flask(__name__)
app.secret_key = "Shhhhh!"

@app.route('/', methods=['GET', 'POST'])
def index():
form = forms.SignUpForm()
if form.validate_on_submit():
return redirect(url_for('forward'))
return render_template('index.html', form=form)

@app.route('/forward', methods=['POST'])
def forword():
if request.method == 'POST':
return render_template('forward.html')

​

from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField
from wtforms.validators import InputRequired, Email


/r/flask
https://redd.it/auucc8
[R] AdaBound: An optimizer that trains as fast as Adam and as good as SGD (ICLR 2019), with A PyTorch Implementation

Hi! I am an undergrad doing research in the field of ML/DL/NLP. This is my first time to write a post on Reddit. :D

We developed a new optimizer called **AdaBound**, hoping to achieve a faster training speed as well as better performance on unseen data. Our paper, *Adaptive Gradient Methods with Dynamic Bound of Learning Rate*, has been accepted by ICLR 2019 and we just updated the camera ready version on open review.

I am very excited that a PyTorch implementation of AdaBound is publicly available now, and a PyPI package has been released as well. You may install and try AdaBound easily via `pip` or directly copying & pasting. I also wrote a post to introduce this lovely new optimizer.

​

Here's some quick links:

**Website:** [https://www.luolc.com/publications/adabound/](https://www.luolc.com/publications/adabound/)

**GitHub:** [https://github.com/Luolc/AdaBound](https://github.com/Luolc/AdaBound)

**Open Review:** [https://openreview.net/forum?id=Bkg3g2R9FX](https://openreview.net/forum?id=Bkg3g2R9FX)

**Abstract:**

Adaptive optimization methods such as AdaGrad, RMSprop and Adam have been proposed to achieve a rapid training process with an element-wise scaling term on learning rates. Though prevailing, they are observed to generalize poorly compared with SGD or even fail to converge due to unstable and extreme learning rates. Recent work has put forward some algorithms such as AMSGrad to tackle this issue but they failed to achieve considerable improvement over existing methods. In

/r/MachineLearning
https://redd.it/auvj3q
Just created my first web app using Flask and have a noob question

First off, Flask is really awesome. I’ve been programming for about 4 months now, and building this application was really cool, challenging, and sort of inspiring. The question I have is: is it possible to create the web server on say a Raspberry Pi, and then access it remotely from another machine? If so where would I look to learn how to do this?

/r/flask
https://redd.it/auipte
Trouble with creating Dynamic forms

I am trying to create an application that displays a list of various questions.

Each question response in the list should be one of the following:

1. StringField()
2. SelectField()

The questions are dynamically generated from a database.

I am having trouble dynamically creating these form fields.

/r/flask
https://redd.it/auqmg5
creating event model with recurring dates

hello.

im working on a project where users can list their events. In each event, it could either be a one-day event or a recurring event. How can I implement this application?

I've looked at other packages like django-scheduling, django-recurrence, and django-eventtools, but I don't know if they are compatible with Django 2.1.

It would be cool if anyone have any experience with these packages, and know if they are up to date with the current django version.

I am also willing to implement my own version of this system, but I do not know where to start.

thank you.

Edit: With this recurring events, is it possible to search for them based on date ranges

/r/djangolearning
https://redd.it/aujbg2
This media is not supported in your browser
VIEW IN TELEGRAM
Django Jet admin interface 2.0 is now compatible with any stack with SQL database

/r/django
https://redd.it/av0dlp
The Django Packages site needs a redesign ASAP

I hope i'm not the only one who really hate browsing it. Its really a bad showcase for the framework (let alone a web framework) when you can't even search packages on mobile. The comparison tables are also not responsive on mobile.

I'd really wish it had a better design. Take Laravel for example: [https://packalyst.com/](https://packalyst.com/)

​

Sorry, just had to get it out. lol.

​

​

​

/r/django
https://redd.it/auy8kl
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/auzuns
How to create choices based on file contents

I have a json object, where I would like each of the entries in the json file to be options choosable by the user, such that the user can select multiple options and those choices can be saved somewhere, can someone point me in the right direction?

Thanks

/r/django
https://redd.it/av2kjc
Build a Data Analysis Library from Scratch in Python

Hey All,

[Build a Data Analysis Library from Scratch in Python](https://www.youtube.com/playlist?list=PLVyhfExBT1XDTu-oocI3ttl_OPhulAJOp) is a course I've developed to help those looking for a long, comprehensive project that will teach advanced Python and basic software development. It seems that there is a lack of these types of projects for those who possess the fundamentals of Python, but haven't put together a complete project.

The end result is a library called Pandas Cub which is built to mimic the pandas library. There are 40 steps with nearly 100 pre-written unit tests that must be passed in order to complete the project. The project not only teaches advanced Python but environment setup, test-driven development, and developing code outside of a Jupyter Notebook. The project can also be [found on GitHub](https://github.com/tdpetrou/pandas_cub).

I hope its useful and if you have critical feedback please let me know.

/r/Python
https://redd.it/av0awc
Geodjango OSMWidget coordinates are wrong.

I'm using an OSMWidget for my PointField(). I had already set my initial coordinates to 120, 14 but when I retrieve the values from my widget I get values around 13468873 and 1639089.

Also I am not saving any (spatial?) objects to my db because I want to stick to one db but I do need the coordinates as Decimal values to measure distances in the future.

Is there a way to convert widget values into standard coordinates?

/r/django
https://redd.it/av86my
[Django + javascript] Sending Post (submit) after given time

Hello r/django \- I am very new to django and javascript so I would appreciate any comments!

I am building a website where users can take math exams for free. The way my website works is very simple - a user writes down an answer (or chooses from a radio button) and clicks on the next button for the next question. Clicking on the next button also sends a POST request to my django views where I save the user's answer in my database.

Everything was working fine until I added a timer in javascript (when the exam time is over, the user is directed to the home page). Since the 'next' button was never clicked, the answer to the last question the user was working on is not saved. I would like to figure out a way to have my javascript code send a POST request to my django views when the timer is over.

​

I would appreciate any help. Thank you!

/r/django
https://redd.it/avb7r1
Intercooler.js vs Stimulus.js vs Vue.js in Django

I'm mainly working on websites that have **little to to medium** interactions with the user, and i'm looking for ways to add JS to my sites without complicating things. SPA are out of the question since the sites needs to be SEO friendly. When i say interactions i mean stuff like upvote / downvote events, adding interactive tables and charts, popups with dynamic content and stuff like that.

​

* **Intercooler.js** \- Seems like the best candidate for Django at the moment but it feels incomplete.
* **Stimulus.js** \- Also seems nice, but it lacks a proper documentation with good examples. It also looks like its mostly meant for Ruby on Rails (?).
* **Vue.js** \- Is really clean and simple, but it seems like including it in Django templates can get messy for larger projects.
* **Nuxt.js** \- Is probably the best solution overall but it has a full separation of backed and fronted. This one requires a full dedication because i need to master both vue.js and nuxt.js to properly use it.

​

Besides pure JS, what do you guys use for this kind of projects?

​

​

/r/django
https://redd.it/avbv0p
Data getting reset on a singleton model

So I'm using a singleton class to save settings like google analytics id, keys related to third party services etc and other data that are static but may need to be updated via frontend.

But apparently, the data is getting reset almost every 2 weeks.

This is my mode

from django.db import models
from django.core.cache import cache

class SingletonModel(models.Model):

class Meta:
abstract = True

def set_cache(self):
cache.set(self.__class__.__name__, self)

def save(self, *args, **kwargs):
self.pk = 1
super(SingletonModel, self).save(*args, **kwargs)
self.set_cache()

def delete(self, *args, **kwargs):
pass

@classmethod
def load(cls):


/r/django
https://redd.it/avazuz