reduce() usage in Python