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
I want to make a minimal Mezzanine site. How do I start from "scratch?"

I've set up a virtual environment using `virtualenv` command. Then I ran these commands:

# Install from PyPI
$ pip install mezzanine

# Create a project
$ mezzanine-project myproject
$ cd myproject

# Create a database
$ python manage.py createdb

# Run the web server
$ python manage.py runserver

When I go to `localhost:8080`, I get the standard, basic Mezzanine site. But I want to make a minimal homepage with two main sections: A navbar up top and a big main section below.

It seems like a lot of work to change the basic Mezzanine theme to match what I want.

So what do I do if I want to start a Mezzanine website/page from scratch?

/r/django
https://redd.it/6y9cqc
PyData Conference

I am relatively new to python (can do the basics, but have few big projects). However, I am debating trying to transition my job from academia to data analyst around May.

My questions for this community:
1) Both in terms of learning new things and interacting with potential employers, is the upcoming PyData conference in New York something that I would benefit from attending?

2) Has anybody attended in the past? What was your experience like?

3) If I decide to attend, how should I prepare?

I should also mention that my college will pay between 50-75% of my total expenses.

I appreciate any thoughts!


/r/pystats
https://redd.it/6xuh5x
What is considered to be the definitive Python bible, so far as books go?

I've been doing software development for 20+ years, and I'm not looking for a beginners Python programming book. I'm looking for something more akin to Perl's Camel book - a definitive reference, that covers all aspects of the language.

Many thanks!

/r/Python
https://redd.it/6y8i05
[AF] Strange problem with output compounding if the a form is submitted within a short timeframe

This one has me stumped.

I have a WTForm that I'm using like so:

form = UserForm()
if form.validate_on_submit():
session['form'] = form.data
return redirect('/analysis')

and then on my analysis function in views.py:

@app.route('/analysis', methods=['GET', 'POST'])
def analysis_results(text=None):
image, answers = main(session.get('form', None))
uniques = answers['uniques']
del answers['uniques']
session['form'] = None # a hack...didn't actually help.
if answers == False:
flash('No viable schedules are possible with these settings. Revise your parameters and submit again.')
return render_template('analysis.html',
title='Analysis',
image=image,
schedules=uniques,
mutations=answers)

So as you can see, I'm calling my backend program (main), which receives the session cookie that has the form data. The problem is that if I go to my analysis page, its great the first time. But, if I go back to the form quickly enough and just submit the same info (or different) in a 30 second window, it processes the whole thing, and then it looks like the 'answers' output (a dict) contains more keys than it should, and these end up getting printed to the analysis page.

Thing is, if I wait more than 30 seconds, no problem.

Thing is, if I try to print the form data, it looks the same no matter what. Or I'm crazy. One of the two.

How the heck could my front end be jacking up my back end if the input form data seemingly stays the same? And its not a problem if I just wait a little? I'm very confused.

This probably wouldn't be an issue for 90% of my users, but if someone did encounter this problem, it would make them lose confidence in my project. Help appreciated.

/r/flask
https://redd.it/6yc6a1
Bokeh poor support of Pandas DataFrame?

Just curious if anybody else find it surprising that Bokeh doesn't support Pandas dataframe as well as they would like as compared to plotly? Bokeh, seaborn, dask, pandas, et. el. are all part of the pydata organization. So I was surprised for instance, if you make a Bokeh chart of multiple lines from a pandas dataframe, the hover tool doesn't include the column names. It includes the (x,y) coordinates and index value, but omits the line labels!!! Hmmm...wow. One of the usefulness of the hover tool is when you have multiple lines, you want to easily identify the corresponding line label. In Bokeh, to get the line labels/column names in the hover tool you have to create a ColumnDataSource object from the Pandas dataframe, create a Hover object, and then use a FOR loop to render each line, otherwise resort to using HoloViews (a higher level API around Bokeh), which I still don't see how to get line labels. So I look into HoloViews further and I also find out it doesn't support pandas dataframe index, you have to resort to doing an additional reset_index() per their [doc](http://dev.holoviews.org/Tutorials/Pandas_Conversion.html).

Plotly surprisingly supports Pandas dataframes more completely compared to Bokeh (shows column names/line labels in the hover tool) and supports dataframe index. This is part of the major reason why it looks like I will have to stick with Plotly for interactive visualizations. If I have a need for a viz server or plot billions of data points, then I'll use Bokeh.

/r/pystats
https://redd.it/6xtmes
Postgres vs MySql - Which is better? Why?

I use MySql, as pythonanywhere has that preinstalled for free accounts. Any reason why you might go with postgres over mysql?

/r/flask
https://redd.it/6y2u0m
[AF] Where to store data and and static charts to be accessed by a Flask app

Flask newbie here! I have a question about how best to supply data to a Flask app.

I have a Flask app that shows some data and charts that are updated every hour. I'd consider the data "small" (a table of ~50 rows and 3 columns). The data and charts are generated by an R script that I have running outside and independently of my Flask app. The R script stores the data as a csv file and the charts as images on AWS S3, which the Flask app loads and presents. The Flask app does not write to the data set; it only reads it.

This setup works fine for now, but I'm wondering if I will experience issues as usage of the app (hopefully) scales. Are there issues with the app loading a csv file instead of reading from a database? Are there issues with the data and charts sitting outside of the app entirely?

Being new to web app development, I just want to make sure that I'm on the right path and not making egregious mistakes. Apologies if my current setup is way off the mark, but I would appreciate feedback. Thanks for your help!

/r/flask
https://redd.it/6xvlwk
Help to redo Economics: The Agent-Based Computational Economics Library. I worked for 5 years and it is finally stable.
https://github.com/AB-CE/abce/releases/tag/0.9b

/r/Python
https://redd.it/6ybnhj
Any Python project for students?

Hi, Reddit! I'm a student of MIPT and I have a course about programming and innovations (not really innovations, administration just calls it this way), and during this course we will have to create different "innovative" projects in small teams (about 2 - 3 student per team). These projects don't have to be really innovative, but it's also not a good idea to create someting that was created thousands times before, like TODO application. Unfortunately, I don't have any good ideas for such project! The only one I have is to create some kind of Wolfram Alpha analogue using Telegram Bot and SymPy.
So, do you have any ideas, what should we (my team and I) implement? Any help will be appreciated!

/r/Python
https://redd.it/6yg2qx
Problem with Flask-SQLAlchemy

Hi, everybody. I'm trying to pass an HTML text (a tag text) to a table using "db.session.Model(HTML)", but I get "sqlalchemy.exc.InterfaceError: (sqlite3.InterfaceError) Error binding parameter 0 - probably unsupported type." If I then pass "HTML" inside a str() function, to turn it into a string, I get "sqlalchemy.orm.exc.UnmappedInstanceError: Class 'builtins.str' is not mapped".

Does anyone know how to solve that problem?

/r/flask
https://redd.it/6wsbz0
Easiest way to send information to a site

Hi all,

I have a site running on pythonanywhere that uses a database to display information to users. The problem is that pythonanywhere doesn't let you remotely write to a database so it is a pain to update the database and I'm looking for a way to automate it. I was thinking of having a specific route in which I could send it a list of values and these values would be written to the database. I was looking and it seems that an API would be an option. I'm not in the mood to learn how to create an API right now if I don't have to. Is there an easier way to do this? Basically I would like to have a python script running on my home computer then at a certain point, it accesses the appropriate page (using requests or something like that) and these values get written to the database.


Thanks

/r/flask
https://redd.it/6wr416