¡@

Home 

python Programming Glossary: sys.stdin

Python C program subprocess hangs at “for line in iter”

http://stackoverflow.com/questions/20503671/python-c-program-subprocess-hangs-at-for-line-in-iter

os.fdopen master_fd 'r b' 0 as master input_fds master sys.stdin while True fds select input_fds timeout 0 if master in fds #.. os.write sys.stdout.fileno data # copy to our stdout if sys.stdin in fds # got user input data os.read sys.stdin.fileno 512 if.. stdout if sys.stdin in fds # got user input data os.read sys.stdin.fileno 512 if not data input_fds.remove sys.stdin else master.write..

Python nonblocking console input

http://stackoverflow.com/questions/2408560/python-nonblocking-console-input

import tty import termios def isData return select.select sys.stdin 0 sys.stdin old_settings termios.tcgetattr sys.stdin try tty.setcbreak.. import termios def isData return select.select sys.stdin 0 sys.stdin old_settings termios.tcgetattr sys.stdin try tty.setcbreak sys.stdin.fileno.. sys.stdin 0 sys.stdin old_settings termios.tcgetattr sys.stdin try tty.setcbreak sys.stdin.fileno i 0 while 1 print i i 1 if..

How to capture Python interpreter's and/or CMD.EXE's output from a Python script?

http://stackoverflow.com/questions/24931/how-to-capture-python-interpreters-and-or-cmd-exes-output-from-a-python-script

do something like this import sys x sys.stderr.readline y sys.stdin.readline sys.stdin and sys.stdout are standard file objects.. this import sys x sys.stderr.readline y sys.stdin.readline sys.stdin and sys.stdout are standard file objects as noted above defined..

How do I use subprocess.Popen to connect multiple processes by pipes?

http://stackoverflow.com/questions/295459/how-do-i-use-subprocess-popen-to-connect-multiple-processes-by-pipes

Python has os.pipe os.exec and os.fork and you can replace sys.stdin and sys.stdout there's a way to do the above in pure Python...

What is the python “with” statement designed for? [closed]

http://stackoverflow.com/questions/3012488/what-is-the-python-with-statement-designed-for

Here's another example that temporarily redirects sys.stdin sys.stdout and sys.stderr to some other file handle and restores..

raw_input and timeout

http://stackoverflow.com/questions/3471461/raw-input-and-timeout

select timeout 10 print Enter something rlist _ _ select sys.stdin timeout if rlist s sys.stdin.readline print s else print No.. something rlist _ _ select sys.stdin timeout if rlist s sys.stdin.readline print s else print No input. Moving on... share improve..

Setting smaller buffer size for sys.stdin?

http://stackoverflow.com/questions/3670323/setting-smaller-buffer-size-for-sys-stdin

smaller buffer size for sys.stdin I'm running memcached with the following bash command pattern.. int GET 1 SET 2 CLIENT 1 SERVER 2 #if for line in sys.stdin key None components line.strip .split #newConn components 0.. lines readlines and file object iterators for line in sys.stdin which is not influenced by this option. To work around this..

Setting the correct encoding when piping stdout in python

http://stackoverflow.com/questions/492483/setting-the-correct-encoding-when-piping-stdout-in-python

everything uppercase in between. import sys for line in sys.stdin # decode what you receive line line.decode 'iso8859 1' # work..

Python cross-platform listening for keypresses?

http://stackoverflow.com/questions/5044073/python-cross-platform-listening-for-keypresses

FAQ. You could experiment a bit with blocking reads from sys.stdin and threading . But this may only work on Unix. On Windows you.. ImportError import termios fcntl sys os def kbhit fd sys.stdin.fileno oldterm termios.tcgetattr fd newattr termios.tcgetattr.. oldflags os.O_NONBLOCK try while True try c sys.stdin.read 1 return True except IOError return False finally termios.tcsetattr..

Python (Windows) - ImportError: No module named site

http://stackoverflow.com/questions/5599872/python-windows-importerror-no-module-named-site

#clear sys.flags #clear sys.float_info #restore sys.stdin #restore sys.stdout #restore sys.stderr #cleanup main #cleanup..

Why is reading lines from stdin much slower in C++ than Python?

http://stackoverflow.com/questions/9371238/why-is-reading-lines-from-stdin-much-slower-in-c-than-python

import time import sys count 0 start time.time for line in sys.stdin count 1 delta_sec int time.time start_time if delta_sec 0 lines_per_sec.. 16384 count sum chunk.count ' n' for chunk in iter partial sys.stdin.read BUFFER_SIZE '' The performance of this version is quite..

Why is splitting a string slower in C++ than Python?

http://stackoverflow.com/questions/9378500/why-is-splitting-a-string-slower-in-c-than-python

sys count 0 start_time time.time dummy None for line in sys.stdin dummy line.split count 1 delta_sec int time.time start_time.. it's a bit closer. Basically the loop is now for line in sys.stdin dummy dummy line.split count 1 The performance of python is..