Question: I have a list of integers and I need to count how many of them are > 0.  

I'm currently doing it with a list comprehension that looks like this:

```
sum([1 for x in frequencies if x > 0])

```

It seems like a decent comprehension but I don't really like the "1"; it seems like a bit of a magic number. Is there a more Pythonish way to do this?

Answer: 
You could use `len()` on the filtered list:

```
len([x for x in frequencies if x > 0])

```
I would like to point out that all said applies to lists. If we have a numpy array,
there are solutions that will be at least *fourty* times faster...

Summing up all solutions given and testing for efficiency, plus adding some more (had to modify the reduce code to be able to run it in Python 3), note that the last answer is in micros, not millis:
[![enter image description here](https://i.stack.imgur.com/AHQoK.png)](https://i.stack.imgur.com/AHQoK.png)

code in copy-pastable format:

```
import random
import functools
frequencies = [random.randint(0,2) for i in range(10**5)]
from collections import Counter
import numpy as np

%timeit len([x for x in frequencies if x > 0])   # sth
%timeit sum([1 for x in frequencies if x > 0])
%timeit sum(1 for x in frequencies if x > 0)
%timeit sum(x > 0 for x in frequencies)
%timeit functools.reduce(lambda x, y: x + (y > 0), frequencies)
%timeit Counter(frequencies)

#'-------Numpy-----------------------')
%timeit ((np.array(frequencies))>0).sum()
npf=np.array(frequencies)
#'-------Numpy without conversion ---')
%timeit (npf>0).sum()

```