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
Backdoor in ssh-decorator package

Do not install or use the [ssh\-decorator](https://pypi.org/project/ssh-decorate/#files) package from Pip. It has a backdoor inserted to steal all your SSH credentials. I've already contacted the developer to take it out. He hasn't responded so for now, use at your own risk! [https://ibb.co/kdDk67](https://www.linkedin.com/redir/redirect?url=https%3A%2F%2Fibb%2Eco%2FkdDk67&urlhash=SFzn&_t=tracking_anet)

**UPDATE:** The compromised package has been taken down now.

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

/r/Python
https://redd.it/8hvzja
Django rest and React

So i just started with django rest and front end frameworks e.g react. From what I've seen with react is that we fetch data from a rest api. We only get data and we build all our logic as to what to do with that data in react.

So here's my question: I've built apps with django before. I've had to create views, forms signals etc etc. however will this be the same case when I want to make a single page application using the rest api? I mean in this case my django application will only serve the function of providing an api right? it will not have anything to do with views and forms logic? all of that will be done in react ?

Basically my question is this: If i want to make a single page application. Do I only need django to serve as a data storage which will provide an api and build all the logic and stuff in the front end e.g angular, react or vue etc?



/r/django
https://redd.it/8hv7ye
Multiple apps, same login.

I am currently running a flask app under `mysite.com`. Now I would like to add a second flask app that will run under a subdomain, say `new.mysite.com`.

What I would like to do is have the main app handle the user authentication so if you login in `mysite.com/login` you are good for `new.mysite.com` too. Right now I am using the flask-login plugin for the main site. Ideally I don't want to add any authentication code or deal with the user database in the second app, but my understanding is that I still need a login manager and a user loader.

What is the proper way to implement this?

/r/flask
https://redd.it/8ggd5r
Email authentication

I'm on a subject of creating/authenticating accounts. Now when a user signs up, I want them to use a valid email. (Gmail, Yahoo etc.) And not fake one time use emails. Whats the best way going about doing this? I've been looking at creating a list of valid email address endings

ie. Endswith @gmail.com, @yahoo.com.

If it matches those it would be valid. I'm not sure if there is a better way...Thoughts?

/r/djangolearning
https://redd.it/8hytlv
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