Skip to content

Instantly share code, notes, and snippets.

@iorlas
Created February 2, 2011 11:23
Show Gist options
  • Save iorlas/807565 to your computer and use it in GitHub Desktop.
Save iorlas/807565 to your computer and use it in GitHub Desktop.
#!/bin/python -u
import os, sys, time, math
local = ['alns', 'lns', 's']
#pipe collectors
alns = ''
lns = []
s = None
#pipe catching
while True:
line = sys.stdin.readline()
if line:
lns.append(line)
alns += line
s = line
else:
break
#time.sleep(1) #wait for others
#some shortcuts
def o(smthng):
sys.stdout.write(str(smthng))
sys.stdout.flush()
local += ['o']
ret = eval(sys.argv[1]) or ''
o(ret)
sys.stdout.close()
sys.stdin.close()
#use it from sh like:
# ls | python pype.py "', '.join(map(lambda x: x[:-1], lns))" #gets all files, separated by comma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment