Redirecting to URL in Flask

You have to return a redirect: See the documentation on flask docs. The default value for code is 302 so code=302 can be omitted or replaced by other redirect code (one in 301, 302, 303, 305, and 307).

What does %s mean in a python format string?

It is a string formatting syntax (which it borrows from C). Please see “PyFormat”: Python supports formatting values into strings. Although this can include very complicated expressions, the most basic usage is to insert values into a string with the %s placeholder. Edit: Here is a really simple example: The %s token allows me to insert (and potentially format) a string. … Read more

data type not understood

Try: Since the shape parameter has to be an int or sequence of ints http://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros.html Otherwise you are passing ncols to np.zeros as the dtype.

if/else in a list comprehension

You can totally do that. It’s just an ordering issue: In general, And, for list comprehensions with if conditions only, Note that this actually uses a different language construct, a conditional expression, which itself is not part of the comprehension syntax, while the if after the for…in is part of list comprehensions and used to … Read more