Get rid of a bunch more raw_input references
This commit is contained in:
parent
9e2b9665ae
commit
ce96f69d69
|
@ -6,6 +6,11 @@ import FSProxy
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
pwd = os.getcwd()
|
pwd = os.getcwd()
|
||||||
s = raw_input("chdir [%s] " % pwd)
|
s = raw_input("chdir [%s] " % pwd)
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
import sys
|
import sys
|
||||||
import string
|
|
||||||
import rcvs
|
import rcvs
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
line = raw_input('$ ')
|
line = raw_input('$ ')
|
||||||
except EOFError:
|
except EOFError:
|
||||||
break
|
break
|
||||||
words = string.split(line)
|
words = line.split()
|
||||||
if not words:
|
if not words:
|
||||||
continue
|
continue
|
||||||
if words[0] != 'rcvs':
|
if words[0] != 'rcvs':
|
||||||
|
@ -16,4 +20,5 @@ def main():
|
||||||
sys.argv = words
|
sys.argv = words
|
||||||
rcvs.main()
|
rcvs.main()
|
||||||
|
|
||||||
main()
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
from cvslib import CVS, File
|
from cvslib import CVS, File
|
||||||
import md5
|
import md5
|
||||||
import os
|
import os
|
||||||
import string
|
|
||||||
import sys
|
import sys
|
||||||
from cmdfw import CommandFrameWork
|
from cmdfw import CommandFrameWork
|
||||||
|
|
||||||
|
@ -269,13 +268,13 @@ class RCVS(CVS):
|
||||||
|
|
||||||
def mailinfo(self, files, message = ""):
|
def mailinfo(self, files, message = ""):
|
||||||
towhom = "sjoerd@cwi.nl, jack@cwi.nl" # XXX
|
towhom = "sjoerd@cwi.nl, jack@cwi.nl" # XXX
|
||||||
mailtext = MAILFORM % (towhom, string.join(files),
|
mailtext = MAILFORM % (towhom, ' '.join(files),
|
||||||
string.join(files), message)
|
' '.join(files), message)
|
||||||
print '-'*70
|
print '-'*70
|
||||||
print mailtext
|
print mailtext
|
||||||
print '-'*70
|
print '-'*70
|
||||||
ok = raw_input("OK to mail to %s? " % towhom)
|
ok = raw_input("OK to mail to %s? " % towhom)
|
||||||
if string.lower(string.strip(ok)) in ('y', 'ye', 'yes'):
|
if ok.lower().strip() in ('y', 'ye', 'yes'):
|
||||||
p = os.popen(SENDMAIL, "w")
|
p = os.popen(SENDMAIL, "w")
|
||||||
p.write(mailtext)
|
p.write(mailtext)
|
||||||
sts = p.close()
|
sts = p.close()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
import FSProxy
|
import FSProxy
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -9,7 +10,9 @@ def main():
|
||||||
proxy._close()
|
proxy._close()
|
||||||
t2 = time.time()
|
t2 = time.time()
|
||||||
print t2-t1, "seconds"
|
print t2-t1, "seconds"
|
||||||
raw_input("[Return to exit] ")
|
sys.stdout.write("[Return to exit] ")
|
||||||
|
sys.stdout.flush()
|
||||||
|
sys.stdin.readline()
|
||||||
|
|
||||||
def sumtree(proxy):
|
def sumtree(proxy):
|
||||||
print "PWD =", proxy.pwd()
|
print "PWD =", proxy.pwd()
|
||||||
|
|
|
@ -9,6 +9,11 @@ import sys
|
||||||
import time
|
import time
|
||||||
import calendar
|
import calendar
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Note that the range checks below also check for bad types,
|
# Note that the range checks below also check for bad types,
|
||||||
# e.g. 3.14 or (). However syntactically invalid replies
|
# e.g. 3.14 or (). However syntactically invalid replies
|
||||||
|
|
|
@ -130,6 +130,11 @@ def getdata(r):
|
||||||
sys.stdout.write(data)
|
sys.stdout.write(data)
|
||||||
print '(end of data connection)'
|
print '(end of data connection)'
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
# Get a command from the user.
|
# Get a command from the user.
|
||||||
#
|
#
|
||||||
def getcommand():
|
def getcommand():
|
||||||
|
@ -143,4 +148,5 @@ def getcommand():
|
||||||
|
|
||||||
# Call the main program.
|
# Call the main program.
|
||||||
#
|
#
|
||||||
main()
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#
|
#
|
||||||
# Usage: gopher [ [selector] host [port] ]
|
# Usage: gopher [ [selector] host [port] ]
|
||||||
|
|
||||||
import string
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
@ -42,7 +41,7 @@ def open_socket(host, port):
|
||||||
if not port:
|
if not port:
|
||||||
port = DEF_PORT
|
port = DEF_PORT
|
||||||
elif type(port) == type(''):
|
elif type(port) == type(''):
|
||||||
port = string.atoi(port)
|
port = int(port)
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
s.connect((host, port))
|
s.connect((host, port))
|
||||||
return s
|
return s
|
||||||
|
@ -73,7 +72,7 @@ def get_menu(selector, host, port):
|
||||||
print '(Empty line from server)'
|
print '(Empty line from server)'
|
||||||
continue
|
continue
|
||||||
typechar = line[0]
|
typechar = line[0]
|
||||||
parts = string.splitfields(line[1:], TAB)
|
parts = line[1:].split(TAB)
|
||||||
if len(parts) < 4:
|
if len(parts) < 4:
|
||||||
print '(Bad line from server: %r)' % (line,)
|
print '(Bad line from server: %r)' % (line,)
|
||||||
continue
|
continue
|
||||||
|
@ -160,7 +159,7 @@ def browse_menu(selector, host, port):
|
||||||
for i in range(len(list)):
|
for i in range(len(list)):
|
||||||
item = list[i]
|
item = list[i]
|
||||||
typechar, description = item[0], item[1]
|
typechar, description = item[0], item[1]
|
||||||
print string.rjust(repr(i+1), 3) + ':', description,
|
print repr(i+1).rjust(3) + ':', description,
|
||||||
if typename.has_key(typechar):
|
if typename.has_key(typechar):
|
||||||
print typename[typechar]
|
print typename[typechar]
|
||||||
else:
|
else:
|
||||||
|
@ -175,8 +174,8 @@ def browse_menu(selector, host, port):
|
||||||
if not str:
|
if not str:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
choice = string.atoi(str)
|
choice = int(str)
|
||||||
except string.atoi_error:
|
except ValueError:
|
||||||
print 'Choice must be a number; try again:'
|
print 'Choice must be a number; try again:'
|
||||||
continue
|
continue
|
||||||
if not 0 < choice <= len(list):
|
if not 0 < choice <= len(list):
|
||||||
|
@ -218,6 +217,11 @@ def browse_textfile(selector, host, port):
|
||||||
print 'IOError:', msg
|
print 'IOError:', msg
|
||||||
x.close()
|
x.close()
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
# Browse a search index
|
# Browse a search index
|
||||||
def browse_search(selector, host, port):
|
def browse_search(selector, host, port):
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -230,7 +234,7 @@ def browse_search(selector, host, port):
|
||||||
except EOFError:
|
except EOFError:
|
||||||
print
|
print
|
||||||
break
|
break
|
||||||
query = string.strip(query)
|
query = query.strip()
|
||||||
if not query:
|
if not query:
|
||||||
break
|
break
|
||||||
if '\t' in query:
|
if '\t' in query:
|
||||||
|
@ -300,11 +304,11 @@ def open_savefile():
|
||||||
except EOFError:
|
except EOFError:
|
||||||
print
|
print
|
||||||
return None
|
return None
|
||||||
savefile = string.strip(savefile)
|
savefile = savefile.strip()
|
||||||
if not savefile:
|
if not savefile:
|
||||||
return None
|
return None
|
||||||
if savefile[0] == '|':
|
if savefile[0] == '|':
|
||||||
cmd = string.strip(savefile[1:])
|
cmd = savefile[1:].strip()
|
||||||
try:
|
try:
|
||||||
p = os.popen(cmd, 'w')
|
p = os.popen(cmd, 'w')
|
||||||
except IOError, msg:
|
except IOError, msg:
|
||||||
|
@ -331,10 +335,10 @@ def test():
|
||||||
browser(sys.argv[1], sys.argv[2], sys.argv[3])
|
browser(sys.argv[1], sys.argv[2], sys.argv[3])
|
||||||
elif sys.argv[2:]:
|
elif sys.argv[2:]:
|
||||||
try:
|
try:
|
||||||
port = string.atoi(sys.argv[2])
|
port = int(sys.argv[2])
|
||||||
selector = ''
|
selector = ''
|
||||||
host = sys.argv[1]
|
host = sys.argv[1]
|
||||||
except string.atoi_error:
|
except ValueError:
|
||||||
selector = sys.argv[1]
|
selector = sys.argv[1]
|
||||||
host = sys.argv[2]
|
host = sys.argv[2]
|
||||||
port = ''
|
port = ''
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import _tkinter
|
import _tkinter
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1)
|
tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1)
|
||||||
tk.call('update')
|
tk.call('update')
|
||||||
|
@ -12,7 +13,9 @@ while 1:
|
||||||
if cmd: prompt = ''
|
if cmd: prompt = ''
|
||||||
else: prompt = '% '
|
else: prompt = '% '
|
||||||
try:
|
try:
|
||||||
line = raw_input(prompt)
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
line = sys.stdin.readline()
|
||||||
except EOFError:
|
except EOFError:
|
||||||
break
|
break
|
||||||
cmd = cmd + (line + '\n')
|
cmd = cmd + (line + '\n')
|
||||||
|
|
|
@ -186,13 +186,3 @@ The character used to draw separator lines under the help-message
|
||||||
headers. If empty, no ruler line is drawn. It defaults to
|
headers. If empty, no ruler line is drawn. It defaults to
|
||||||
\character{=}.
|
\character{=}.
|
||||||
\end{memberdesc}
|
\end{memberdesc}
|
||||||
|
|
||||||
\begin{memberdesc}{use_rawinput}
|
|
||||||
A flag, defaulting to true. If true, \method{cmdloop()} uses
|
|
||||||
\function{raw_input()} to display a prompt and read the next command;
|
|
||||||
if false, \method{sys.stdout.write()} and
|
|
||||||
\method{sys.stdin.readline()} are used. (This means that by
|
|
||||||
importing \refmodule{readline}, on systems that support it, the
|
|
||||||
interpreter will automatically support \program{Emacs}-like line editing
|
|
||||||
and command-history keystrokes.)
|
|
||||||
\end{memberdesc}
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ Remove any unhandled source text from the input buffer.
|
||||||
\begin{methoddesc}{raw_input}{\optional{prompt}}
|
\begin{methoddesc}{raw_input}{\optional{prompt}}
|
||||||
Write a prompt and read a line. The returned line does not include
|
Write a prompt and read a line. The returned line does not include
|
||||||
the trailing newline. When the user enters the \EOF{} key sequence,
|
the trailing newline. When the user enters the \EOF{} key sequence,
|
||||||
\exception{EOFError} is raised. The base implementation uses the
|
\exception{EOFError} is raised. The base implementation reads from
|
||||||
built-in function \function{raw_input()}; a subclass may replace this
|
\code{sys.stdin}; a subclass may replace this
|
||||||
with a different implementation.
|
with a different implementation.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
|
@ -41,6 +41,12 @@ A simple example illustrating typical use:
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
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 = raw_input('Python login:')
|
||||||
cryptedpasswd = pwd.getpwnam(username)[1]
|
cryptedpasswd = pwd.getpwnam(username)[1]
|
||||||
|
|
|
@ -153,9 +153,7 @@ Raised when an \keyword{assert} statement fails.
|
||||||
|
|
||||||
\begin{excdesc}{EOFError}
|
\begin{excdesc}{EOFError}
|
||||||
% XXXJH xrefs here
|
% XXXJH xrefs here
|
||||||
Raised when one of the built-in functions (\function{input()} or
|
Raised when attempting to read beyond the end of a file.
|
||||||
\function{raw_input()}) hits an end-of-file condition (\EOF) without
|
|
||||||
reading any data.
|
|
||||||
% XXXJH xrefs here
|
% XXXJH xrefs here
|
||||||
(N.B.: the \method{read()} and \method{readline()} methods of file
|
(N.B.: the \method{read()} and \method{readline()} methods of file
|
||||||
objects return an empty string when they hit \EOF.)
|
objects return an empty string when they hit \EOF.)
|
||||||
|
@ -213,9 +211,6 @@ Raised when an \keyword{assert} statement fails.
|
||||||
\kbd{Control-C} or \kbd{Delete}). During execution, a check for
|
\kbd{Control-C} or \kbd{Delete}). During execution, a check for
|
||||||
interrupts is made regularly.
|
interrupts is made regularly.
|
||||||
% XXX(hylton) xrefs here
|
% XXX(hylton) xrefs here
|
||||||
Interrupts typed when a built-in function \function{input()} or
|
|
||||||
\function{raw_input()} is waiting for input also raise this
|
|
||||||
exception.
|
|
||||||
The exception inherits from \exception{BaseException} so as to not be
|
The exception inherits from \exception{BaseException} so as to not be
|
||||||
accidentally caught by code that catches \exception{Exception} and thus
|
accidentally caught by code that catches \exception{Exception} and thus
|
||||||
prevent the interpreter from exiting.
|
prevent the interpreter from exiting.
|
||||||
|
|
|
@ -551,23 +551,6 @@ class C:
|
||||||
note: this is the address of the object.)
|
note: this is the address of the object.)
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{input}{\optional{prompt}}
|
|
||||||
Equivalent to \code{eval(raw_input(\var{prompt}))}.
|
|
||||||
\warning{This function is not safe from user errors! It
|
|
||||||
expects a valid Python expression as input; if the input is not
|
|
||||||
syntactically valid, a \exception{SyntaxError} will be raised.
|
|
||||||
Other exceptions may be raised if there is an error during
|
|
||||||
evaluation. (On the other hand, sometimes this is exactly what you
|
|
||||||
need when writing a quick script for expert use.)}
|
|
||||||
|
|
||||||
If the \refmodule{readline} module was loaded, then
|
|
||||||
\function{input()} will use it to provide elaborate line editing and
|
|
||||||
history features.
|
|
||||||
|
|
||||||
Consider using the \function{raw_input()} function for general input
|
|
||||||
from users.
|
|
||||||
\end{funcdesc}
|
|
||||||
|
|
||||||
\begin{funcdesc}{int}{\optional{x\optional{, radix}}}
|
\begin{funcdesc}{int}{\optional{x\optional{, radix}}}
|
||||||
Convert a string or number to a plain integer. If the argument is a
|
Convert a string or number to a plain integer. If the argument is a
|
||||||
string, it must contain a possibly signed decimal number
|
string, it must contain a possibly signed decimal number
|
||||||
|
@ -811,24 +794,6 @@ class C(object):
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
\end{funcdesc}
|
\end{funcdesc}
|
||||||
|
|
||||||
\begin{funcdesc}{raw_input}{\optional{prompt}}
|
|
||||||
If the \var{prompt} argument is present, it is written to standard output
|
|
||||||
without a trailing newline. The function then reads a line from input,
|
|
||||||
converts it to a string (stripping a trailing newline), and returns that.
|
|
||||||
When \EOF{} is read, \exception{EOFError} is raised. Example:
|
|
||||||
|
|
||||||
\begin{verbatim}
|
|
||||||
>>> s = raw_input('--> ')
|
|
||||||
--> Monty Python's Flying Circus
|
|
||||||
>>> s
|
|
||||||
"Monty Python's Flying Circus"
|
|
||||||
\end{verbatim}
|
|
||||||
|
|
||||||
If the \refmodule{readline} module was loaded, then
|
|
||||||
\function{raw_input()} will use it to provide elaborate
|
|
||||||
line editing and history features.
|
|
||||||
\end{funcdesc}
|
|
||||||
|
|
||||||
\begin{funcdesc}{reduce}{function, sequence\optional{, initializer}}
|
\begin{funcdesc}{reduce}{function, sequence\optional{, initializer}}
|
||||||
Apply \var{function} of two arguments cumulatively to the items of
|
Apply \var{function} of two arguments cumulatively to the items of
|
||||||
\var{sequence}, from left to right, so as to reduce the sequence to
|
\var{sequence}, from left to right, so as to reduce the sequence to
|
||||||
|
|
|
@ -267,6 +267,12 @@ processing of the \rfc{822} headers. In particular, the `To' and
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
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 raw_input(prompt).strip()
|
||||||
|
|
||||||
|
|
|
@ -511,11 +511,8 @@ else:
|
||||||
\dataline{stderr}
|
\dataline{stderr}
|
||||||
File objects corresponding to the interpreter's standard input,
|
File objects corresponding to the interpreter's standard input,
|
||||||
output and error streams. \code{stdin} is used for all interpreter
|
output and error streams. \code{stdin} is used for all interpreter
|
||||||
input except for scripts but including calls to
|
input except for scripts. \code{stdout} is
|
||||||
\function{input()}\bifuncindex{input} and
|
used for the output of \keyword{print} and expression statements.
|
||||||
\function{raw_input()}\bifuncindex{raw_input}. \code{stdout} is
|
|
||||||
used for the output of \keyword{print} and expression statements and
|
|
||||||
for the prompts of \function{input()} and \function{raw_input()}.
|
|
||||||
The interpreter's own prompts and (almost all of) its error messages
|
The interpreter's own prompts and (almost all of) its error messages
|
||||||
go to \code{stderr}. \code{stdout} and \code{stderr} needn't be
|
go to \code{stderr}. \code{stdout} and \code{stderr} needn't be
|
||||||
built-in file objects: any object is acceptable as long as it has a
|
built-in file objects: any object is acceptable as long as it has a
|
||||||
|
|
|
@ -196,6 +196,11 @@ import getpass
|
||||||
import sys
|
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 = raw_input("Enter your remote account: ")
|
||||||
password = getpass.getpass()
|
password = getpass.getpass()
|
||||||
|
|
|
@ -91,6 +91,12 @@ and a \keyword{try} ... \keyword{finally} statement to ensure that the
|
||||||
old tty attributes are restored exactly no matter what happens:
|
old tty attributes are restored exactly no matter what happens:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
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()
|
||||||
|
|
|
@ -103,10 +103,7 @@ The input line read by \function{input()} must have the following form:
|
||||||
\end{productionlist}
|
\end{productionlist}
|
||||||
|
|
||||||
Note: to read `raw' input line without interpretation, you can use the
|
Note: to read `raw' input line without interpretation, you can use the
|
||||||
built-in function \function{raw_input()} or the \method{readline()} method
|
the \method{readline()} method of file objects, including \code{sys.stdin}.
|
||||||
of file objects.
|
|
||||||
\obindex{file}
|
\obindex{file}
|
||||||
\index{input!raw}
|
\index{input!raw}
|
||||||
\index{raw input}
|
|
||||||
\bifuncindex{raw_input}
|
|
||||||
\withsubitem{(file method)}{\ttindex{readline()}}
|
\withsubitem{(file method)}{\ttindex{readline()}}
|
||||||
|
|
|
@ -2,6 +2,12 @@
|
||||||
|
|
||||||
# This Python program sorts and reformats the table of keywords in ref2.tex
|
# This Python program sorts and reformats the table of keywords in ref2.tex
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
import sys
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
l = []
|
l = []
|
||||||
try:
|
try:
|
||||||
while 1:
|
while 1:
|
||||||
|
|
|
@ -231,7 +231,7 @@ full name on the command line.
|
||||||
|
|
||||||
Note that there is a difference between \samp{python file} and
|
Note that there is a difference between \samp{python file} and
|
||||||
\samp{python <file}. In the latter case, input requests from the
|
\samp{python <file}. In the latter case, input requests from the
|
||||||
program, such as calls to \function{input()} and \function{raw_input()}, are
|
program, such as calling \code{sys.stdin.read()}, are
|
||||||
satisfied from \emph{file}. Since this file has already been read
|
satisfied from \emph{file}. Since this file has already been read
|
||||||
until the end by the parser before the program starts executing, the
|
until the end by the parser before the program starts executing, the
|
||||||
program will encounter end-of-file immediately. In the former case
|
program will encounter end-of-file immediately. In the former case
|
||||||
|
@ -1161,6 +1161,12 @@ Perhaps the most well-known statement type is the
|
||||||
\keyword{if} statement. For example:
|
\keyword{if} statement. For example:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
>>> def raw_input(prompt):
|
||||||
|
... import sys
|
||||||
|
... sys.stdout.write(prompt)
|
||||||
|
... sys.stdout.flush()
|
||||||
|
... return sys.stdin.readline()
|
||||||
|
...
|
||||||
>>> x = int(raw_input("Please enter an integer: "))
|
>>> x = int(raw_input("Please enter an integer: "))
|
||||||
>>> if x < 0:
|
>>> if x < 0:
|
||||||
... x = 0
|
... x = 0
|
||||||
|
@ -1453,6 +1459,12 @@ arguments. This creates a function that can be called with fewer
|
||||||
arguments than it is defined to allow. For example:
|
arguments than it is defined to allow. For example:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
def raw_input(prompt):
|
||||||
|
import sys
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
|
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
|
||||||
while True:
|
while True:
|
||||||
ok = raw_input(prompt)
|
ok = raw_input(prompt)
|
||||||
|
@ -2711,15 +2723,15 @@ standard module \module{__builtin__}\refbimodindex{__builtin__}:
|
||||||
'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError',
|
'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError',
|
||||||
'UserWarning', 'ValueError', 'Warning', 'WindowsError',
|
'UserWarning', 'ValueError', 'Warning', 'WindowsError',
|
||||||
'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__',
|
'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__',
|
||||||
'__name__', 'abs', 'apply', 'basestring', 'bool', 'buffer',
|
'__name__', 'abs', 'basestring', 'bool', 'buffer',
|
||||||
'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile',
|
'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile',
|
||||||
'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod',
|
'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod',
|
||||||
'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float',
|
'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float',
|
||||||
'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex',
|
'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex',
|
||||||
'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter',
|
'id', 'int', 'intern', 'isinstance', 'issubclass', 'iter',
|
||||||
'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min',
|
'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min',
|
||||||
'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range',
|
'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range',
|
||||||
'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set',
|
'reduce', 'reload', 'repr', 'reversed', 'round', 'set',
|
||||||
'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super',
|
'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super',
|
||||||
'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']
|
'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
@ -3412,6 +3424,12 @@ supports); note that a user-generated interruption is signalled by
|
||||||
raising the \exception{KeyboardInterrupt} exception.
|
raising the \exception{KeyboardInterrupt} exception.
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
|
>>> def raw_input(prompt):
|
||||||
|
... import sys
|
||||||
|
... sys.stdout.write(prompt)
|
||||||
|
... sys.stdout.flush()
|
||||||
|
... return sys.stdin.readline()
|
||||||
|
...
|
||||||
>>> while True:
|
>>> while True:
|
||||||
... try:
|
... try:
|
||||||
... x = int(raw_input("Please enter a number: "))
|
... x = int(raw_input("Please enter a number: "))
|
||||||
|
@ -4983,7 +5001,12 @@ 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:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
>>> import time, os.path
|
>>> import time, os.path, sys
|
||||||
|
>>> 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 = '%'
|
||||||
|
|
10
Lib/cmd.py
10
Lib/cmd.py
|
@ -40,18 +40,20 @@ The data members `self.doc_header', `self.misc_header', and
|
||||||
`self.undoc_header' set the headers used for the help function's
|
`self.undoc_header' set the headers used for the help function's
|
||||||
listings of documented functions, miscellaneous topics, and undocumented
|
listings of documented functions, miscellaneous topics, and undocumented
|
||||||
functions respectively.
|
functions respectively.
|
||||||
|
|
||||||
These interpreters use raw_input; thus, if the readline module is loaded,
|
|
||||||
they automatically support Emacs-like command history and editing features.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import string
|
import string, sys
|
||||||
|
|
||||||
__all__ = ["Cmd"]
|
__all__ = ["Cmd"]
|
||||||
|
|
||||||
PROMPT = '(Cmd) '
|
PROMPT = '(Cmd) '
|
||||||
IDENTCHARS = string.ascii_letters + string.digits + '_'
|
IDENTCHARS = string.ascii_letters + string.digits + '_'
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
class Cmd:
|
class Cmd:
|
||||||
"""A simple framework for writing line-oriented command interpreters.
|
"""A simple framework for writing line-oriented command interpreters.
|
||||||
|
|
||||||
|
|
10
Lib/code.py
10
Lib/code.py
|
@ -269,12 +269,14 @@ class InteractiveConsole(InteractiveInterpreter):
|
||||||
The returned line does not include the trailing newline.
|
The returned line does not include the trailing newline.
|
||||||
When the user enters the EOF key sequence, EOFError is raised.
|
When the user enters the EOF key sequence, EOFError is raised.
|
||||||
|
|
||||||
The base implementation uses the built-in function
|
The base implementation uses sys.stdin.readline(); a subclass
|
||||||
raw_input(); a subclass may replace this with a different
|
may replace this with a different implementation.
|
||||||
implementation.
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return raw_input(prompt)
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def interact(banner=None, readfunc=None, local=None):
|
def interact(banner=None, readfunc=None, local=None):
|
||||||
|
|
|
@ -13,6 +13,11 @@ import StringIO, ConfigParser
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
class register(Command):
|
class register(Command):
|
||||||
|
|
||||||
description = ("register the distribution with the Python package index")
|
description = ("register the distribution with the Python package index")
|
||||||
|
|
|
@ -69,8 +69,7 @@ def default_getpass(prompt='Password: '):
|
||||||
|
|
||||||
|
|
||||||
def _raw_input(prompt=""):
|
def _raw_input(prompt=""):
|
||||||
# A raw_input() replacement that doesn't save the string in the
|
# This doesn't save the string in the GNU readline history.
|
||||||
# GNU readline history.
|
|
||||||
prompt = str(prompt)
|
prompt = str(prompt)
|
||||||
if prompt:
|
if prompt:
|
||||||
sys.stdout.write(prompt)
|
sys.stdout.write(prompt)
|
||||||
|
|
|
@ -1122,7 +1122,7 @@ class PyShell(OutputWindow):
|
||||||
self.text.tag_add("stdin", "iomark", "end-1c")
|
self.text.tag_add("stdin", "iomark", "end-1c")
|
||||||
self.text.update_idletasks()
|
self.text.update_idletasks()
|
||||||
if self.reading:
|
if self.reading:
|
||||||
self.top.quit() # Break out of recursive mainloop() in raw_input()
|
self.top.quit() # Break out of recursive mainloop()
|
||||||
else:
|
else:
|
||||||
self.runit()
|
self.runit()
|
||||||
return "break"
|
return "break"
|
||||||
|
|
|
@ -22,6 +22,11 @@ _saferepr = _repr.repr
|
||||||
__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace",
|
__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace",
|
||||||
"post_mortem", "help"]
|
"post_mortem", "help"]
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
def find_function(funcname, filename):
|
def find_function(funcname, filename):
|
||||||
cre = re.compile(r'def\s+%s\s*[(]' % funcname)
|
cre = re.compile(r'def\s+%s\s*[(]' % funcname)
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -342,6 +342,11 @@ _application_file._elemdict = {
|
||||||
# XXXX Should test more, really...
|
# XXXX Should test more, really...
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
target = AE.AECreateDesc('sign', 'quil')
|
target = AE.AECreateDesc('sign', 'quil')
|
||||||
ae = AE.AECreateAppleEvent('aevt', 'oapp', target, -1, 0)
|
ae = AE.AECreateAppleEvent('aevt', 'oapp', target, -1, 0)
|
||||||
print unpackevent(ae)
|
print unpackevent(ae)
|
||||||
|
|
|
@ -1505,6 +1505,11 @@ def writedocs(dir, pkgpath='', done=None):
|
||||||
done[modname] = 1
|
done[modname] = 1
|
||||||
writedoc(modname)
|
writedoc(modname)
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
class Helper:
|
class Helper:
|
||||||
keywords = {
|
keywords = {
|
||||||
'and': 'BOOLEAN',
|
'and': 'BOOLEAN',
|
||||||
|
|
|
@ -28,12 +28,6 @@ application (or the user) to enable this feature, I consider this an
|
||||||
acceptable risk. More complicated expressions (e.g. function calls or
|
acceptable risk. More complicated expressions (e.g. function calls or
|
||||||
indexing operations) are *not* evaluated.
|
indexing operations) are *not* evaluated.
|
||||||
|
|
||||||
- GNU readline is also used by the built-in functions input() and
|
|
||||||
raw_input(), and thus these also benefit/suffer from the completer
|
|
||||||
features. Clearly an interactive application can benefit by
|
|
||||||
specifying its own completer function and using raw_input() for all
|
|
||||||
its input.
|
|
||||||
|
|
||||||
- When the original stdin is not a tty device, GNU readline is never
|
- When the original stdin is not a tty device, GNU readline is never
|
||||||
used, and this module (and the readline module) are silently inactive.
|
used, and this module (and the readline module) are silently inactive.
|
||||||
|
|
||||||
|
|
|
@ -299,7 +299,9 @@ class _Printer(object):
|
||||||
lineno += self.MAXLINES
|
lineno += self.MAXLINES
|
||||||
key = None
|
key = None
|
||||||
while key is None:
|
while key is None:
|
||||||
key = raw_input(prompt)
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
key = sys.stdin.readline()
|
||||||
if key not in ('', 'q'):
|
if key not in ('', 'q'):
|
||||||
key = None
|
key = None
|
||||||
if key == 'q':
|
if key == 'q':
|
||||||
|
|
|
@ -44,8 +44,8 @@ fp = open(TESTFN, 'r')
|
||||||
savestdin = sys.stdin
|
savestdin = sys.stdin
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
sys.stdin = fp
|
import marshal
|
||||||
x = raw_input()
|
marshal.loads('')
|
||||||
except EOFError:
|
except EOFError:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -768,10 +768,11 @@ class FancyURLopener(URLopener):
|
||||||
|
|
||||||
def prompt_user_passwd(self, host, realm):
|
def prompt_user_passwd(self, host, realm):
|
||||||
"""Override this in a GUI environment!"""
|
"""Override this in a GUI environment!"""
|
||||||
import getpass
|
import getpass, sys
|
||||||
try:
|
try:
|
||||||
user = raw_input("Enter username for %s at %s: " % (realm,
|
sys.stdout.write("Enter username for %s at %s: " % (realm, host))
|
||||||
host))
|
sys.stdout.flush()
|
||||||
|
user = sys.stdin.readline()
|
||||||
passwd = getpass.getpass("Enter password for %s in %s at %s: " %
|
passwd = getpass.getpass("Enter password for %s in %s at %s: " %
|
||||||
(user, realm, host))
|
(user, realm, host))
|
||||||
return user, passwd
|
return user, passwd
|
||||||
|
|
|
@ -6,6 +6,12 @@ READ = 1
|
||||||
WRITE = 2
|
WRITE = 2
|
||||||
smAllScripts = -3
|
smAllScripts = -3
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
import sys
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
def copyres(src, dst):
|
def copyres(src, dst):
|
||||||
"""Copy resource from src file to dst file."""
|
"""Copy resource from src file to dst file."""
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,10 @@ morsetab = {
|
||||||
}
|
}
|
||||||
|
|
||||||
def morsecode(s):
|
def morsecode(s):
|
||||||
from string import lower
|
|
||||||
m = ''
|
m = ''
|
||||||
for c in s:
|
for c in s:
|
||||||
c = lower(c)
|
c = c.lower()
|
||||||
if morsetab.has_key(c):
|
if c in morsetab:
|
||||||
c = morsetab[c] + ' '
|
c = morsetab[c] + ' '
|
||||||
else:
|
else:
|
||||||
c = '? '
|
c = '? '
|
||||||
|
@ -107,9 +106,12 @@ class BaseMorse:
|
||||||
|
|
||||||
def sendmorse(self, s):
|
def sendmorse(self, s):
|
||||||
for c in s:
|
for c in s:
|
||||||
if c == '.': self.dot()
|
if c == '.':
|
||||||
elif c == '-': self.dah()
|
self.dot()
|
||||||
else: self.pdah()
|
elif c == '-':
|
||||||
|
self.dah()
|
||||||
|
else:
|
||||||
|
self.pdah()
|
||||||
self.pdot()
|
self.pdot()
|
||||||
|
|
||||||
def sendascii(self, s):
|
def sendascii(self, s):
|
||||||
|
@ -122,8 +124,9 @@ class BaseMorse:
|
||||||
import Audio_mac
|
import Audio_mac
|
||||||
class MyAudio(Audio_mac.Play_Audio_mac):
|
class MyAudio(Audio_mac.Play_Audio_mac):
|
||||||
def _callback(self, *args):
|
def _callback(self, *args):
|
||||||
if hasattr(self, 'usercallback'): self.usercallback()
|
if hasattr(self, 'usercallback'):
|
||||||
apply(Audio_mac.Play_Audio_mac._callback, (self,) + args)
|
self.usercallback()
|
||||||
|
Audio_mac.Play_Audio_mac._callback(self, args)
|
||||||
|
|
||||||
|
|
||||||
class MacMorse(BaseMorse):
|
class MacMorse(BaseMorse):
|
||||||
|
@ -169,12 +172,21 @@ class MacMorse(BaseMorse):
|
||||||
def usercallback(self):
|
def usercallback(self):
|
||||||
if self.morsequeue:
|
if self.morsequeue:
|
||||||
c, self.morsequeue = self.morsequeue[0], self.morsequeue[1:]
|
c, self.morsequeue = self.morsequeue[0], self.morsequeue[1:]
|
||||||
if c == '.': self.dot()
|
if c == '.':
|
||||||
elif c == '-': self.dah()
|
self.dot()
|
||||||
else: self.pdah()
|
elif c == '-':
|
||||||
|
self.dah()
|
||||||
|
else:
|
||||||
|
self.pdah()
|
||||||
self.pdot()
|
self.pdot()
|
||||||
|
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
import sys
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
m = MacMorse()
|
m = MacMorse()
|
||||||
while 1:
|
while 1:
|
||||||
|
@ -183,6 +195,8 @@ def test():
|
||||||
except (EOFError, KeyboardInterrupt):
|
except (EOFError, KeyboardInterrupt):
|
||||||
break
|
break
|
||||||
m.send(line)
|
m.send(line)
|
||||||
while m.morsequeue: pass
|
while m.morsequeue:
|
||||||
|
pass
|
||||||
|
|
||||||
test()
|
if __name__ == '__main__':
|
||||||
|
test()
|
||||||
|
|
|
@ -63,16 +63,16 @@ endif
|
||||||
|
|
||||||
if exists("python_highlight_builtins")
|
if exists("python_highlight_builtins")
|
||||||
syn keyword pythonBuiltin unichr all set abs vars int __import__ unicode
|
syn keyword pythonBuiltin unichr all set abs vars int __import__ unicode
|
||||||
syn keyword pythonBuiltin enumerate reduce coerce intern exit issubclass
|
syn keyword pythonBuiltin enumerate reduce exit issubclass
|
||||||
syn keyword pythonBuiltin divmod file Ellipsis apply isinstance open any
|
syn keyword pythonBuiltin divmod file Ellipsis isinstance open any
|
||||||
syn keyword pythonBuiltin locals help filter basestring slice copyright min
|
syn keyword pythonBuiltin locals help filter basestring slice copyright min
|
||||||
syn keyword pythonBuiltin super sum tuple hex execfile long id xrange chr
|
syn keyword pythonBuiltin super sum tuple hex execfile long id chr
|
||||||
syn keyword pythonBuiltin complex bool zip pow dict True oct NotImplemented
|
syn keyword pythonBuiltin complex bool zip pow dict True oct NotImplemented
|
||||||
syn keyword pythonBuiltin map None float hash getattr buffer max reversed
|
syn keyword pythonBuiltin map None float hash getattr buffer max reversed
|
||||||
syn keyword pythonBuiltin object quit len repr callable credits setattr
|
syn keyword pythonBuiltin object quit len repr callable credits setattr
|
||||||
syn keyword pythonBuiltin eval frozenset sorted ord __debug__ hasattr
|
syn keyword pythonBuiltin eval frozenset sorted ord __debug__ hasattr
|
||||||
syn keyword pythonBuiltin delattr False input license classmethod type
|
syn keyword pythonBuiltin delattr False license classmethod type
|
||||||
syn keyword pythonBuiltin raw_input list iter compile reload range globals
|
syn keyword pythonBuiltin list iter reload range globals
|
||||||
syn keyword pythonBuiltin staticmethod str property round dir cmp
|
syn keyword pythonBuiltin staticmethod str property round dir cmp
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -925,8 +925,6 @@ __import__(name[, Imports module within the given context (see lib ref for
|
||||||
globals[, locals[, more details)
|
globals[, locals[, more details)
|
||||||
fromlist]]])
|
fromlist]]])
|
||||||
abs(x) Return the absolute value of number x.
|
abs(x) Return the absolute value of number x.
|
||||||
apply(f, args[, Calls func/method f with arguments args and optional
|
|
||||||
keywords]) keywords.
|
|
||||||
bool(x) Returns True when the argument x is true and False otherwise.
|
bool(x) Returns True when the argument x is true and False otherwise.
|
||||||
buffer(obj) Creates a buffer reference to an object.
|
buffer(obj) Creates a buffer reference to an object.
|
||||||
callable(x) Returns True if x callable, else False.
|
callable(x) Returns True if x callable, else False.
|
||||||
|
@ -934,10 +932,6 @@ chr(i) Returns one-character string whose ASCII code isinteger i
|
||||||
classmethod(f) Converts a function f, into a method with the class as the
|
classmethod(f) Converts a function f, into a method with the class as the
|
||||||
first argument. Useful for creating alternative constructors.
|
first argument. Useful for creating alternative constructors.
|
||||||
cmp(x,y) Returns negative, 0, positive if x <, ==, > to y
|
cmp(x,y) Returns negative, 0, positive if x <, ==, > to y
|
||||||
coerce(x,y) Returns a tuple of the two numeric arguments converted to a
|
|
||||||
common type.
|
|
||||||
Compiles string into a code object.filename is used in
|
|
||||||
error message, can be any string. It isusually the file
|
|
||||||
compile(string, from which the code was read, or eg. '<string>'if not read
|
compile(string, from which the code was read, or eg. '<string>'if not read
|
||||||
filename, kind) from file.kind can be 'eval' if string is a single stmt, or
|
filename, kind) from file.kind can be 'eval' if string is a single stmt, or
|
||||||
'single' which prints the output of expression statements
|
'single' which prints the output of expression statements
|
||||||
|
@ -971,8 +965,6 @@ hash(object) Returns the hash value of the object (if it has one)
|
||||||
help(f) Display documentation on object f.
|
help(f) Display documentation on object f.
|
||||||
hex(x) Converts a number x to a hexadecimal string.
|
hex(x) Converts a number x to a hexadecimal string.
|
||||||
id(object) Returns a unique 'identity' integer for an object.
|
id(object) Returns a unique 'identity' integer for an object.
|
||||||
input([prompt]) Prints prompt if given. Reads input and evaluates it.
|
|
||||||
Converts a number or a string to a plain integer. Optional
|
|
||||||
int(x[, base]) base paramenter specifies base from which to convert string
|
int(x[, base]) base paramenter specifies base from which to convert string
|
||||||
values.
|
values.
|
||||||
intern(aString) Enters aString in the table of "interned strings"
|
intern(aString) Enters aString in the table of "interned strings"
|
||||||
|
@ -1013,8 +1005,6 @@ property() Created a property with access controlled by functions.
|
||||||
range(start [,end Returns list of ints from >= start and < end.With 1 arg,
|
range(start [,end Returns list of ints from >= start and < end.With 1 arg,
|
||||||
[, step]]) list from 0..arg-1With 2 args, list from start..end-1With 3
|
[, step]]) list from 0..arg-1With 2 args, list from start..end-1With 3
|
||||||
args, list from start up to end by step
|
args, list from start up to end by step
|
||||||
raw_input([prompt]) Prints prompt if given, then reads string from stdinput (no
|
|
||||||
trailing \n). See also input().
|
|
||||||
reduce(f, list [, Applies the binary function f to the items oflist so as to
|
reduce(f, list [, Applies the binary function f to the items oflist so as to
|
||||||
init]) reduce the list to a single value.If init given, it is
|
init]) reduce the list to a single value.If init given, it is
|
||||||
"prepended" to list.
|
"prepended" to list.
|
||||||
|
|
|
@ -378,18 +378,18 @@ support for features needed by `python-mode'.")
|
||||||
"ZeroDivisionError" "__debug__"
|
"ZeroDivisionError" "__debug__"
|
||||||
"__import__" "__name__" "abs" "apply" "basestring"
|
"__import__" "__name__" "abs" "apply" "basestring"
|
||||||
"bool" "buffer" "callable" "chr" "classmethod"
|
"bool" "buffer" "callable" "chr" "classmethod"
|
||||||
"cmp" "coerce" "compile" "complex" "copyright"
|
"cmp" "compile" "complex" "copyright"
|
||||||
"delattr" "dict" "dir" "divmod"
|
"delattr" "dict" "dir" "divmod"
|
||||||
"enumerate" "eval" "execfile" "exit" "file"
|
"enumerate" "eval" "execfile" "exit" "file"
|
||||||
"filter" "float" "getattr" "globals" "hasattr"
|
"filter" "float" "getattr" "globals" "hasattr"
|
||||||
"hash" "hex" "id" "input" "int" "intern"
|
"hash" "hex" "id" "int" "intern"
|
||||||
"isinstance" "issubclass" "iter" "len" "license"
|
"isinstance" "issubclass" "iter" "len" "license"
|
||||||
"list" "locals" "long" "map" "max" "min" "object"
|
"list" "locals" "long" "map" "max" "min" "object"
|
||||||
"oct" "open" "ord" "pow" "property" "range"
|
"oct" "open" "ord" "pow" "property" "range"
|
||||||
"raw_input" "reduce" "reload" "repr" "round"
|
"reduce" "reload" "repr" "round"
|
||||||
"setattr" "slice" "staticmethod" "str" "sum"
|
"setattr" "slice" "staticmethod" "str" "sum"
|
||||||
"super" "tuple" "type" "unichr" "unicode" "vars"
|
"super" "tuple" "type" "unichr" "unicode" "vars"
|
||||||
"xrange" "zip")
|
"zip")
|
||||||
"\\|"))
|
"\\|"))
|
||||||
)
|
)
|
||||||
(list
|
(list
|
||||||
|
|
|
@ -67,6 +67,11 @@ def run_regrtest(lib_dir):
|
||||||
def cleanup(dir):
|
def cleanup(dir):
|
||||||
os.system("rm -rf %s" % dir)
|
os.system("rm -rf %s" % dir)
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
lib_dir = copy_library()
|
lib_dir = copy_library()
|
||||||
compile_files(lib_dir)
|
compile_files(lib_dir)
|
||||||
|
|
|
@ -352,6 +352,11 @@ class LoggingFile:
|
||||||
def close(self):
|
def close(self):
|
||||||
self.outfp.write('\n')
|
self.outfp.write('\n')
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
# Ask permission to download a file.
|
# Ask permission to download a file.
|
||||||
def askabout(filetype, filename, pwd):
|
def askabout(filetype, filename, pwd):
|
||||||
prompt = 'Retrieve %s %s from %s ? [ny] ' % (filetype, filename, pwd)
|
prompt = 'Retrieve %s %s from %s ? [ny] ' % (filetype, filename, pwd)
|
||||||
|
|
|
@ -187,6 +187,11 @@ def copy(src, dst, rmode="rb", wmode="wb", answer='ask'):
|
||||||
f.close()
|
f.close()
|
||||||
g.close()
|
g.close()
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
def okay(prompt, answer='ask'):
|
def okay(prompt, answer='ask'):
|
||||||
answer = answer.strip().lower()
|
answer = answer.strip().lower()
|
||||||
if not answer or answer[0] not in 'ny':
|
if not answer or answer[0] not in 'ny':
|
||||||
|
|
|
@ -105,6 +105,11 @@ def showdiffs(file):
|
||||||
cmd = 'rcsdiff ' + file + ' 2>&1 | ${PAGER-more}'
|
cmd = 'rcsdiff ' + file + ' 2>&1 | ${PAGER-more}'
|
||||||
sts = os.system(cmd)
|
sts = os.system(cmd)
|
||||||
|
|
||||||
|
def raw_input(prompt):
|
||||||
|
sys.stdout.write(prompt)
|
||||||
|
sys.stdout.flush()
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
def askyesno(prompt):
|
def askyesno(prompt):
|
||||||
s = raw_input(prompt)
|
s = raw_input(prompt)
|
||||||
return s in ['y', 'yes']
|
return s in ['y', 'yes']
|
||||||
|
|
|
@ -4,4 +4,6 @@ webchecker.MAXPAGE = 50000
|
||||||
webchecker.verbose = 2
|
webchecker.verbose = 2
|
||||||
sys.argv.append('-x')
|
sys.argv.append('-x')
|
||||||
webchecker.main()
|
webchecker.main()
|
||||||
raw_input("\nCR to exit: ")
|
sys.stdout.write("\nCR to exit: ")
|
||||||
|
sys.stdout.flush()
|
||||||
|
sys.stdin.readline()
|
||||||
|
|
Loading…
Reference in New Issue