¡@

Home 

python Programming Glossary: os.dup

Suppressing output of module calling outside library

http://stackoverflow.com/questions/4178614/suppressing-output-of-module-calling-outside-library

improve this question Open dev null for writing use os.dup to copy stdout and use os.dup2 to copy your open dev null to.. dev null for writing use os.dup to copy stdout and use os.dup2 to copy your open dev null to stdout. Use os.dup2 to copy your.. and use os.dup2 to copy your open dev null to stdout. Use os.dup2 to copy your copied stdout back to the real stdout after. devnull..

How do I prevent a C shared library to print on stdout in python?

http://stackoverflow.com/questions/5081657/how-do-i-prevent-a-c-shared-library-to-print-on-stdout-in-python

word is always printed tempfile open mktemp 'w' savestdout os.dup 1 os.close 1 if os.dup tempfile.fileno 1 assert False couldn't.. tempfile open mktemp 'w' savestdout os.dup 1 os.close 1 if os.dup tempfile.fileno 1 assert False couldn't redirect stdout dup.. a call to my library libc.printf hello world n os.close 1 os.dup savestdout os.close savestdout This first approach is half working..

Redirect stdout from python for C calls

http://stackoverflow.com/questions/8804893/redirect-stdout-from-python-for-c-calls

# important when redirecting to files 4. newstdout os.dup 1 5. devnull os.open ' dev null' os.O_WRONLY 6. os.dup2 devnull.. os.dup 1 5. devnull os.open ' dev null' os.O_WRONLY 6. os.dup2 devnull 1 7. os.close devnull 8. sys.stdout os.fdopen newstdout.. 1 # to a different file descriptor number newstdout os.dup 1 # dev null is used just to discard what is being printed devnull..

Is there any way to pass 'stdin' as an argument to another process in python?

http://stackoverflow.com/questions/8976962/is-there-any-way-to-pass-stdin-as-an-argument-to-another-process-in-python

do_more_things If the above doesn't help you could try os.dup newstdin os.fdopen os.dup sys.stdin.fileno try p Process target.. above doesn't help you could try os.dup newstdin os.fdopen os.dup sys.stdin.fileno try p Process target get_input args newstdin..

Redirecting FORTRAN (called via F2PY) output in Python

http://stackoverflow.com/questions/977840/redirecting-fortran-called-via-f2py-output-in-python

2 # save the current file descriptors to a tuple save os.dup 1 os.dup 2 # put dev null fds on 1 and 2 os.dup2 null_fds 0.. save the current file descriptors to a tuple save os.dup 1 os.dup 2 # put dev null fds on 1 and 2 os.dup2 null_fds 0 1 os.dup2.. tuple save os.dup 1 os.dup 2 # put dev null fds on 1 and 2 os.dup2 null_fds 0 1 os.dup2 null_fds 1 2 # run the function fortran_function..