[Python-Dev] The current dict is not an "OrderedDict"
Antoine Pitrou
solipsis at pitrou.net
Tue Nov 7 10:14:12 EST 2017
On Tue, 7 Nov 2017 09:44:07 -0500
Yury Selivanov <yselivanov.ml at gmail.com> wrote:
>
> One common pattern that I see frequently is this:
>
> def foo(**kwargs):
> kwargs.pop('somekey', None)
> bar(**kwargs)
I see it frequently too, but that's in code meant to be
Python 2-compatible (and therefore cannot count on any ordering
guarantee, even de facto). On Python 3 you can write:
def foo(somekey=None, **kwargs):
# do something with somekey?
bar(**kwargs)
Regards
Antoine.
More information about the Python-Dev
mailing list