-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added eprint #16
added eprint #16
Conversation
cs50/cs50.py
Outdated
@@ -20,6 +21,15 @@ def write(self, x): | |||
sys.stderr = flushfile(sys.stderr) | |||
sys.stdout = flushfile(sys.stdout) | |||
|
|||
def eprint(*objects, end="\n", sep=" "): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifying *object
first is incompatible with Python 2 https://docs.python.org/2/tutorial/controlflow.html#arbitrary-argument-lists.
Before the variable number of arguments, zero or more normal arguments may occur.
Maybe something like
def eprint(*objects, **kwargs):
end = kwargs.get("end", "\n")
sep = kwargs.get("sep", " ")
# ...
would do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, forgot about Python 2, thanks!
cs50/cs50.py
Outdated
Print an error message to standard error, prefixing it with | ||
file name and line number from which method was called. | ||
""" | ||
(frame, filename, lineno, function, code_context, index) = inspect.stack()[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just
(filename, lineno) = inspect.stack()[1][1:3]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
No description provided.