The ```is``` key is used in Python to test the identity, not the equality. If ```encod``` is a string, your test is always true.
(RTFM: http://docs.python.org/2/library/stdtypes.html)