shorter and IMHO better Python solution