#!/usr/bin/env python3 #!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2019 Karl Fogel # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # If you did not receive a copy of the GNU General Public License # along with this program, see . """Print unique lines from the input, preserving the input's order.""" import sys import fileinput def main(): input_lines = { } # Since Python 3.7, dicts preserve insertion order. for line in fileinput.input(): input_lines[line] = True for line in input_lines: sys.stdout.write(line) if __name__ == '__main__': main()