I'm being way to clever... I read your article when it was originally posted, but hadn't realized that you're quoting from it! My bad...
If you'll humor me, I'd love to take another shot, but from the more interesting direction!
Adding a type might clear stuff up a bit:
-- hs
pure (n, guard (factor /= n) $> factor) :: IO (Int, Maybe Int)
# py
print((n, if factor == n then factor else None))
So without the for loop, there's no list to comprehend. Adding the list back gives something more equivalent to a standard for loop in Python:
-- hs
for numbers $ \n ->
pure (n, guard (factor /= n) $> factor) :: IO [(Int, Maybe Int)]
# py
for n in numbers:
print((n, if factor == n then factor else None))
Which could also be written as a list comprehension in either language:
-- hs
[pure (n, guard (factor /= n) $> factor) | n <- numbers] :: IO [(Int, Maybe Int)]
# py
[print((n, if factor == n then factor else None)) for n in numbers]
Note that they behave a bit differently though, and it's the reason I haven't included `return` in the python line (what does `print` return?). Python will loop through the list and actually run the `print` function on each element, while Haskell will loop through and collect all the `IO` into one function to run later. Although it's starting to get pretty un-Pythonic, you can hack the behavior into Python with something like:
# py
return lambda: [f for f in (print((n, if factor == n then factor else None)) for n in numbers)]
Which would need to be run using something unholy like:
# py
factorize(numbers)()