Look to my Python session:
>>> {}.keys().insert(0, "") == None
True
but:
>>> k = {}.keys()
>>> k
[]
>>> k.insert(0, "")
>>> k
['']
Why??
PS. Thanks for help! Python have very strange design - do not support chaining:
That is root of my problem...
list.insert returns None; when you print k you're printing the new state of the list.
You are checking the return type to None in case 1 which would evaluate to True.
Python insert returns None
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