10 examples of 'python raw input' in Python

Every line of 'python raw input' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
162def compat_input(s=""): # pragma: no cover
163 """Compatibility function to permit testing for Python 2 and 3."""
164 try:
165 return raw_input(s)
166 except NameError:
167 # Py2 raw_input() renamed to input() in Py3
168 return input(s) # lgtm[py/use-of-input]
86def _input(prompt):
87 if _PY2: # pragma: no cover
88 return raw_input(prompt) # noqa # pragma: no cover (py2 only)
89 else:
90 return input(prompt) # noqa # pragma: no cover
31def input( s ):
32 if sys.stdout.encoding:
33 s = s.decode('utf8').encode(sys.stdout.encoding)
34 return raw_input(s)
8def python2_input(prompt=None):
9 try:
10 cur_stdin, cur_stdout = sys.stdin, sys.stdout
11 if hasattr(sys.stdin, '_original_stream'):
12 sys.stdin = sys.stdin._original_stream
13 if hasattr(sys.stdout, '_original_stream'):
14 sys.stdout = sys.stdout._original_stream
15 encoded_prompt = prompt.encode(getattr(sys.stdout, 'encoding', 'utf-8'))
16 return raw_input(encoded_prompt).decode(getattr(sys.stdin, 'encoding', 'utf-8')) # noqa
17 finally:
18 sys.stdin, sys.stdout = cur_stdin, cur_stdout
61def shell_input(*args, **kwargs):
62 # 2to3 only notices raw_input used as a function
63 return raw_input(*args, **kwargs)
56@staticmethod
57def __python_2(string):
58 # type: (str) -> str
59 return raw_input(string)
21def getUserInput(prompt):
22 if sys.version[0] >= '3':
23 return input(prompt)
24 else:
25 return raw_input(prompt)
2def readinput(k):
3 bstr = raw_input("Enter a binary string %s: " % k)
4 return bstr
16def user_input(text='', hide_input=False):
17 """ Nice little function to read text inputs from stdin """
18 try:
19 if hide_input:
20 inp = getpass.getpass(text)
21 else:
22 inp = input(text)
23 except KeyboardInterrupt:
24 sys.exit(0)
25 except:
26 inp = None
27 return inp
263def _prompt_input(prompt):
264 if prompt is None:
265 return input(PROMPT)
266 else:
267 return input(prompt)

Related snippets