cosmologicon / pywat

Python wats

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Indexing with floats

daneah opened this issue · comments

This is not much of a wat. In the first case the example shows attempting to index a list at index 0.0, which does not make sense. In the second case, the example shows attempting to find the key 0.0 in a dictionary, which does make sense. The only wat here might be that Python coerces float to int if possible when using it in a dictionary key search.

Similarly:

{3:'foo'}[3.0]  # 'foo'

To me:

:)