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
How do you handle dynamic interactions

So I'm building a sass app where my productivity is pretty much my main concern. Since I have extremely limited time server rendered html with Django is my choice. It's going great for me even if I am quite new to the framework.

Problem now is there are a couple cases where I need a bit more interaction. Way back I used to do this with Ruby on Rails with jQuery AJAX where the server returned a small chunk of html that got swapped out on the existing page. I was thinking of doing the same thing again, but I was wondering if anybody has any better solutions or pointers.

I definitely want to minimize JavaScript and absolutely want to avoid adding react and a whole lot of other stuff (state, router, ...) For example. I'm looking for a minimal solution that's quick to develop.

Main use case for me is something like an invoice where the user can add items dynamically. This means some kind of modal pop-up type thing where they can search/filter/sort through items to add the correct one.

Any ideas appreciated!

/r/django
https://redd.it/cfufs9
Flask_debug=1 when running i get this error



does anyone else get this kinda problem,
how to fix it


c:\\python37\\python.exe: No module named C:\\Python37\\Scripts\\flask

/r/flask
https://redd.it/cfabez
I cannot even begin to get %load magic to work without an absolute path.

My personal ‘Scripts’ folder is in both my Path and PYTHONPATH environment variables (Windows), and I can even import files in that directory in Jupyter Lab with no problem.

I’m trying to `%load` a file there called `first_cell.py`. I’ve tried all these variations:

%load first_cell.py
%loadpy first_cell.py
%load first_cell
%loadpy first_cell

I get this error (after a big stack trace):

ValueError: 'first_cell' was not found in history, as a file, url, nor in the user namespace.

or:

ValueError: 'first_cell.py' was not found in history, as a file, url, nor in the user namespace.

Putting the complete absolute path (`%load C:\Users\atimh\Scripts\first_cell.py`) *does* work, but it’s a giant pain. It’s not portable, and it defeats the purpose: it should be something easy to remember and quick to type, else why even do it?

I know I can just run the file, but showing all my preferred imports every time communicates far more clearly what’s going on.

And being forced to stick it in some “special” folder hidden away somewhere is not a good solution. I don’t want to be forced to scatter all my Python scripts to the four winds.

/r/IPython
https://redd.it/cfvgzy
Tried by any possible means to get my first 10 on pylint. Got nuked.

/r/Python
https://redd.it/cfked9
I celebrated the lunar landing anniversary coding up some orbits in the earth moon system. It's surprisingly painless in python! Here's my favorite from the day.

/r/Python
https://redd.it/cfqg16
Need help with how Django does URL reversing

[https://docs.djangoproject.com/en/2.2/topics/http/urls/#reversing-namespaced-urls](https://docs.djangoproject.com/en/2.2/topics/http/urls/#reversing-namespaced-urls)

With the docs that I have linked, *step 1* seems pretty clear cut.

Take the example of `'polls:index'`:

* *First, Django looks for a matching* [*application namespace*](https://docs.djangoproject.com/en/2.2/topics/http/urls/#term-application-namespace) *(in this example, 'polls'). This will yield a list of instances of that application.*

After that I'm unclear on *step 2*. What exactly would be a current application if there is a list of application instances as stated in *step1*?

* *If there is a current application defined*, Django finds and returns the URL resolver for that instance.

/r/djangolearning
https://redd.it/cftt7l
[AF]Can't import views on a new project

So I am just starting a project in flask and I am using the proper folder structure for the first time and I keep getting this error. I am confused as to why and haven't faced this problem before.

I have tried renaming files and using from . import views but to no avail.

app.py

from flask import Flask
from app import views

app = Flask(__name__)



views.py

from app import app

@app.route('/')
def index():
return "Hello World!"



run.py

from app import app
app.run(debug=True)



Folder structure:

app
static
templates
app.py
run.py
views.py

tmp


Traceback (most recent call last):
File "app.py", line 2, in <module>
from app import views
File "/Users/Josh/PycharmProjects/web1/app/app.py", line 2, in <module>
from app import views
ImportError: cannot import name 'views'

/r/flask
https://redd.it/cg2g30
Getting Flask app to work on VPS.

I just got a VPS service to host my flask app on Hostinger.
When I get flask apps running on my local machine, it’s as easy as just doing :
$ python flask_app.py

On my VPS, I can run the same command, but I can’t access the app from outside the server. All instructions online are quite arcane, so I ‘m hoping someone could point me in the right direction!

Context: I used to host my app on Pythonanywhere, but they often have downtimes so I’m forced to look for a more stable option.

/r/flask
https://redd.it/cg52xw
This media is not supported in your browser
VIEW IN TELEGRAM
Annihilating My Friend Will in a Python Fluid Simulation, Like the Cur He Is

/r/Python
https://redd.it/cg6rpf
Implement Vue into an existing Django (but not djangorest) project?

Hey, I'm still not a very advanced developer, but I was looking into learning a front end framework...with the primary goal of doing some on-the-fly data filtering in a form. Essentially I want to, when a user selects an option from a dropdown, filter another dropdown based on some parameters that are too cumbersome to have loading with the page.

So I figured I need some kind of framework to handle that, and I had a few questions:

1. Is Vue a good option for this, generally speaking?
2. Is there another, simpler way to do this? Have a small section of the page make calls to either a function in my Django project or straight to the database to retrieve some data.
3. If Vue IS a good option, how do I get around the fact that they both use the { } syntax? Am I going to have to rewrite my django templates to not actually include Django?

Any other insights would be great! I want to fully learn Vue or React soon, but thought maybe a simple implementation into a real-world existing project would be a nice way

/r/django
https://redd.it/cg52n0
[R] A repository of community detection (graph clustering) research papers with implementations (deep learning, spectral clustering, edge cuts, factorization)

&#x200B;

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

Link: [https://github.com/benedekrozemberczki/awesome-community-detection](https://github.com/benedekrozemberczki/awesome-community-detection)

The repository covers techniques such as deep learning, spectral clustering, edge cuts, factorization. I monthly update it with new papers when something comes out with code.

/r/MachineLearning
https://redd.it/cgbwk2
What to do next to be proficient at Django?

I have just finished Django For Beginners by William S. Vincent. Now I am learning basic CSS, HTML from [freeCodeCamp.org](https://freeCodeCamp.org). What should I do now to become proficient in Django? Should I finish another tutorial on Django(like Django For Girls) or should I revise the previous one another time? Thanks in advance.

/r/django
https://redd.it/cgftnd
This media is not supported in your browser
VIEW IN TELEGRAM
For those of you made uncomfortable by yesterdays simulation. No phones were harmed in the making of this simulation

/r/Python
https://redd.it/cghqy0
[D] What is OpenAI? I don't know anymore.

*Some [commentary](https://threadreaderapp.com/thread/1153364705777311745.html) from [Smerity](https://twitter.com/Smerity/status/1153364705777311745) about yesterday's [cash infusion](https://openai.com/blog/microsoft/) from MS into OpenAI:*

What is OpenAI? I don't know anymore.
A non-profit that leveraged good will whilst silently giving out equity for [years](https://twitter.com/gdb/status/1105137541970243584) prepping a shift to for-profit that is now seeking to license closed tech through a third party by segmenting tech under a banner of [pre](https://twitter.com/tsimonite/status/1153340994986766336)/post "AGI" technology?

The non-profit/for-profit/investor [partnership](https://openai.com/blog/openai-lp/) is held together by a set of legal documents that are entirely novel (=bad term in legal docs), are [non-public](https://twitter.com/gdb/status/1153305526026956800) + unclear, have no case precedence, yet promise to wed operation to a vague (and already re-interpreted) [OpenAI Charter](https://openai.com/charter/).

The claim is that [AGI](https://twitter.com/woj_zaremba/status/1105149945118519296) needs to be carefully and collaboratively guided into existence yet the output of almost [every](https://github.com/facebookresearch) [other](https://github.com/google-research/google-research) [existing](https://github.com/salesforce) [commercial](https://github.com/NVlabs) lab is more open. OpenAI runs a closed ecosystem where they primarily don't or won't trust outside of a small bubble.

I say this knowing many of the people there and with past and present love in my heart—I don't collaborate with OpenAI as I have no freaking clue what they're doing. Their primary form of communication is high entropy blog posts that'd be shock pivots for any normal start-up.

Many of their [blog posts](https://openai.com/blog/cooperation-on-safety/) and [spoken](https://www.youtube.com/watch?v=BJi6N4tDupk) [positions](https://www.youtube.com/watch?v=9EN_HoEk3KY) end up [influencing government

/r/MachineLearning
https://redd.it/cgmptl
Burnout & Personal Projects

I've been developing web apps using Django as my main tool for about 4 years now.

It started with needing to solve a problem at an old job (requiring a relatively simple CRUD db app with some vaguely interesting front end stuff) and Django seemed like a great tool. I read tutorials and the Django docs and taught myself the basics over a few weeks, refined and expanded the app, read some more, bought a copy of TwoScoops, asked lots of questions on Stack Overflow and on /r/django (shoutout pydanny), and refined it some more. Had some ideas for personal projects that interested me, learned how to use REST APIs, built a reddit bot, read about ML, put a small portfolio together on github and ended up getting headhunted to be the lead developer at a company with some interesting tech problems to solve and a Django codebase that was in desperate need of some TLC.

Fast forward a few years and professionally things have been great, the money has grown, but so has the responsibility and mental energy required.

I just realised its now been months since I touched a personal project or did any development outside of

/r/django
https://redd.it/cgn3q2
500+ Python Machine Learning Applications in Various Industries

An exhaustive ML/DS list sorted by industry.

&#x200B;

1500+ Stars on GitHub:

[https://github.com/firmai/industry-machine-learning](https://github.com/firmai/industry-machine-learning)

Join the new list to get access to the catalogue from November 2019 - November 2020.

&#x200B;

||||
|:-|:-|:-|
|[Accommodation & Food](https://github.com/firmai/industry-machine-learning#accommodation)|[Agriculture](https://github.com/firmai/industry-machine-learning#agriculture)|[Banking & Insurance](https://github.com/firmai/industry-machine-learning#bankfin)|
|[Biotechnological & Life Sciences](https://github.com/firmai/industry-machine-learning#biotech)|[Construction & Engineering](https://github.com/firmai/industry-machine-learning#construction)|[Education & Research](https://github.com/firmai/industry-machine-learning#education)|
|[Emergency & Relief](https://github.com/firmai/industry-machine-learning#emergency)|[Finance](https://github.com/firmai/industry-machine-learning#finance)|[Manufacturing](https://github.com/firmai/industry-machine-learning#manufacturing)|
|[Government and Public Works](https://github.com/firmai/industry-machine-learning#public)|[Healthcare](https://github.com/firmai/industry-machine-learning#healthcare)|[Media & Publishing](https://github.com/firmai/industry-machine-learning#media)|
|[Justice, Law and Regulations](https://github.com/firmai/industry-machine-learning#legal)|[Miscellaneous](https://github.com/firmai/industry-machine-learning#miscellaneous)|[Accounting](https://github.com/firmai/industry-machine-learning#accounting)|
|[Real Estate, Rental & Leasing](https://github.com/firmai/industry-machine-learning#realestate)|[Utilities](https://github.com/firmai/industry-machine-learning#utilities)|[Wholesale & Retail](https://github.com/firmai/industry-machine-learning#wholesale)|

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