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
numba and llvmlite are available in .whl format for Windows, Linux and Mac OS.

Just wanted to say that it's really nice that we can now easily install numba in a virtualenv, without having to use conda.
Kudos to the guys at Anaconda Inc!

/r/Python
https://redd.it/7mo9n9
[D] What type of Asimov-style rules would robot hosts have in HBO's Westworld?

>In the HBO series Westworld, a Host is an artificially created being, an android or artificially created animal. All of the animals (except for flies) in Westworld are hosts.

>The hosts are built to act out both storylines and narratives in the park by interacting with each other and with guests. They are designed to be incapable of permanently hurting any living non-host.

>At least some hosts are given a narrative to follow, and it may be that all hosts have a narrative to follow.

>Narratives are the stories that guests can participate in within the park. These stories are part of the entertainment of the guests. (Hosts follow their own story lines that loop, or repeat. The host's story lines can be part of guest narratives. There have been instances when hosts have broken away from their loops.)


>http://westworld.wikia.com/wiki/Host

>http://westworld.wikia.com/wiki/Narratives

/r/MachineLearning
https://redd.it/7mrbkv
Sqlalchemy for Mysql vs postgres

Hi Im learning to program(first year CompSci student) and Im trying to teach myself how to make a website backed by a database. So far it is proving to be a harder nut to crack than I had anticipated, and definitely a learning experience.

I did a pretty cool tutorial where I scraped some facebook data with their api and stored it in a Mysql database, That was pretty cool. Now next step for my plan will be connecting to that database and getting the info out of it to use. for that end I found sqlalchemy and flask. Seems pretty great and I found a pretty great tutorial :

https://auth0.com/blog/sqlalchemy-orm-tutorial-for-python-developers/

But they use a postgres database! As far as I understand the whole purpose of sqlalchemy is so that the language will be the same for connecting to any database. Am I correct? If not Im thinking this whole thing might be a bit too ambitious for my current skill level! Oh well! Im open to any and all suggestions :)

TLDR: can i use sqlalchemy with a mysql database just like a postgres database?



/r/flask
https://redd.it/7mcwre
Algorithmic Problem Solving with Python [pdf]
http://www.eecs.wsu.edu/~schneidj/PyBook/swan.pdf

/r/Python
https://redd.it/7ms7xc
[HELP] Setting up a frontend workflow in a Django project.

Hi everyone! I have some experience with Flask and is now trying to pickup Django, and am slightly getting overwhelmed by the directory structure. And then there's a handful of techniques which deviates from the stock `startproject` layout, which only adds to the confusion. I mean, that's the reason I'm picking up the framework: to get a standardized structure/layout, unlike Flask in which the burden is in the developer's hands. Okay, enough of the newbie rant :D

The premise is that I would like to incorporate Node/NPM to my workflow. The primary reason is to allow usage of `ES6+` and `SASS` on my static files. Anyway, I currently have the following setup:

<project_root>
├── <django_project_root>
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ ├── views.py
│ └── wsgi.py
├── lib // Compiled stuff.
│ └── app.js
├── LICENSE
├── manage.py
├── package.json
├── README.md
├── requirements.txt
├── src // Uncompiled 'source'
│ └── app.js
├── templates
│ └── index.djt
├── static // What gets referenced in my templates.
│ └── app.js
└── webpack.config.js

Now, I would like to write my `JS/SCSS` inside my `src` directory, and then:

1. Babel do its thing and output an `ES5` friendly version of whatever is in `src` into the `lib` folder.
2. Webpack grabs what's in `lib` and spits out a browser friendly version into a `static` folder.
3. Templates inside the `tempaltes` directory loads the contents of the `static` folder.
4. Note that I keep both `lib` and `static` out of version control. Which is correct, since I only need the `src` file, right?

Anyway, I can successfully do the workflow above with `ES6` js files inside `src`. But I'm clueless on what to do to do the same with `SCSS` files.

Relevant files:

// package.json
{
// ....
"scripts": {
"build": "babel src -d lib && webpack"
},
// ...
}

---

// webpack.config.js
module.exports = {
entry: './lib/app.js',
output: {
filename: './static/js/app.js',
}
};


How should I continue? Please do tell me if I need to provide more information. Thanks!

/r/django
https://redd.it/7mtbc5
Linting while the dev server runs

I've been doing a bit of front-end development lately and one of the things I really started to like is that while using webpack-dev-server with eslint, any linting errorswill show in the console in real-time when the server reloads.

I was wondering if I could do the same thing using Flask dev server and flake8

Turns out it's fairly simple.

I modified my `run.py` to run flake8 and show the errors any time the Flask dev server restarts.

https://gist.github.com/timster/a6b8d01c864cf7ce7ad20ecb3f8d85b6

This gives a pretty output in the console for any linting errors:

https://i.imgur.com/7zbsXu9.png

Has anyone done anything similar?

/r/flask
https://redd.it/7mty89
django app with celery enabling users to create tasks, and configure how to run them.

hello, i am making a django app using celery, i want the user to be able to schedule tasks. how should i go about doing it?should i use periodic tasks or something else, the examples show static calls to functions.

/r/django
https://redd.it/7mucll
%run magic not working with other ipynb files

So I created a "test" environment where I have 3 separate jupyter notebooks (`one, two, run_all`).

- `one` adds a few integer numbers
- `two` creates a dataframe and writes to a csv file
- `run_all` contains only 2 cells:
- `%run ./one.ipynb`
- `%run ./two.ipynb`

Unfortunately it is not working. There is no error the two cells inside the `run_all` executes but nothing is happening

/r/IPython
https://redd.it/7mvz9v
[AF] Populating forums with url values?

Hello!

I have a search page on my Flask site that takes user input, when they submit it refreshes the page with the url changed to www.url.com/search?query=value

Is there a way to automatically populate the search bar with the value from the url? There are several search bars and drop down selectors with values to sync with the url.

Thanks!

/r/flask
https://redd.it/7mw98a
Flask Listens on Private IP vs Localhost

This might be the wrong place but I'm wondering, I'm just using a basic flask sample app from

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-flask.html

And I'm wondering, why when I use localhost/127.0.0.1 as the ip to host the server on port 80, I cannot connect to it from anywhere else, but when I use the private IP assigned to it by AWS, I can connect to it from my house.

So if I use app.run(host='172.16.1.15', port=80), I can put in the public IP in my browser and connect to it. But when I use localhost, I cannot connect to it, only from the instance itself.

I'm curious as to why using my private IP as the app host would make this available to anyone, and using just localhost would only have it available to that box. Does AWS automatically map incoming connections on the public IP to the private IP?

Thanks.

/r/flask
https://redd.it/7mvytj
opening .txt file from a specific folder

Hi guys, I am having some trouble opening files from a specific folder in my downloads. I need then to be from this specific folder because I am using a TfIdf Vectorizer later on in my code, and I want the edited files from that folder to be used in the dendogram I am making.
When I just put the files in the download folder I have no trouble opening them when I just use:

text = open('blabla.txt','r')
blabla = text.read()

But when I put them in the folder it can't read the file, so basically it can only find these files in the download folder.
Can anyone help me? Or at least maybe explain why this is the case?

/r/IPython
https://redd.it/7mxcvc
Hosting Flask App on Heroku

Hi there,

I've been working through deploying an application on Heroku.

On my local host I run my application with:
*python manage.py runserver*

As I understand it this runs a Development server and should not be used in production.

I am assuming i need to refactor my application to run on Heroku with the standard
*web: gunicorn app:app*

Any suggestions on how to refactor my code/file tree? Thanks!

FileTree:

* myApp(root)
* -templates
* -admin.py
* -__init__.py
* -auth.py
* -config.py
* -manage.py
* -models.py
* -Procfile
* -requirements.txt
* -.gitignore

/r/flask
https://redd.it/7mz2z5
Python Cheet Sheet for begineers

/r/Python
https://redd.it/7mwgtw