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

Keyword arguments are possible with placeholders #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wolph
Copy link

@wolph wolph commented Mar 18, 2017

Using a dict() to allow for keyword arguments is the obvious alternative for the new-style keyword arguments. It's a bit odd to say that this sn't supported.

Using a `dict()` to allow for keyword arguments is the obvious alternative for the new-style keyword arguments. It's a bit odd to say that this sn't supported.
@ulope
Copy link
Owner

ulope commented May 9, 2017

Thanks for the PR.

However I think it's a question of semantics whether you'd call this form "keyword arguments". Sure dict accepts kwargs but IMO that has little to do with the % formatting call.

@wolph
Copy link
Author

wolph commented May 9, 2017

I suppose it is, but it's a commonly used technique so it would be good to document that regardless of whether it's related to the formatting call.

@xmo-odoo
Copy link

I don't know that the split even makes sense, fundamentally the first section is already using keyword arguments: % uses dicts for named placeholders while format uses keyword arguments (though there is format_map). I think it'd be more sensible to use both in the first example, and add a note pointing out ** or str.format_map in the specific case where one already has a dict object.

@wolph
Copy link
Author

wolph commented Feb 21, 2019

In any case, I think this should document an alternative solution for common use cases and for the projects I've seen the dict approach is common enough so it should be added.

@ulope will this get merged or should I just close it?

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

3 participants