Add bold text to certain articles

This commit is contained in:
Angelos Chalaris
2023-01-26 22:26:48 +02:00
parent 63e8b314a9
commit 52b04edfe8
10 changed files with 21 additions and 21 deletions

View File

@ -9,7 +9,7 @@ excerpt: There's a good way to test the emptiness of a Python list and a better
firstSeen: 2023-01-15T05:00:00-04:00
---
Checking the emptiness of a Python list is rather easy using the `len()` function. Yet, there's another technique that works on all types of sequences and collections. This is based on the truth value testing of the sequence or collection itself.
Checking the emptiness of a Python list is rather easy using the `len()` function. Yet, there's another technique that works on all types of sequences and collections. This is based on the **truth value testing** of the sequence or collection itself.
By default, a Python object is considered truthy unless its class defines either a `__bool__()` or a `__len__()` method that returns `False` or `0` respectively. Python's built-in objects, such as tuples, lists, strings, dictioners, sets and ranges all implement a `__len__()` method. This menas that truth value testing of these objects will return `False` if they are empty, and `True` otherwise.