Standard in/out deduplication in python