def input(prompt=''):
return builtin_mod.input(prompt)
python类input()的实例源码
def input(prompt=''):
return builtin_mod.raw_input(prompt)
def input(prompt=''):
return builtin_mod.input(prompt)
def input(prompt=''):
return builtin_mod.raw_input(prompt)
def init():
# defer imports until initialization
import sys, __builtin__
from ..util import safeeval
class Wrapper:
def __init__(self, fd):
self._fd = fd
def readline(self, size = None):
return readline(size)
def __getattr__(self, k):
return self._fd.__getattribute__(k)
sys.stdin = Wrapper(sys.stdin)
def raw_input(prompt = '', float = True):
"""raw_input(prompt = '', float = True)
Replacement for the built-in `raw_input` using ``pwnlib``s readline
implementation.
Arguments:
prompt(str): The prompt to show to the user.
float(bool): If set to `True`, prompt and input will float to the
bottom of the screen when `term.term_mode` is enabled.
"""
return readline(None, prompt, float)
__builtin__.raw_input = raw_input
def input(prompt = '', float = True):
"""input(prompt = '', float = True)
Replacement for the built-in `input` using ``pwnlib``s readline
implementation, and `pwnlib.util.safeeval.expr` instead of `eval` (!).
Arguments:
prompt(str): The prompt to show to the user.
float(bool): If set to `True`, prompt and input will float to the
bottom of the screen when `term.term_mode` is enabled.
"""
return safeeval.const(readline(None, prompt, float))
__builtin__.input = input
def input(prompt=''):
#input must also be rebinded for using the new raw_input defined
return eval(raw_input(prompt))
def input(prompt=''):
#the original input would only remove a trailing \n, so, at
#this point if we had a \r\n the \r would remain (which is valid for eclipse)
#so, let's remove the remaining \r which python didn't expect.
ret = original_input(prompt)
if ret.endswith('\r'):
return ret[:-1]
return ret
def input(prompt=''):
return builtin_mod.input(prompt)
def input(prompt=''):
return builtin_mod.raw_input(prompt)
def input(prompt=''):
return builtin_mod.input(prompt)
def input(prompt=''):
return builtin_mod.raw_input(prompt)
def init():
# defer imports until initialization
import sys, __builtin__
from ..util import safeeval
class Wrapper:
def __init__(self, fd):
self._fd = fd
def readline(self, size = None):
return readline(size)
def __getattr__(self, k):
return self._fd.__getattribute__(k)
sys.stdin = Wrapper(sys.stdin)
def raw_input(prompt = '', float = True):
"""raw_input(prompt = '', float = True)
Replacement for the built-in `raw_input` using ``pwnlib``s readline
implementation.
Arguments:
prompt(str): The prompt to show to the user.
float(bool): If set to `True`, prompt and input will float to the
bottom of the screen when `term.term_mode` is enabled.
"""
return readline(None, prompt, float)
__builtin__.raw_input = raw_input
def input(prompt = '', float = True):
"""input(prompt = '', float = True)
Replacement for the built-in `input` using ``pwnlib``s readline
implementation, and `pwnlib.util.safeeval.expr` instead of `eval` (!).
Arguments:
prompt(str): The prompt to show to the user.
float(bool): If set to `True`, prompt and input will float to the
bottom of the screen when `term.term_mode` is enabled.
"""
return safeeval.const(readline(None, prompt, float))
__builtin__.input = input
def raw_input(prompt=""):
"""raw_input([prompt]) -> string
Read a string from standard input. The trailing newline is stripped.
If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
On Unix, GNU readline is used if enabled. The prompt string, if given,
is printed without a trailing newline before reading."""
sys.stderr.flush()
tty = STDIN.is_a_TTY() and STDOUT.is_a_TTY()
if RETURN_UNICODE:
if tty:
line_bytes = readline(prompt)
line = stdin_decode(line_bytes)
else:
line = stdio_readline(prompt)
else:
if tty:
line = readline(prompt)
else:
line_unicode = stdio_readline(prompt)
line = stdin_encode(line_unicode)
if line:
return line[:-1] # strip strailing "\n"
else:
raise EOFError
def input(prompt=""):
"""input([prompt]) -> value
Equivalent to eval(raw_input(prompt))."""
string = stdin_decode(raw_input(prompt))
caller_frame = sys._getframe(1)
globals = caller_frame.f_globals
locals = caller_frame.f_locals
return eval(string, globals, locals)
def enable(return_unicode=RETURN_UNICODE):
global RETURN_UNICODE
RETURN_UNICODE = return_unicode
builtins.raw_input = raw_input
builtins.input = input
def disable():
builtins.raw_input = original_raw_input
builtins.input = original_input
def input(prompt=''):
return builtin_mod.input(prompt)
def input(prompt=''):
return builtin_mod.input(prompt)
def input(prompt=''):
return builtin_mod.raw_input(prompt)
def input(prompt=''):
return builtin_mod.input(prompt)
def input(prompt=''):
return builtin_mod.raw_input(prompt)
def input(prompt=''):
return builtin_mod.input(prompt)
def input(prompt=''):
return builtin_mod.raw_input(prompt)