kv port to python