Get lengths of a list in a jinja2 template?

How do I get the number of elements in a list in jinja2 template? For example, in Python: print(template.render(pr...

In Python, how do I determine if an object is iterable??

Is there a method like isiterable? The only solution I have found so far is to call hasattr(myObj, '__iter__') Bu...

How to sum all the values in a dictionary??

Let's say I have a dictionary in which the keys map to integers like: d = {'key1': 1,'key2': 14,'key3': 47} Is th...

Django 127.0.0.1:8000/admin/ stopped working?

Not sure what I've done to break the admin site, but going to 127.0.0.1:8000/admin/ is not working and gives me the ...

DistutilsOptionError: must supply either home or prefix/exec-prefix — not both?

I've been usually installed python packages through pip. For Google App Engine, I need to install packages to anoth...

ImportError: No module named six?

I'm trying to build OpenERP project, done with dependencies. It's giving this error now Traceback (most recent call...

Official abbreviation for: import scipy as sp/sc?

I've seen both: import scipy as sp and: import scipy as sc Is there an official preference listed anywhere? ...

BeautifulSoup: object of type 'Response' has no len()?

Issue: when I try to execute the script, BeautifulSoup(html, ...) gives the error message "TypeError: object of type...

How do I get the parent directory in Python??

Could someone tell me how to get the parent directory of a path in Python in a cross platform way. E.g. C:\Program ...

NameError: name 'reduce' is not defined in Python?

I'm using Python 3.2. Tried this: xor = lambda x,y: (x+y)%2 l = reduce(xor, [1,2,3,4]) And got the following erro...

Python IOError: File not open for reading?

I get an error when I try to open a file in Python. Here is my code : >>> import os.path >>> os.p...

What does `ValueError: cannot reindex from a duplicate axis` mean??

I am getting a ValueError: cannot reindex from a duplicate axis when I am trying to set an index to a certain value....

ImportError: No module named 'MySQL'?

I have downloaded the Connector/Python for MySQL successfully. I used the following code in Python's shell to test m...

Convert hex string to int in Python?

How do I convert a hex string to an int in Python? I may have it as "0xffff" or just "ffff". ...