args = ['awk', '/^\\s*word/ { print $1}', 'anyfile.py']
p = sp.Popen(args, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE)
print(p.stdout.read())
How to check if a string is at the beginning of line in spite of tabs or whitespaces?