Undeclared variable with "dictionary" syntax does not throw exception
I spent the last half hour debugging my script where I typed ":" instead of "=" when trying to update a variable.
So why does
a: "10"
not throw an exception? Even when ``a`` is not defined prior to this?
/r/Python
https://redd.it/8gx5dc
I spent the last half hour debugging my script where I typed ":" instead of "=" when trying to update a variable.
So why does
a: "10"
not throw an exception? Even when ``a`` is not defined prior to this?
/r/Python
https://redd.it/8gx5dc
reddit
Undeclared variable with "dictionary" syntax does not... • r/Python
I spent the last half hour debugging my script where I typed ":" instead of "=" when trying to update a variable. So why does a: "10" not...
Hello Qt for Python - Qt Blog
http://blog.qt.io/blog/2018/05/04/hello-qt-for-python/
/r/Python
https://redd.it/8gylqd
http://blog.qt.io/blog/2018/05/04/hello-qt-for-python/
/r/Python
https://redd.it/8gylqd
www.qt.io
Hello Qt for Python
Crypto trading bot think-tank: what indicators do you use?
I've been working on a python based trading bot using the GDAX api and have come pretty far. My ideas are working well, but still in the baby stages of testing. This thread is simply to see if there are others who are doing this who would like to pool statistics and indicator techniques.
I'm not talking so much about sharing our entire scripts but discussing what styles of analysis you have found useful, if any?
/r/pystats
https://redd.it/8h085p
I've been working on a python based trading bot using the GDAX api and have come pretty far. My ideas are working well, but still in the baby stages of testing. This thread is simply to see if there are others who are doing this who would like to pool statistics and indicator techniques.
I'm not talking so much about sharing our entire scripts but discussing what styles of analysis you have found useful, if any?
/r/pystats
https://redd.it/8h085p
reddit
Crypto trading bot think-tank: what indicators do you use? • r/pystats
I've been working on a python based trading bot using the GDAX api and have come pretty far. My ideas are working well, but still in the baby...
Hyperparameters tuning with Polyaxon
https://medium.com/polyaxon/hyperparameters-tuning-with-polyaxon-9403f8ea85be
/r/Python
https://redd.it/8gztcf
https://medium.com/polyaxon/hyperparameters-tuning-with-polyaxon-9403f8ea85be
/r/Python
https://redd.it/8gztcf
Medium
Hyperparameters tuning on Kubernetes with Polyaxon
hyperparameters tuning is very important concept in order to choose the optimal hyperparameters for a given algorithm, it is crucial for…
[AF] How to properly test view functions?
So I have this view function:
@app.route('/submit', methods=['GET', 'POST'])
@login_required
def submit():
"""View function for the submit site, which contains a standard
form. Creates initial variables for mutable variables like
upvotes, downvotes and importance, to avoid any TypeErrors."""
form = SubmitForm()
if form.validate_on_submit():
post = Post(title=form.title.data, text=form.text.data, user_id=current_user.id, topics=[Topic(tag_name=form.topics.data)])
post.upvotes = 1
post.downvotes = 0
post.importance = 1
post.score = post.get_score()
db.session.add(post)
db.session.commit()
flash('You have now made a post!')
return redirect(url_for('index'))
return render_template('submit.html', title='Submit', form=form)
How would I properly test this works?
The testing function I'm using is this:
def test_submit(self):
"""Tests to see whether the /submit route will work"""
self.post = Post(title="Title", text="Text", user_id=1, topics=[Topic(tag_name="topic1"), Topic(tag_name="topic2")])
self.post.upvotes = 1
self.post.downvotes = 0
self.post.importance = 1
self.post.score = self.post.get_score()
db.session.add(self.post)
db.session.commit()
self.assertTrue(Post.query.filter_by(text="Text").first())
self.assertFalse(Post.query.filter_by(text="Not me").first())
I know this isn't the proper way of doing things, so how should I do it?
Here is the rest of my testing file, if needed:
https://github.com/ModoUnreal/dopenet/blob/master/tests/test_posts.py
/r/flask
https://redd.it/8h19nu
So I have this view function:
@app.route('/submit', methods=['GET', 'POST'])
@login_required
def submit():
"""View function for the submit site, which contains a standard
form. Creates initial variables for mutable variables like
upvotes, downvotes and importance, to avoid any TypeErrors."""
form = SubmitForm()
if form.validate_on_submit():
post = Post(title=form.title.data, text=form.text.data, user_id=current_user.id, topics=[Topic(tag_name=form.topics.data)])
post.upvotes = 1
post.downvotes = 0
post.importance = 1
post.score = post.get_score()
db.session.add(post)
db.session.commit()
flash('You have now made a post!')
return redirect(url_for('index'))
return render_template('submit.html', title='Submit', form=form)
How would I properly test this works?
The testing function I'm using is this:
def test_submit(self):
"""Tests to see whether the /submit route will work"""
self.post = Post(title="Title", text="Text", user_id=1, topics=[Topic(tag_name="topic1"), Topic(tag_name="topic2")])
self.post.upvotes = 1
self.post.downvotes = 0
self.post.importance = 1
self.post.score = self.post.get_score()
db.session.add(self.post)
db.session.commit()
self.assertTrue(Post.query.filter_by(text="Text").first())
self.assertFalse(Post.query.filter_by(text="Not me").first())
I know this isn't the proper way of doing things, so how should I do it?
Here is the rest of my testing file, if needed:
https://github.com/ModoUnreal/dopenet/blob/master/tests/test_posts.py
/r/flask
https://redd.it/8h19nu
GitHub
ModoUnreal/dopenet
dopenet - The ideal template to make websites in 2018!!!! (I'm kidding of course)
[AF] How do I send data route to route, in order to maintain a dynamic form?
This question is probably not asked correctly. I'll try to explain better below. I am also new to python and flask.
I am creating a flask web interface for a simple inventory system we have. I'm trying to have the following interaction:
USER: <Inputs part number into appropriate field>
SERVER: <Checks to see if on file>
if on file
SERVER: "Place bin on scale."
USER: <Places bin on scale>
*SCALE: <Weighs item and sends value to server>
*My issue
Here is my issue: the scale data sent is not within scope of the "inventory" route. Is there a better way to go about this?
**My Direction:**
I want the user to have the form readily available for another form input if necessary. I also want to print the new data with some data pulled from the database after the item is weighed.
**app/routes.py**
from flask import render_template, flash, redirect, url_for, request, jsonify
from app import app, db
from app.forms import LoginForm, RegistrationForm, PrintLabelForm, \
InventoryForm1, InventoryForm2
from flask_login import current_user, login_user, logout_user, login_required
from app.models import *
import scale as s
@app.route('/inventory', methods=['GET', 'POST'])
@login_required
def inventory():
form = InventoryForm1()
# if form.validate_on_submit(): # Checks form submission syntax validity
if "submit" in request.form: # Checks form submission syntax validity
item = Items.query.filter_by(ItemCode=form.itemCode.data).first()
measurement = Measurements.query.filter_by(partNumber=form.itemCode.data).first()
# Checks if part number field is correct
if item is None: # No input for the field
flash('Item not on file.')
return redirect(url_for('inventory'))
elif measurement is None: # No current measurements available
flash('No previous measurements found for, ' + item.ItemCodeDesc + '.')
flash('Place empty container on scale.')
# while container is not containerChange and keyboardIdle:
# await item data input
else: # Generate Item Report
flash('Place bin on scale.')
# User clicks "Weigh Item"
return render_template('inventory.html', title='Inventory', form=form)
@app.route('/weighItem', methods=['GET', 'POST'])
@login_required
def weighItem():
weight = s.runScale("getWeight", 0)
return jsonify(weight=weight)
**app/templates/base.html**
<script>
function weighItem() {
$.post('/weighItem', {
}).done(function(response) {
$("#result").text(response.weight);
alert(response.weight);
}).fail(function() {
$.text("Error: Could not contact server.");
});
}
</script>
**app/templates/inventory.html**
{% extends "base.html" %}
{% import 'bootstrap/wtf.html' as wtf %}
{% block app_content %}
<h1>Inventory</h1>
<div class="row">
<div class="col-md-4">
{{ wtf.quick_form(form) }}
<a href="javascript:weighItem()" id="weighItem">Weigh Item</a>
<p id="result"> </p>
</div>
</div>
{% endblock %}
**Some Notes:**
I am using the [https://github.com/tatobari/hx711py](https://github.com/tatobari/hx711py) for a scale.
/r/flask
https://redd.it/8h0ur9
This question is probably not asked correctly. I'll try to explain better below. I am also new to python and flask.
I am creating a flask web interface for a simple inventory system we have. I'm trying to have the following interaction:
USER: <Inputs part number into appropriate field>
SERVER: <Checks to see if on file>
if on file
SERVER: "Place bin on scale."
USER: <Places bin on scale>
*SCALE: <Weighs item and sends value to server>
*My issue
Here is my issue: the scale data sent is not within scope of the "inventory" route. Is there a better way to go about this?
**My Direction:**
I want the user to have the form readily available for another form input if necessary. I also want to print the new data with some data pulled from the database after the item is weighed.
**app/routes.py**
from flask import render_template, flash, redirect, url_for, request, jsonify
from app import app, db
from app.forms import LoginForm, RegistrationForm, PrintLabelForm, \
InventoryForm1, InventoryForm2
from flask_login import current_user, login_user, logout_user, login_required
from app.models import *
import scale as s
@app.route('/inventory', methods=['GET', 'POST'])
@login_required
def inventory():
form = InventoryForm1()
# if form.validate_on_submit(): # Checks form submission syntax validity
if "submit" in request.form: # Checks form submission syntax validity
item = Items.query.filter_by(ItemCode=form.itemCode.data).first()
measurement = Measurements.query.filter_by(partNumber=form.itemCode.data).first()
# Checks if part number field is correct
if item is None: # No input for the field
flash('Item not on file.')
return redirect(url_for('inventory'))
elif measurement is None: # No current measurements available
flash('No previous measurements found for, ' + item.ItemCodeDesc + '.')
flash('Place empty container on scale.')
# while container is not containerChange and keyboardIdle:
# await item data input
else: # Generate Item Report
flash('Place bin on scale.')
# User clicks "Weigh Item"
return render_template('inventory.html', title='Inventory', form=form)
@app.route('/weighItem', methods=['GET', 'POST'])
@login_required
def weighItem():
weight = s.runScale("getWeight", 0)
return jsonify(weight=weight)
**app/templates/base.html**
<script>
function weighItem() {
$.post('/weighItem', {
}).done(function(response) {
$("#result").text(response.weight);
alert(response.weight);
}).fail(function() {
$.text("Error: Could not contact server.");
});
}
</script>
**app/templates/inventory.html**
{% extends "base.html" %}
{% import 'bootstrap/wtf.html' as wtf %}
{% block app_content %}
<h1>Inventory</h1>
<div class="row">
<div class="col-md-4">
{{ wtf.quick_form(form) }}
<a href="javascript:weighItem()" id="weighItem">Weigh Item</a>
<p id="result"> </p>
</div>
</div>
{% endblock %}
**Some Notes:**
I am using the [https://github.com/tatobari/hx711py](https://github.com/tatobari/hx711py) for a scale.
/r/flask
https://redd.it/8h0ur9
GitHub
GitHub - tatobari/hx711py: HX711 Python Library for Raspberry Pi.
HX711 Python Library for Raspberry Pi. Contribute to tatobari/hx711py development by creating an account on GitHub.
[P] Prototype of 3D Hand Pose and Gesture Tracking on a Monocular Mobile Device (Keras + Core ML)
https://www.youtube.com/watch?v=y__pYj9UHfc&feature=youtu.be
/r/MachineLearning
https://redd.it/8h1lfs
https://www.youtube.com/watch?v=y__pYj9UHfc&feature=youtu.be
/r/MachineLearning
https://redd.it/8h1lfs
YouTube
3D Hand Pose and Gesture Tracking on a Monocular Mobile Device
Early prototype of tracking hand gestures in 3D using an iPhone 8, Keras, TensorFlow, CoreML, and synthetic training data.
django-bootstrap-datepicker-plus: Django Widget for bootstrap-datepicker for Django version 1.8, 1.10, 1.11 and 2.0.4.
I have published a date\-picker widget [django\-bootstrap\-datepicker\-plus](https://github.com/monim67/django-bootstrap-datepicker-plus) for `django` to support latest version keeping backward compatibility up to`djang`o version 1.8. Please let me know what you think of it. Any suggestion is highly appreciated and is what I am looking for.
/r/django
https://redd.it/8gza32
I have published a date\-picker widget [django\-bootstrap\-datepicker\-plus](https://github.com/monim67/django-bootstrap-datepicker-plus) for `django` to support latest version keeping backward compatibility up to`djang`o version 1.8. Please let me know what you think of it. Any suggestion is highly appreciated and is what I am looking for.
/r/django
https://redd.it/8gza32
GitHub
GitHub - monim67/django-bootstrap-datepicker-plus: Bootstrap3/Bootstrap4/Bootstrap5 DatePickerInput, TimePickerInput, DateTimePickerInput…
Bootstrap3/Bootstrap4/Bootstrap5 DatePickerInput, TimePickerInput, DateTimePickerInput, MonthPickerInput, YearPickerInput with date-range-picker functionality for django >= 2.0 - monim67/dja...
Storing millions and billions of URLs?
Hello Everyone!
Currently, using ElasticSearch for storing the meta data and other raw data information but it is a very small scale around 500,000 domains.
I have been tasked to scale it to 20-40 million domains and storing their internal/external links while building a page rank/domain authority score for each domain which we are adding to our database.
What do you guys suggest/recommend for storing this data at a very large scale as web page internal links/external links will be stored which will lead it over 100M-1B links database?
Any kind of feedback/suggestion would be appreciated.
Thanks.
/r/Python
https://redd.it/8h293k
Hello Everyone!
Currently, using ElasticSearch for storing the meta data and other raw data information but it is a very small scale around 500,000 domains.
I have been tasked to scale it to 20-40 million domains and storing their internal/external links while building a page rank/domain authority score for each domain which we are adding to our database.
What do you guys suggest/recommend for storing this data at a very large scale as web page internal links/external links will be stored which will lead it over 100M-1B links database?
Any kind of feedback/suggestion would be appreciated.
Thanks.
/r/Python
https://redd.it/8h293k
reddit
Storing millions and billions of URLs? • r/Python
Hello Everyone! Currently, using ElasticSearch for storing the meta data and other raw data information but it is a very small scale around...
How to make the transition from "python scripter" to "python software developer"?
Hello there. I recently got hired as software developer for some of the skills that I have, but none of those is actually being a good software developer. I'm writing Python code 5+ years now, but never really exposed my code to being reviewed, tested or criticized. The people I work with have not only more experience but their background also entails software development. I try to learn as much as possible from them when I read their Python code, but I want to get on a higher level in terms of coding quality as soon as possible.
Can you give me any tips how I can get there? Whether it is good article, book or a DOs and DONTs cheat-sheet, I don't know, but whatever it is I would appreciate some tips!
/r/Python
https://redd.it/8h2u16
Hello there. I recently got hired as software developer for some of the skills that I have, but none of those is actually being a good software developer. I'm writing Python code 5+ years now, but never really exposed my code to being reviewed, tested or criticized. The people I work with have not only more experience but their background also entails software development. I try to learn as much as possible from them when I read their Python code, but I want to get on a higher level in terms of coding quality as soon as possible.
Can you give me any tips how I can get there? Whether it is good article, book or a DOs and DONTs cheat-sheet, I don't know, but whatever it is I would appreciate some tips!
/r/Python
https://redd.it/8h2u16
reddit
r/Python - How to make the transition from "python scripter" to "python software developer"?
14 votes and 6 so far on reddit
Does anyone know a django app to handle Feature Requests?
I'm looking for something similar to [gog's Community Wishlist](https://www.gog.com/wishlist): users can submit requests for new features and the like, and other users can vote in which features they want the most.
Comments in each request would be appreciated, but aren't necessary.
/r/django
https://redd.it/8h38rj
I'm looking for something similar to [gog's Community Wishlist](https://www.gog.com/wishlist): users can submit requests for new features and the like, and other users can vote in which features they want the most.
Comments in each request would be appreciated, but aren't necessary.
/r/django
https://redd.it/8h38rj
Numpy FFT lots slower than Octave FFT?
After trying Octave and missing Python's features, I've been back to Python / Numpy. But now it's looking like Numpy is significantly slower? Here's the test. Python, about 10 seconds:
import numpy
numpy.fft.fft(numpy.ones(31257584))
Octave, about one second:
sum(fft(ones(1, 31257584)))
I'd rather use Python, but don't have time to wait for it.
/r/Python
https://redd.it/8h23xs
After trying Octave and missing Python's features, I've been back to Python / Numpy. But now it's looking like Numpy is significantly slower? Here's the test. Python, about 10 seconds:
import numpy
numpy.fft.fft(numpy.ones(31257584))
Octave, about one second:
sum(fft(ones(1, 31257584)))
I'd rather use Python, but don't have time to wait for it.
/r/Python
https://redd.it/8h23xs
reddit
r/Python - Numpy FFT lots slower than Octave FFT?
22 votes and 18 so far on reddit
flask restfull handle incorrect urls
I am using the Flask_restful package and I have a question. I have some paths like: /api/users/<int:id>/recepies. Everything works fine until you request this url without the id, like this: /api/users//recepies or /api/users/recepies, then it throws an error. Is there a way to catch this kind of errors?
/r/flask
https://redd.it/8gsqiz
I am using the Flask_restful package and I have a question. I have some paths like: /api/users/<int:id>/recepies. Everything works fine until you request this url without the id, like this: /api/users//recepies or /api/users/recepies, then it throws an error. Is there a way to catch this kind of errors?
/r/flask
https://redd.it/8gsqiz
reddit
r/flask - flask restfull handle incorrect urls
1 votes and 2 so far on reddit
migrating from sqlserver to postgres, issue with sqlserver_ado.fields.BigAutoField
I am trying to change our django from using M/S SQL server to postgres. One of the model fields is defined in the initial migration as sqlserver_ado.fields.BigAutoField(serialize=False, primary_key=True). After changing the database engine to postgres, the field is missing in the postgres database. If I try to migrate it to something like models.BigIntegerField(serialize=False, primary_key=True), I get the error "ValueError: Cannot alter field verosgui.MpWatchlistchange.chan_coun into verosgui.MpWatchlistchange.chan_coun - they do not properly define db_type (are you using PostGIS 1.5 or badly-written custom fields?)". Does anyone know how to migrate this field?
/r/django
https://redd.it/8h2q5c
I am trying to change our django from using M/S SQL server to postgres. One of the model fields is defined in the initial migration as sqlserver_ado.fields.BigAutoField(serialize=False, primary_key=True). After changing the database engine to postgres, the field is missing in the postgres database. If I try to migrate it to something like models.BigIntegerField(serialize=False, primary_key=True), I get the error "ValueError: Cannot alter field verosgui.MpWatchlistchange.chan_coun into verosgui.MpWatchlistchange.chan_coun - they do not properly define db_type (are you using PostGIS 1.5 or badly-written custom fields?)". Does anyone know how to migrate this field?
/r/django
https://redd.it/8h2q5c
reddit
migrating from sqlserver to postgres, issue with... • r/django
I am trying to change our django from using M/S SQL server to postgres. One of the model fields is defined in the initial migration as...
I figured you guys would enjoy this, Humble Bundle put together a nice Python Dev Kit. Happy coding!
https://www.humblebundle.com/software/python-dev-kit-bundle?hmb_source=navbar&hmb_medium=product_tile&hmb_campaign=tile_index_2
/r/Python
https://redd.it/8h5q4g
https://www.humblebundle.com/software/python-dev-kit-bundle?hmb_source=navbar&hmb_medium=product_tile&hmb_campaign=tile_index_2
/r/Python
https://redd.it/8h5q4g
Humble Bundle
Humble Software Bundle: Python Dev Kit
Pay what you want for a bundle of Python resources and support charity!
How to run a task after flask server starts?
Hey guys, I'm trying to run my flask site in a pyqt5 GUI interface however after app.run(), all functions afterward are ignored until I close the server. This results in me getting a 404 from the PyQT interface. Anyone know how to run the flask server and allow a function to run after it? If it is possible, it would actually be better if I could run them at the same time. Thanks guys
**EDIT**: solved this actually
did the following
def pyqt_function():
#thing to be done by pyqt
t = threading.Thread(target=pyqt_function)
t.daemon = True
t.start()
app.run()
/r/flask
https://redd.it/8gs9zq
Hey guys, I'm trying to run my flask site in a pyqt5 GUI interface however after app.run(), all functions afterward are ignored until I close the server. This results in me getting a 404 from the PyQT interface. Anyone know how to run the flask server and allow a function to run after it? If it is possible, it would actually be better if I could run them at the same time. Thanks guys
**EDIT**: solved this actually
did the following
def pyqt_function():
#thing to be done by pyqt
t = threading.Thread(target=pyqt_function)
t.daemon = True
t.start()
app.run()
/r/flask
https://redd.it/8gs9zq
reddit
r/flask - How to run a task after flask server starts?
0 votes and 0 so far on reddit
The first color-accurate Instagram-like filters reconstruction for apps
https://github.com/homm/color-filters-reconstruction#accurate-instagram-filters-reconstruction
/r/Python
https://redd.it/8h6wut
https://github.com/homm/color-filters-reconstruction#accurate-instagram-filters-reconstruction
/r/Python
https://redd.it/8h6wut
GitHub
GitHub - homm/color-filters-reconstruction: Very accurate color filters reconstruction tools based on 3D color LUTs
Very accurate color filters reconstruction tools based on 3D color LUTs - homm/color-filters-reconstruction
Python batch script in Windows
Need to run a python program multiple times with different arguments each time. Coming from Linux I would create a shell script and run a loop calling the python program. What is your preferred way to do this in Windows? Powershell? Open to all suggestions.
/r/Python
https://redd.it/8h7405
Need to run a python program multiple times with different arguments each time. Coming from Linux I would create a shell script and run a loop calling the python program. What is your preferred way to do this in Windows? Powershell? Open to all suggestions.
/r/Python
https://redd.it/8h7405
reddit
r/Python - Python batch script in Windows
1 votes and 0 so far on reddit
[P] Style2PaintsV3 released! Geometric Interactivity, Controllable Shadow Rendering, Better Skin Engine and More.
/r/MachineLearning
https://redd.it/8h2wzn
/r/MachineLearning
https://redd.it/8h2wzn
Build A Social Network With Python Flask Tutorial For Beginners
https://www.youtube.com/watch?v=GjJbaolBPAY
/r/Python
https://redd.it/8h70wv
https://www.youtube.com/watch?v=GjJbaolBPAY
/r/Python
https://redd.it/8h70wv
YouTube
build a social network with python: tutorial for beginners
Awesome to have you here TIME TO CODE 🖥️ 🎧
Join the community on Discord! https://discordapp.com/invite/QZd3aaN
———————————————————————————————————————————————
JOIN THE DEVELOPER COMMUNITY 👬:
———————————————————————————————————————————————
📺 SUBSCRIBE ON…
Join the community on Discord! https://discordapp.com/invite/QZd3aaN
———————————————————————————————————————————————
JOIN THE DEVELOPER COMMUNITY 👬:
———————————————————————————————————————————————
📺 SUBSCRIBE ON…