I was going through a question in Checkio. And then i came across this.
import re,math
re > math # returns True
math > re # returns False
Can someone explain how Python compares between ANY two THINGS.
Does python does this thing by providing a hierarchy for modules. Furthermore,
re > 1 # return True # Ok, But Why?
I would really appreciate some deep explanations on these things!
Everthing is an object. And modules are no exception. Therefore:
import re, math
print(id(re), id(math))
print(re > math)
print(id(re) > id(math))
print(re < math)
print(id(re) < id(math))
print(id(re), id(math))
In my case:
39785048 40578360
False
False
True
True
39785048 40578360
Your mileage may vary, because your ids will not be mine and therefore the comparison may be reversed in your case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With