How do comparison operators work? I thought they could be used only to compare numeric values, 5 <= 8, etc. But in this code sets are compared:
str = 'The quick Brow Fox'
alphabet = string.ascii_lowercase
alphaset = set(alphabet)
b = alphaset <= set(str.lower()) # Does it automatically extract length of objects?
print(len(alphaset)) # 26
print(len(set(str.lower()))) # 19
print(b)
26
15
False
I thought that it is impossible to do. alphaset <= set(str.lower())
, you know literally is, e. g. set() <= set()
. Does an operator implicitly call len()
on such objects to find some numeric values to compare?
How does it know that one sequence is bigger, less or equal etc. to another?