Python group tool