mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Remove all definitions of raw_input() that were still scattered throughout the docs
from the time where there was neither input() nor raw_input().
This commit is contained in:
parent
2b1c592d22
commit
8d5c39240e
6 changed files with 8 additions and 37 deletions
|
@ -47,14 +47,8 @@ A simple example illustrating typical use::
|
||||||
|
|
||||||
import crypt, getpass, pwd
|
import crypt, getpass, pwd
|
||||||
|
|
||||||
def raw_input(prompt):
|
|
||||||
import sys
|
|
||||||
sys.stdout.write(prompt)
|
|
||||||
sys.stdout.flush()
|
|
||||||
return sys.stdin.readline()
|
|
||||||
|
|
||||||
def login():
|
def login():
|
||||||
username = raw_input('Python login:')
|
username = input('Python login:')
|
||||||
cryptedpasswd = pwd.getpwnam(username)[1]
|
cryptedpasswd = pwd.getpwnam(username)[1]
|
||||||
if cryptedpasswd:
|
if cryptedpasswd:
|
||||||
if cryptedpasswd == 'x' or cryptedpasswd == '*':
|
if cryptedpasswd == 'x' or cryptedpasswd == '*':
|
||||||
|
|
|
@ -306,14 +306,8 @@ example doesn't do any processing of the :rfc:`822` headers. In particular, the
|
||||||
|
|
||||||
import smtplib
|
import smtplib
|
||||||
|
|
||||||
def raw_input(prompt):
|
|
||||||
import sys
|
|
||||||
sys.stdout.write(prompt)
|
|
||||||
sys.stdout.flush()
|
|
||||||
return sys.stdin.readline()
|
|
||||||
|
|
||||||
def prompt(prompt):
|
def prompt(prompt):
|
||||||
return raw_input(prompt).strip()
|
return input(prompt).strip()
|
||||||
|
|
||||||
fromaddr = prompt("From: ")
|
fromaddr = prompt("From: ")
|
||||||
toaddrs = prompt("To: ").split()
|
toaddrs = prompt("To: ").split()
|
||||||
|
@ -324,7 +318,7 @@ example doesn't do any processing of the :rfc:`822` headers. In particular, the
|
||||||
% (fromaddr, ", ".join(toaddrs)))
|
% (fromaddr, ", ".join(toaddrs)))
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
line = raw_input()
|
line = input()
|
||||||
except EOFError:
|
except EOFError:
|
||||||
break
|
break
|
||||||
if not line:
|
if not line:
|
||||||
|
|
|
@ -211,16 +211,10 @@ Telnet Example
|
||||||
A simple example illustrating typical use::
|
A simple example illustrating typical use::
|
||||||
|
|
||||||
import getpass
|
import getpass
|
||||||
import sys
|
|
||||||
import telnetlib
|
import telnetlib
|
||||||
|
|
||||||
def raw_input(prompt):
|
|
||||||
sys.stdout.write(prompt)
|
|
||||||
sys.stdout.flush()
|
|
||||||
return sys.stdin.readline()
|
|
||||||
|
|
||||||
HOST = "localhost"
|
HOST = "localhost"
|
||||||
user = raw_input("Enter your remote account: ")
|
user = input("Enter your remote account: ")
|
||||||
password = getpass.getpass()
|
password = getpass.getpass()
|
||||||
|
|
||||||
tn = telnetlib.Telnet(HOST)
|
tn = telnetlib.Telnet(HOST)
|
||||||
|
|
|
@ -90,12 +90,6 @@ technique using a separate :func:`tcgetattr` call and a :keyword:`try` ...
|
||||||
:keyword:`finally` statement to ensure that the old tty attributes are restored
|
:keyword:`finally` statement to ensure that the old tty attributes are restored
|
||||||
exactly no matter what happens::
|
exactly no matter what happens::
|
||||||
|
|
||||||
def raw_input(prompt):
|
|
||||||
import sys
|
|
||||||
sys.stdout.write(prompt)
|
|
||||||
sys.stdout.flush()
|
|
||||||
return sys.stdin.readline()
|
|
||||||
|
|
||||||
def getpass(prompt = "Password: "):
|
def getpass(prompt = "Password: "):
|
||||||
import termios, sys
|
import termios, sys
|
||||||
fd = sys.stdin.fileno()
|
fd = sys.stdin.fileno()
|
||||||
|
@ -104,7 +98,7 @@ exactly no matter what happens::
|
||||||
new[3] = new[3] & ~termios.ECHO # lflags
|
new[3] = new[3] & ~termios.ECHO # lflags
|
||||||
try:
|
try:
|
||||||
termios.tcsetattr(fd, termios.TCSADRAIN, new)
|
termios.tcsetattr(fd, termios.TCSADRAIN, new)
|
||||||
passwd = raw_input(prompt)
|
passwd = input(prompt)
|
||||||
finally:
|
finally:
|
||||||
termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
||||||
return passwd
|
return passwd
|
||||||
|
|
|
@ -143,7 +143,7 @@ module. ::
|
||||||
import sys, traceback
|
import sys, traceback
|
||||||
|
|
||||||
def run_user_code(envdir):
|
def run_user_code(envdir):
|
||||||
source = raw_input(">>> ")
|
source = input(">>> ")
|
||||||
try:
|
try:
|
||||||
exec(source, envdir)
|
exec(source, envdir)
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -104,16 +104,11 @@ Template subclasses can specify a custom delimiter. For example, a batch
|
||||||
renaming utility for a photo browser may elect to use percent signs for
|
renaming utility for a photo browser may elect to use percent signs for
|
||||||
placeholders such as the current date, image sequence number, or file format::
|
placeholders such as the current date, image sequence number, or file format::
|
||||||
|
|
||||||
>>> import time, os.path, sys
|
>>> import time, os.path
|
||||||
>>> def raw_input(prompt):
|
|
||||||
... sys.stdout.write(prompt)
|
|
||||||
... sys.stdout.flush()
|
|
||||||
... return sys.stdin.readline()
|
|
||||||
...
|
|
||||||
>>> photofiles = ['img_1074.jpg', 'img_1076.jpg', 'img_1077.jpg']
|
>>> photofiles = ['img_1074.jpg', 'img_1076.jpg', 'img_1077.jpg']
|
||||||
>>> class BatchRename(Template):
|
>>> class BatchRename(Template):
|
||||||
... delimiter = '%'
|
... delimiter = '%'
|
||||||
>>> fmt = raw_input('Enter rename style (%d-date %n-seqnum %f-format): ')
|
>>> fmt = input('Enter rename style (%d-date %n-seqnum %f-format): ')
|
||||||
Enter rename style (%d-date %n-seqnum %f-format): Ashley_%n%f
|
Enter rename style (%d-date %n-seqnum %f-format): Ashley_%n%f
|
||||||
|
|
||||||
>>> t = BatchRename(fmt)
|
>>> t = BatchRename(fmt)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue