Port of ruby KSS in python