You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
343 B
20 lines
343 B
13 years ago
|
#!/usr/bin/env python
|
||
|
|
||
|
# randomize the lines of stdin or a file
|
||
|
|
||
|
import random, sys
|
||
|
|
||
|
def main():
|
||
|
if len(sys.argv) > 1:
|
||
|
fname = sys.argv[1]
|
||
|
inf = open(fname, 'r')
|
||
|
else:
|
||
|
inf = sys.stdin
|
||
|
|
||
|
lines = inf.readlines()
|
||
|
random.shuffle(lines)
|
||
|
sys.stdout.writelines(lines)
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|