Comparison of modules in Python. OK, but why?

In Chekio, I asked a question. And then I stumbled upon this.

import re,math re > math # returns True math > re # returns False 

Can someone explain how Python compares ANY OTHER THINGS.

Does python use this thing, providing a hierarchy for modules. Besides,

 re > 1 # return True # Ok, But Why? 

I would really appreciate some in-depth explanation on these issues!

+7
python
source share
1 answer

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 identifiers will not be mine, and therefore the comparison may be canceled in your case.

+4
source share

All Articles