We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents bf2b82a + d9c9aba commit 5455ee4Copy full SHA for 5455ee4
cs50/cs50.py
@@ -1,4 +1,5 @@
1
from __future__ import print_function
2
+import inspect
3
import re
4
import sys
5
@@ -20,6 +21,17 @@ def write(self, x):
20
21
sys.stderr = flushfile(sys.stderr)
22
sys.stdout = flushfile(sys.stdout)
23
24
+def eprint(*args, **kwargs):
25
+ """
26
+ Print an error message to standard error, prefixing it with
27
+ file name and line number from which method was called.
28
29
+ end = kwargs.get("end", "\n")
30
+ sep = kwargs.get("sep", " ")
31
+ (filename, lineno) = inspect.stack()[1][1:3]
32
+ print("{}:{}: ".format(filename, lineno), end="")
33
+ print(*args, end=end, file=sys.stderr, sep=sep)
34
+
35
def get_char(prompt=None):
36
"""
37
Read a line of text from standard input and return the equivalent char;
0 commit comments