Pythonic solution?