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
Leveraging Python for Data Visibility - A tutorial on how to leverage python's Data Spyre, Bokeh, and Pygal libraries (xpost from /r/DataScience)

Hi /r/pystats,

I got a recommendation to post this here from /r/python, so here you go!

Last night I gave a talk at the Kansas City Data Science Meetup on how to use Data Spyre to create a lightweight and easy to use web application. On top of that, I give examples on how you can incorporate Bokeh and Pygal plots to add interactivity to your web application as well. I've put my Jupyter notebook along with all of my example scripts into a Git Repo for all to use. Enjoy!

https://github.com/pm8k/dataspyre_tutorial

/r/pystats
https://redd.it/3sm9ju
Is Django a good framework for multi-tenancy SaaS app?

I am evaluating difference frameworks right now and it seems like Django is not as mature for building multi-tenancy app. I just tried out django-tenant-schemas today and the repository is not quite caught up with the recent version of Django. I wonder whether anyone have experiences building SaaS app with Django and what do you think of it. Thanks!

/r/django
https://redd.it/5kubzl
Highly custom validation?

Ok so I have a model that asks for an event from a dropdown menu and then depending on what event that is a certain number of people, both men and women, have to be entered before submitting.
An example would be event A requires 3 people, at least 2 male and 1 female or 2 female and 1 male. But the rules for each event are different. Is there any way to go about doing this in django? Thank you so much for the help.

Edit* Im using model forms btw if that matters at all

/r/django
https://redd.it/5ksoaf
Embedding IPython example from manual doesn't work (for me)

Hi,
I'm looking to integrate interactive shell to extended unittests framework I work on and I wanted to use IPython for that. But when I tried the example from http://ipython.readthedocs.io/en/stable/interactive/reference.html#embedding-ipython - embed_class_long.py it doesn't seem to work properly - after exiting instance of InteractiveShellEmbed for the first time, next time it should open it just displays both banner and exit messages and no actual shell opens.

Calling IPython.embed() works ok, but I need to set custom banner and new commands (magics in IPython lingo?) which I think isn't possible that way

Any guesses why the manual example doesn't work or what should I change/test/etc?

(I'm using python 2.7 , ipython version 5.0.0, Linux)

/r/IPython
https://redd.it/5kwh3a
Creating a flask app and thinking of using peewee instead of sqlalchemy...

So, I am creating a flask app and thinking of using peewee instead of sqlalchemy. I have some basic experience with peewee and it seems great to me.

My database will be postgreSQL which I have almost no experience with but I have read that its the recommended Python database for Flask and other web apps.

Are there any glaring problems with using peewee with flask that might cause me problems?

The part of the app I am writing right now is back-end of the back-end. By that I mean that it is the engine that will be running and actually scraping the web and analyzing the data that I want to return to my users. It's the service that the web app will be sending data to and getting results from.

/r/flask
https://redd.it/5kuv7n
Can anyone suggest a good way to handle postal addresses in Python/Django?

I'm currently finishing up an app that relies somewhat heavily on postal addresses - local and international. I'm currently using (a slightly modified version of) https://github.com/furious-luke/django-address. It does a decent job, but the relationships in the DB are set up so every address FK references a locality, every locality fk references a state, and every state fk references a country. I understand the logic behind doing something like this, but if I enter an address that doesn't contain a locality, it won't store a country, because it breaks the FK reference chain. Has anyone ever setup a flat db table that stores all postal address parameters on individual rows? I've been searching all over for something that will at least store international addresses to no avail. Thanks in advance.

/r/django
https://redd.it/5klhbd
[AF] Please share advice for testing with existing database

I am new to flask and marginally familiar with databases and testing. I am working on a project that mainly deals with an Oracle database and it isn't clear to me how I should to test my project. I need help getting my mindset right.

Currently the application draws a chart of selected data, the user categorizes points in the chart and saves the categories to another table. The site is then updated in a way so other uses know that group of data has been examined.

At the moment the dev database is a full copy with hundreds of thousands of rows in the main table. At the moment relations are simple and I know exactly which tables I need and their relation to one another.

What advice or resources do you all have?

The popular advice from just searching is that I should build a new version of the database up for each test, but that seems unwieldy for the amount of data. Do I take a subset? Are there established ways of copying the database's schema using sql-alchemy so it can be regenerated quickly? Even then what do I test, that I get the correct data from the database?

The other advice I have seen is to avoid CRUD tests altogether and just test data manipulation using mocks or example data. This seems like the easy way out as almost all the business logic will live in the database.

Thanks






/r/flask
https://redd.it/5kuxfn
Jinja 2.8.1 Released with a Security Fix for str.format in Sandbox Mode
https://www.palletsprojects.com/blog/jinja-281-released/

/r/Python
https://redd.it/5kwvr6