Skip to content

Commit be16156

Browse files
committedMay 21, 2017
fixed eprint for Python 2
1 parent bc1483a commit be16156

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎cs50/cs50.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ def write(self, x):
2121
sys.stderr = flushfile(sys.stderr)
2222
sys.stdout = flushfile(sys.stdout)
2323

24-
def eprint(*objects, end="\n", sep=" "):
24+
def eprint(*args, **kwargs):
2525
"""
2626
Print an error message to standard error, prefixing it with
2727
file name and line number from which method was called.
2828
"""
29-
(frame, filename, lineno, function, code_context, index) = inspect.stack()[1]
29+
end = kwargs.get("end", "\n")
30+
sep = kwargs.get("sep", " ")
31+
(filename, lineno) = inspect.stack()[1][1:3]
3032
print("{}:{}: ".format(filename, lineno), end="")
31-
print(*objects, end=end, file=sys.stderr, sep=sep)
33+
print(*args, end=end, file=sys.stderr, sep=sep)
3234

3335
def get_char():
3436
"""Read a line of text from standard input and return the equivalent char."""

0 commit comments

Comments
 (0)