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
Flask CLI and Web ?

I'm thinking of building a Flask APP.

I would also like to build a corresponding CLI app.

Should I build two separate apps or can I make Flask do it all?

Thanks

/r/flask
https://redd.it/8gh6lv
A promising competitor for pygame: Arcade

I've been using pygame for a long time now (just check my GitHub), and while it gets the job done, it has its downsides. Some of the stuff is very confusing; I for one hate how the sprites can only be positioned on integer coordinates, forces me to write my own wrapper around the sprites every time. And the whole game loop is just a bunch of boiler plate, since you're gonna do it the same way everytime anyways. I even made a library to avoid having to write all the boiler plate: https://github.com/Mahi/EzPyGame.

However, there is a better solution! Let me introduce you to [Arcade](http://arcade.academy/). It's a similar game library, but has way less quirks and it's much more pythonic. It's also being actively maintained and developed further as you can see on the [GitHub](https://github.com/pvcraven/arcade) page. It uses OpenGL and pyglet underneath, and there are a ton of examples on getting started on its website. There's even a [subreddit](/r/pythonarcade), although a bit inactive.

Just wanted to give you all a heads up, I'm not connected to the developer in any way, I'm just very happy to see a "better" pygame and wanted to let you all know. It takes some time to get into (coming from pygame), but for me it has been worth the time.

/r/Python
https://redd.it/8hz8p8
pipenv: wanted to try out a specific version of python, ran into some bugs

tldr: used pipenv --python path/to/2.7.15, but pipenv shell still thinks i'm using 2.7.6

---

twig@nix:~/src/TestProject$ rm -rf Pipfile Pipfile.lock ~/.virtualenvs/TestProject-nEJHdvQJ
twig@nix:~/src/TestProject$ pipenv install --python ~/python/compiled/2.7.15/bin/python2.7
Creating a virtualenv for this project…
Using /home/twig/python/compiled/2.7.15/bin/python2.7 (2.7.15) to create virtualenv…
⠋Running virtualenv with interpreter /home/twig/python/compiled/2.7.15/bin/python2.7
New python executable in /home/twig/.virtualenvs/TestProject-nEJHdvQJ/bin/python2.7
Also creating executable in /home/twig/.virtualenvs/TestProject-nEJHdvQJ/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /home/twig/.virtualenvs/TestProject-nEJHdvQJ
Creating a Pipfile for this project…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (dfae9f)!
Installing dependencies from Pipfile.lock (dfae9f)…
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run the following:
$ pipenv shell


twig@nix:~/src/TestProject$ pipenv shell
Loading .env environment variables…
Spawning environment shell (/bin/bash). Use 'exit' to leave.
. /home/twig/.virtualenvs/TestProject-nEJHdvQJ/bin/activate


(TestProject-nEJHdvQJ) twig@nix:~/src/TestProject$ python --version
Python 2.7.6


(TestProject-nEJHdvQJ) twig@nix:~/src/TestProject$ whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python3.4m /usr/bin/python3.4 /usr/bin/python2.7-config /etc/python /etc/python2.7 /etc/python3.4 /usr/lib/python2.7 /usr/lib/python3.4 /usr/bin/X11/python /usr/bin/X11/python2.7 /usr/bin/X11/python3.4m /usr/bin/X11/python3.4 /usr/bin/X11/python2.7-config /usr/local/lib/python2.7 /usr/local/lib/python3.4 /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz

any ideas?

/r/Python
https://redd.it/8i1qdq
I have a 64 bit machine, but I had to install the 32 bit version of Python 3.6.5

I’m new to programming as a whole. I had installed Python 3.6.5 on my 64 bit computer, but I have the 32 bit version of Python. Can anyone explain this please?

/r/Python
https://redd.it/8i17ks
Content scraping with Selenium

Hi

I am building a site that allows users to enter a URL with the aim of it grabbing the images from that site and allowing the user to pick one to use on their page. Standard concept I imagine. I have it all working, along with some code that checks the file size to make sure it's above a certain size. However it's slow, for instance running this on my local machine for a given site may take 12seconds, doing the same on a site with similar functionality takes 3 seconds. Even if I disable the portion of my code that determines the file size it's still as slow.

Is there a way to optimise this? I notice the site that I compared mine with only grabbed 5 images whereas mine took about 20+.

Can I tell selenium to only run for maybe 3 seconds and then use whatever it grabs within that time frame? Or anything else that would help speed this up in any way. I would be happy to only expend as much energy as is required to take the first 5 images from the page - some of the pages that will be scraped by users will be really large I imagine.

Thanks in advance for any assistance / pointers.

/r/django
https://redd.it/8hz6p6
[AF]Flask + Multicore: will flask use all cores automatically?

I have very little knowledge in this area but I'm curious. If I write a Flask application and deploy it onto a virtual machine with multiple cores, then will my Flask application be able to utilize all cores out of the box? If not, then can it be configured to (conceptually)?


/r/flask
https://redd.it/8gafpl
Anyone have a spare ticket they could sell for euroDjangoCon this month? I'm keen to go, but just found out about it....



/r/django
https://redd.it/8i46xe
Thumbnail for file fields

Hey guys,

Has anyone come up with an effective way to display image thumbnails within an ImageField (or VersatileImage) field in Django after the user uploads the image? I see that there are a few code snippets out that that handles thumbnail images for the admin area, but I'm interested in displaying the thumbnail of a user uploaded image on my web page. I'd imagine that I'd need a custom widget, but I don't know much about widgets or how to implement them. Any thoughts would be greatly appreciated.

Thanks!

/r/django
https://redd.it/8i4agq
Advice on database topology? visualizer

Hi all, I'm looking for advice as to the approach I should take.

I have a database something like this;

Animal
Mammal Fish
Cat Dog Cod Plaice

And I'm just wondering of a *sexy* way to visualize the data using a django approach where you can explore along the options tree branches and see the Cat at the end of the tree. I've used django a fair bit before.

Wonder if anyone has any advice or can point me in any direction of good platforms/github repos I could copy and paste my database into and tweak? Something ideally relatively secure such that I could put onto the web at the end.

/r/django
https://redd.it/8hxkfy
Django Vs Rails

hi

i am interested in learning a framework for web. i have read that Django is more modern but rails is fast. it is not clear which one i should learn. rails has been around for a while now and people are saying it is dying. is this true?

i would love to know your opinions

/r/django
https://redd.it/8i5b0y
Help with wtforms and socketio/session data

Hi, I’m new to flask and web development. I’m building my first web app with flask and loving it, learning a lot. My web app allows people to join groups and chat with each other on the specific group page. Wondering what is a good way to pass the username back to client with the message? Or should I put the username in the html (I have it as a variable in the view function), and then try to access it in my jquery script?

Also, I have a basic question about wtforms classes. I am currently using the Form class but am interested in the FlaskForm class. It seems from what I’ve read that FlaskForm offers more. Just interested in the difference/benefits of either.

/r/flask
https://redd.it/8gacsp
Air pollution analysis with pandas

Hi,
I have started a project where I try to analyse air pollution data from monitoring sites in Munich, Germany. Anybody knows of publicly accessible air quality analysis using python/pandas? My initial scripts:

https://github.com/jsln/aq-sensor-data-analysis

I want to extract as much information as I can from the samples before attempting to use scikit-learn to:

- Compare the performance of different forecasting models.
- Study correlations between samples at different monitoring stations.

Any work in this area you can point me at, I would appreciate it.

Thanks,
Juan.

/r/pystats
https://redd.it/8i8fhe
[Code Review] I'm working on a vinyl trading API and it's currently WIP but I'd like some feedback.

Link: https://github.com/mabbie/vinylhandelsclub-api

I still have ways to go before the project is complete, mainly security and handling logging in and out users. But so far, how am I doing? I used Flask-RESTful to build the API, and Flask-JWT-Extended for JWT authentication.

/r/flask
https://redd.it/8dzhyb
Is anybody doing qualitative data analysis in Jupyter / IPython?

For R there is the RQDA package and a number of other tools related to qualitative data analysis. There are very few IPython notebooks on the web that deal with qualitative sociological approaches, but most of them are undocumented.

Therefore my question: is anybody doing a qualitative project in a Jupyter notebook? Would you like to present it here and post a short description of what it is about?

/r/IPython
https://redd.it/8i3r72