Skip to content

Tag: python

What do ellipsis […] mean in a list?

I was playing around in python. I used the following code in IDLE: The output was: What is this […]? Interestingly I could now use this as a list of list of list up to infinity i.e. I could write the above as long as I wanted and it would still work. EDIT: How is it represented in memory? What’s

Django + Heroku: Out of Memory problems

So this is my first time deploying a django instance on Heroku. My site has had 1000 visits so far and 600 unique visits. We get about 60-200 visits per day. The link is https://socialspark.spuro.org/ Today, 6 days into being live – our site is running into a lot of memory issues. I.E., cannot allocate …

how is axis indexed in numpy’s array?

From Numpy’s tutorial, axis can be indexed with integers, like 0 is for column, 1 is for row, but I don’t grasp why they are indexed this way? And How do I figure out each axis’ index when coping with multidimensional array? Answer By definition, the axis number of the dimension is the index…

Placing text values on axis instead of numeric values

I’ve created a simple word frequency calculator in python 3.2. Now I want to create a plot to visualize the results. The x-axis would contain frequency results and I want to add the most frequent words to the y-axis. How can I add text instead of numbers to a pylab axis? Thanks in advance! Answer I am g…

redirect while passing arguments

In flask, I can do this: And if foo.html contains {{ messages[‘main’] }}, the page will show hello. But what if there’s a route that leads to foo: In this case, the only way to get to foo.html, if I want that logic to happen anyway, is through a redirect: So, how can I get that messages vari…

How to check if table exists?

I’m using this function : I want to check if the table exists, how can I do it? I saw some examples using XXXX.execute(). What does it mean? Here is what I saw: I tried printing MY_T to see if it returns -1 for example but it just prints “select count (*)…… ” How can I check it? …