Skip to content

Commit b9ba417

Browse files
✨ std_lib: chained comparisons
1 parent d518149 commit b9ba417

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

standard_lib/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ A collection of useful snippets using only the standard library.
1414
| builtins_manipulation | Illustrates the easy overriding/manipulation of built-in functions |
1515
| capture_output | Capture the output of a function generally directing to stdout |
1616
| chained_assignments | Assign a value to multiple variables using chained assignments |
17+
| chained_comparison | Chain comparisons to have more math-like comparisons |
1718
| check_pattern | Check for multiple string patterns |
1819
| compare_strings | Use `difflib.SequenceMatcher` to compare strings |
1920
| count_thresholds | Count the number of elements between certain thresholds |

standard_lib/chained_comparison.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
x = 13
2+
lower_bound, upper_bound = 10, 20
3+
print(lower_bound, upper_bound)
4+
print(x > lower_bound and x < upper_bound)
5+
print(lower_bound < x < upper_bound)

0 commit comments

Comments
 (0)