2005-05-17

_Pythonの謎

>>> None > 0
False
>>> None == 0
False
>>> None < 0
True
>>> None < -1
True
>>> None < -1000000
True
>>> None < -1000000000000000
True

None って無限小なんすか???

追記:5.9 Comparisons によれば、

The operators <, >, ==, >=, <=, and != compare the values of two objects. The objects need not have the same type. If both are numbers, they are converted to a common type. Otherwise, objects of different types always compare unequal, and are ordered consistently but arbitrarily.

だそうで、多分、型に付けられた識別子の数値か何かで決まっているっぽいですね。 要するに、Noneがintより小さいのは任意であって、それを利用しちゃいかんのですね。 別に利用しようと思ったわけではなくて、たまたま変な症状が見受けられたので、何でだろうと思っただけなんですけど。

本日のツッコミ(全1件) [ツッコミを入れる]
_ zunda (2005-05-18 06:15)

>>> -1e999
-inf
>>> None < -1e999
True

そうみたいですね :)

[]