Skip to content
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

Merged
merged 4 commits into from
May 21, 2017
Merged

added eprint #16

merged 4 commits into from
May 21, 2017

Conversation

dmalan
Copy link
Member

@dmalan dmalan commented Apr 29, 2017

No description provided.

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=" "):
Copy link
Member

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?

Copy link
Member Author

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]
Copy link
Member

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]

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@dmalan dmalan merged commit 5455ee4 into develop May 21, 2017
@dmalan dmalan deleted the eprint branch May 21, 2017 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants