---
title: "Alex Hall (@alexmojaki) | Hashnode"
description: "Python metaprogrammer. Read the latest articles by Alex Hall on Hashnode."
url: "https://hashnode.com/@alexmojaki"
---

@alexmojaki

# Alex Hall

@alexmojaki · Joined August 2020

Python metaprogrammer

## Comments

[To me it seems obvious that the chained comparisons wouldn't work. I've never seen someone make that mistake before. Doing that breaks extremely easily without the fact about booleans. If a == b == c is True, then (a == b) == c is guaranteed to be False unless they are all equal to True (or 1). I often use this property of booleans to write something like sum(predicate(x) for x in lst) to count the number of items in a list satisfying a condition, or conveniently making something plural with f"thing{(len(things) > 1) \* 's'}". It's hacky but it's fun.](https://hashnode.com/posts/python-gotchas/5f93f46afbdce372c9a56d6b/comment/5f98974b91c85e2865f5fb86#reply-5f989ea76ea7602886a170d5)

Reply · Article · Oct 27, 2020 · [Python Gotchas: 5 Worst Mistakes You Should Avoid](https://hashnode.com/posts/python-gotchas/5f93f46afbdce372c9a56d6b)

[Since 0 is considered a "Falsy" value, then the comparison returns 'True\`. No, that's the kind of thing JavaScript does. Most Falsy values (None, empty string/list/dict/etc) are not equal to False. False == 0 and True == 1 because bool is a subclass of int. You can treat booleans just like those numbers, for example True + True == 2. This can be very useful.](https://hashnode.com/posts/python-gotchas/5f93f46afbdce372c9a56d6b/comment/5f98974b91c85e2865f5fb86)

Comment · Article · Oct 27, 2020 · [Python Gotchas: 5 Worst Mistakes You Should Avoid](https://hashnode.com/posts/python-gotchas/5f93f46afbdce372c9a56d6b)
