Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b9ba417

Browse filesBrowse files
✨ std_lib: chained comparisons
1 parent d518149 commit b9ba417
Copy full SHA for b9ba417

File tree

2 files changed

+6
-0
lines changed
Filter options

2 files changed

+6
-0
lines changed

‎standard_lib/README.md

Copy file name to clipboardExpand all lines: standard_lib/README.md
+1Lines 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

Copy file name to clipboard
+5Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.