Toggle navigation
Images.Elk.pl
termios Example
8.8.1 Example
Python Library Reference
Previous: 8.8 termios
Up: 8.8 termios
Next: 8.9 TERMIOS
8.8.1 Example
Here's a function that prompts for a password with echoing turned
off. Note the technique using a separate tcgetattr() call
and a try ... finally statement to ensure that the
old tty attributes are restored exactly no matter what happens:
def getpass(prompt = "Password: "):
import termios, TERMIOS, sys
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
new = termios.tcgetattr(fd)
new[3] = new[3] & ~TERMIOS.ECHO # lflags
try:
termios.tcsetattr(fd, TERMIOS.TCSADRAIN, new)
passwd = raw_input(prompt)
finally:
termios.tcsetattr(fd, TERMIOS.TCSADRAIN, old)
return passwd
Python Library Reference
Previous: 8.8 termios
Up: 8.8 termios
Next: 8.9 TERMIOS
See About this document... for information on suggesting changes.
Wyszukiwarka
Podobne podstrony:
general training example writing 6 10
Project manager CV example 1
Example01
group convolution example
drugs for youth via internet and the example of mephedrone tox lett 2011 j toxlet 2010 12 014
group matrix example
MSP430x13x, MSP430F14x, MSP430F15x, MSP430F16x Code Examples TI COM ?T140?molist C
pickle example
Source Program Information EXAMPLE
examples
examples ?cident records
The Social EconomyBR The dynamics of the social economyBR Example of Basta Arbetskooperativ
WiDaF test examples
więcej podobnych podstron