python Programming Glossary: sys.stdin.read
Reading a single character (getch style) in Python is not working in Unix http://stackoverflow.com/questions/1052107/reading-a-single-character-getch-style-in-python-is-not-working-in-unix termios.tcgetattr fd try tty.setraw sys.stdin.fileno ch sys.stdin.read 1 finally termios.tcsetattr fd termios.TCSADRAIN old_settings..
Post JSON to Python CGI http://stackoverflow.com/questions/10718572/post-json-to-python-cgi 'true' 'message' 'The Command Completed Successfully' data sys.stdin.read myjson json.loads data return str myjson jquery python html..
Pipe output from shell command to a python script http://stackoverflow.com/questions/11109859/pipe-output-from-shell-command-to-a-python-script python import sys def hello variable print variable data sys.stdin.read hello data If all you want to do here is grab some data from..
How to do “hit any key” in python? http://stackoverflow.com/questions/1394956/how-to-do-hit-any-key-in-python old termios.tcgetattr fd try tty.setraw fd return sys.stdin.read 1 finally termios.tcsetattr fd termios.TCSADRAIN old share..
embedding short python scripts inside a bash script http://stackoverflow.com/questions/2189098/embedding-short-python-scripts-inside-a-bash-script function pyexec echo usr bin python c 'import sys exec sys.stdin.read ' function traildirs pyexec END trail int ' 1 3 ' import os..
Python nonblocking console input http://stackoverflow.com/questions/2408560/python-nonblocking-console-input sys.stdin.fileno i 0 while 1 print i i 1 if isData c sys.stdin.read 1 if c ' x1b' # x1b is ESC break finally termios.tcsetattr..
Why can't I handle a KeyboardInterrupt in python? http://stackoverflow.com/questions/4606942/why-cant-i-handle-a-keyboardinterrupt-in-python the comments I replaced the contents of the try block with sys.stdin.read . The problem still occurs exactly as described with the first.. after the read the handler works. So this fails try sys.stdin.read except KeyboardInterrupt ... But this works try sys.stdin.read.. except KeyboardInterrupt ... But this works try sys.stdin.read print Done reading. except KeyboardInterrupt ... Here's what's..
Python cross-platform listening for keypresses? http://stackoverflow.com/questions/5044073/python-cross-platform-listening-for-keypresses oldflags os.O_NONBLOCK try while True try c sys.stdin.read 1 return True except IOError return False finally termios.tcsetattr..
Python read a single character from the user http://stackoverflow.com/questions/510357/python-read-a-single-character-from-the-user termios.tcgetattr fd try tty.setraw sys.stdin.fileno ch sys.stdin.read 1 finally termios.tcsetattr fd termios.TCSADRAIN old_settings..
How to obtain the keycodes in Python http://stackoverflow.com/questions/575650/how-to-obtain-the-keycodes-in-python import tty tty.setcbreak sys.stdin while True print ord sys.stdin.read 1 Note solution is Unix including Linux only. Edit On Windows..
Assignment Condition in Python While Loop http://stackoverflow.com/questions/7780998/assignment-condition-in-python-while-loop while i a b but in Python it appears one cannot. while i sys.stdin.read 1 n generates while i sys.stdin.read 1 n ^ SyntaxError invalid.. one cannot. while i sys.stdin.read 1 n generates while i sys.stdin.read 1 n ^ SyntaxError invalid syntax the ^ should be on the Is there..
How does one encode and decode a string with Python for use in a URL? http://stackoverflow.com/questions/875771/how-does-one-encode-and-decode-a-string-with-python-for-use-in-a-url example import base64 import sys encoded base64.b64encode sys.stdin.read print encoded decoded base64.b64decode encoded print decoded..
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 16384 count sum chunk.count ' n' for chunk in iter partial sys.stdin.read BUFFER_SIZE '' The performance of this version is quite fast..
|