Documentation
Comparisons
Equals (==
), inequality (!=
)
- The only comparison operator that can be used cross type, but only with
None
- Equal comparisons between different types that are not None will always result in a crash, e.g. int(2) == dec(2)
- Not equal comparisons between different types that are not None will always result in a cresh, e.g. int(2) != dec(2)
- Equal comparisons on any non-
None
value with None
will always be False
- Not equal comparisons on any non-
None
value with None
will always be True
- Can not be chained
Less than (<
), greater than (>
), less than or equal to (<=
), greater than or equal to (>=
)
- Does not work for
dict
and function
types
- For strings, the comparison is alphabetical
- For lists, it compares items on an item-to-item basis
- Will fail on root level type mismatches (elements will not be ducked-typed into comparisons)
- Can not be chained
in
and has
- Checks to look for a value inside a list or inside the keys of a dictionary
- One side of the operator must be a list value to look for, the other side must be a list
- Order does not matter
- The list must all contain elements of the same type
- Can not be chained