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: 
A slightly more Pythonic way would be to use a generator instead:

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

```

This avoids generating the whole list before calling `sum()`.
If the array only contains elements >= 0 (i.e. all elements are either 0 or a positive integer) then you could just count the zeros and subtract this number form the length of the array:

```
len(arr) - arr.count(0)

```