stack Python implementation