Python3 implementation in D