Jul-29-2019, 05:38 AM
i did some experimenting and found that i can exploit open()'s ability to open a file descriptor as a file to change the mode of a pipe from subprocess.Popen() or os.pipe(). here is how i tried it:
#!/usr/bin/env python3 import os from subprocess import PIPE,Popen proc = Popen(['bash','-c','exec xz -9 >tryout.xz'],stdin=PIPE) ofd = proc.stdin.fileno() prt = open(ofd,'w') print('foobar',file=prt) prt.close() proc.wait() proc = Popen(['bash','-c','exec xzdec <tryout.xz'],stdout=PIPE) ifd = proc.stdout.fileno() look = open(ifd,'r') lines = look.readlines() print(repr(lines)) look.close() proc.wait()so, i don't need to convert to bytes to output to a pipe, and can input a regular string from a pipe. i assume anything else that comes as a binary mode file can be done the same.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.