[clug] Thursday afternoon Perl/bash golf time

Andrew Janke a.janke at gmail.com
Thu Oct 1 06:57:43 UTC 2015


Because I like dragging old threads out....

I now happen to be writing python and am using Carlos suggestion below
to read binary data from a series of files, I now however want to
write this binary data to the STDIN of a subprocess call.

ie:

# do something magical to init the raw FD.
...

call(str(x) for x in cmd), stdin=raw)

for block in read_blocks(spoolfiles[start_spool_idx:stop_spool_idx]):
        raw.write(block)


Is there a "correct" way to do this in python? seems to be conflicting
information out there regarding subprocess.POpen and friends.

ta


a


On 12 June 2015 at 10:31, Carlo Hamalainen <carlo at carlo-hamalainen.net> wrote:
> I would have recommended the Python library "fileinput" but it is
> strongly oriented towards iterating over lines in a collection of files,
> so joining binary files won't work.
>
> Instead, read chunks from the input files in a list and write to the
> output file.
>
> https://gist.github.com/carlohamalainen/14aedb34be4f862334a4



More information about the linux mailing list