Last active
July 24, 2018 23:36
-
-
Save innateessence/b655ea039a75c91e0a474b8e8fe9feac to your computer and use it in GitHub Desktop.
uniq.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
''' | |
Demonstration of how simple it can be to recreate | |
core functionality of various tools within python | |
''' | |
from sys import stdin, stdout, argv | |
class Uniq: | |
def __init__(self): | |
self.args = argv | |
self.lines = [] | |
if len(argv) == 1 or '--' in argv: | |
self.output() | |
def output(self): | |
for line in stdin.readlines(): | |
if line not in self.lines: | |
stdout.write(line) | |
self.lines.append(line) | |
if __name__ == '__main__': | |
Uniq() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment