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

Add support for 'sep' and 'end' kwonlyargs in 'print'. #113

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

belmarca
Copy link
Collaborator

This draft proposes an implementation of sep and end keyword args in print statements.

Works on the online REPL, need to figure out how to test this functionality.

sep = rte_lookup_locals(rte, 'sep')
end = rte_lookup_locals(rte, 'end')

if not (om_isinstance(sep, class_str) or om_isinstance(sep, class_NoneType)):
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's faster to do om_is(sep, om_None) since None is a singleton.

return sem_raise_with_message(ctx, class_TypeError, "end must be None or a string")

sep = OM_get_boxed_value(sep)
end = OM_get_boxed_value(end)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Careful, at this point, sep and end could be om_None in your code.

@@ -7290,7 +7303,7 @@ def print_value(rte, str_result):
if args_len > 0:
return loop(rte, 0)
else:
runtime_print('', rte)
runtime_print('' + end, rte)
Copy link
Collaborator

Choose a reason for hiding this comment

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

runtime_print(end, rte) should do the trick

@omelancon
Copy link
Collaborator

I think we should also add tests

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.

2 participants